Searching...
Sunday, June 1, 2014

Swings JFrame -1

June 01, 2014
In this first lesson we will start slowly and just introduce the concepts and code which you will use to create a JFrame.A JFrame is the main window that you use to display the components you want to show on the screen. FrameExample.java
package java9r.blogspot.com;

import javax.swing.*;
//Importing the package that contains all the Swing Components and Classes.

public class FrameExample {

 public static void main(String[] args) {
     //Schedule a job for the event-dispatching thread:
     //creating and showing this application's GUI.
     SwingUtilities.invokeLater(new Runnable() {
         public void run() {
             createAndShowGUI();
         }
     });
 }

 private static void createAndShowGUI() {
     //Create and set up the frame.
     //The string passed as an argument will be displayed
     //as the title.

     JFrame frame = new JFrame("-----------Hello World--------------");

     //Display the window.
     frame.setSize(400, 400);
     frame.setVisible(true);
 } 
}
 Output

0 comments:

Post a Comment

ads2