View RSS Feed

Java Swing

Creating and Showing Frames

Rate this Entry
by , 04-26-2012 at 08:50 PM (597 Views)
Extremely plain window’s picture is given below that is made by the demonstration application FrameDemo. Source code could be found in FrameDemo.java. FrameDemo could be run (downloading JDK6, or later.)

How to setup a frame has been shown in the given code of FrameDemo.

Java Code:
//1. Create the frame.
JFrame frame = new JFrame("FrameDemo");

//2. Optional: What happens when the frame closes?
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//3. Create components and put them in the frame.
//...create emptyLabel...
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);

//4. Size the frame.
frame.pack();

//5. Show it.
frame.setVisible(true);

Submit "Creating and Showing Frames" to Facebook Submit "Creating and Showing Frames" to Digg Submit "Creating and Showing Frames" to del.icio.us Submit "Creating and Showing Frames" to StumbleUpon Submit "Creating and Showing Frames" to Google

Categories
JFrame

Comments