There are main 3 steps.
Following are the steps which I make for the ease of implementation.
Step 1: Update 'field name' property with a variable name. (eg: mainPanel)
Step 2: Create the constructor to set the panel, while extending the class to JFrame class
public class MyClass extends JFrame{
//following component variables are automatically created
private JPanel mainPanel;
public MyClass(){
setContentPane(mainPanel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
}
}
Step 3: Create the main method to make the frame visible
public static void main() {
new MyClass().setVisible(true);
}
Comments
Post a Comment