I am quite new to Java GUI, and I have a question about JScrollPane:
Why does my scroll_pane not show up?
package good_Package;
public class Class_Operation
{
public static void main(String[] args)
{
Class_Frame frame = new Class_Frame();
frame.setVisible(true);
}//END MAIN
}//END CLASS
And the frame class is below.
package good_Package;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class Class_Frame extends JFrame
{
JTextArea text_area;
JScrollPane scroll_pane;
public Class_Frame()
{
//Basics
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("This is a title.");
getContentPane().setPreferredSize(new Dimension(500, 500));
pack();
setResizable(false);
setLayout(null);//This is a null Layout
getContentPane().setBackground(Color.GREEN);//frame has a different color from the scroll_pane
//END Basics
text_area = new JTextArea(20, 20);
scroll_pane = new JScrollPane(text_area);
scroll_pane.setBackground(Color.CYAN);//scroll_pane has a different color from the frame
scroll_pane.setVisible(true);
getContentPane().add(scroll_pane);
}//END CONSTRUCTOR
}//END CLASS
Thank you for all suitable answers come from the future.