Java JPanel create with default layout manager

Description

Java JPanel create with default layout manager

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

public class Main extends JFrame {
  public Main() {
    super("JPaenl default layout");
    setSize(540, 80);/*ww w. ja  v a2s .c  o m*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    JButton play = new JButton("Play");
    JButton stopEject = new JButton("Stop/Eject");
    JButton rewind = new JButton("Rewind");
    JButton fastForward = new JButton("Fast Forward");
    JButton pause = new JButton("Pause");
    
    JPanel pane = new JPanel();
    pane.add(play);
    pane.add(stopEject);
    pane.add(rewind);
    pane.add(fastForward);
    pane.add(pause);
    setContentPane(pane);
    pack();
    setVisible(true);
  }

  public static void main(String[] arguments) {
    Main main = new Main();
  }
}



PreviousNext

Related