A panel is created, three buttons are added to the panel, and then it is added to a frame - Java Swing

Java examples for Swing:JPanel

Description

A panel is created, three buttons are added to the panel, and then it is added to a frame

Demo Code

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main extends JFrame {
  JButton load = new JButton("Load");
  JButton save = new JButton("Save");
  JButton unsubscribe = new JButton("Unsubscribe");

  public Main() {
    super("Button Frame");
    setSize(340, 170);//from   w  ww  .  j  a  v  a 2s  .  c om
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel pane = new JPanel();
    pane.add(load);
    pane.add(save);
    pane.add(unsubscribe);
    add(pane);
    setVisible(true);
  }
  public static void main(String[] arguments) {

    Main bf = new Main();
  }
}

Related Tutorials