JavaScript
x
public class Main {
public GUI () {
JFrameframe = new JFrame();
JButton button = new JButton("click here!");
JPanel panel = new JPanel();
panel.setBoder(BorderFactory.createEmptyBoarder(30,30,10,30));
panel.setLayout(new GridLayout(0,1));
panel.add(button);
frame.add(panel,BorderLayout.CENTER);
frame.setdefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("first program");
frame.pack();
frame.setVisible(true);}}
the public GUI error what should I do ? it gives me invalid method declaration return type required, this is the first time I used GUI
Advertisement
Answer
Add a return type
JavaScript
public void GUI () {
JFrameframe = new JFrame();
JButton button = new JButton("click here!");
JPanel panel = new JPanel();
panel.setBoder(BorderFactory.createEmptyBoarder(30,30,10,30));
panel.setLayout(new GridLayout(0,1));
panel.add(button);
frame.add(panel,BorderLayout.CENTER);
frame.setdefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("first program");
frame.pack();
frame.setVisible(true);
}