Skip to content

Instantly share code, notes, and snippets.

@alsamitech
Created October 22, 2020 17:32
Show Gist options
  • Select an option

  • Save alsamitech/84d8c4d23419fde8ec87fcf17051da25 to your computer and use it in GitHub Desktop.

Select an option

Save alsamitech/84d8c4d23419fde8ec87fcf17051da25 to your computer and use it in GitHub Desktop.
Java GUI With buttons
import javax.swing.*;
class Main{
public static void main(String args[]){
JFrame frame = new JFrame("My First GUI");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,300);
JButton button1 = new JButton("Button 1");
JButton button2 = new JButton("Button 2");
frame.getContentPane().add(button1);
frame.getContentPane().add(button2);
frame.setVisible(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment