Here's a simple GUI Template I have from last year. Hope it helps!
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class GUITemplate extends JFrame
implements ActionListener {
private JPanel panel1, panel2;
private JButton button1, button2;
public GUITemplate() {
setTitle("GUITemplate");
panel1 = new JPanel();
panel2 = new JPanel();
//Button 1
button1 = new JButton("Button 1");
button1.addActionListener(this);
//Button 2
button2 = new JButton("Button 2");
button2.addActionListener(this);
setLayout(new GridLayout(2,1));
//add buttons to panels
panel1.add(button1);
panel2.add(button2);
add(panel1);
add(panel2);
}
public static void main(String args[]) {
GUITemplate gui = new GUITemplate();
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gui.setSize(200,200);
gui.setLocation(200,200);
gui.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==button1) {
button1.setEnabled(false);
}
if(e.getSource()==button2) {
button1.setEnabled(true);
}
}
}