Swing Button Quiz - Java Swing

Java examples for Swing:JButton

Introduction

Create an application with a frame that includes several DVR controls as individual components with JButton.

  • play
  • stop/eject
  • rewind
  • fast-forward
  • pause

Demo Code

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

public class Main extends JFrame {
  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");

  public Main() {
    super("DVR");
    setSize(540, 80);/*from  w  ww  .  j a v  a  2 s.c om*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel pane = new JPanel();
    pane.add(play);
    pane.add(stopEject);
    pane.add(rewind);
    pane.add(fastForward);
    pane.add(pause);
    setContentPane(pane);
    setVisible(true);
  }

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

Related Tutorials