I have two methods: createGui
and createButton
.
I called createGui
method in main
method.
GUI created.
Now I want to add other components like JButton
in the JFrame
by using createButton
method in createGui
method
How to add a button in a frame by calling createButton
method?
public class JavaGui {
public static void main(String[] args){
CreateGui.createGui();
}
}
class CreateGui{
static GraphicsConfiguration gc;
public static void createGui(){
JFrame frame= new JFrame(gc);
frame.setTitle("gui");
frame.setSize(600, 400);
frame.setLocation(200, 200);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
}
public static void createButton(){
JButton button=new JButton();
}
}