- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
-
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
-
-
- @SuppressWarnings( "serial" )
- public class Menu extends JFrame implements ActionListener{
-
- private JButton start;
- private JButton settings;
- private JButton info;
- private JButton exit;
-
-
- private Menu( String title ) {
-
- super( title ) ;
-
- start = new JButton( "Spiel starten" ) ;
- start.setBounds( 120, 40, 160, 40 ) ;
- start.addActionListener( this ) ;
- add( start ) ;
-
- settings = new JButton( "Einstellungen" ) ;
- settings.setBounds( 120, 120, 160, 40 ) ;
- settings.addActionListener( this ) ;
- add( settings ) ;
-
- info = new JButton( "Credits" ) ;
- info.setBounds( 120, 200, 160, 40 ) ;
- info.addActionListener( this ) ;
- add( info ) ;
-
- exit = new JButton( "Ende" ) ;
- exit.setBounds( 120, 280, 160, 40 ) ;
- exit.addActionListener( this ) ;
- add( exit ) ;
- }
-
- public void actionPerformed( ActionEvent e ) {
-
- if( e.getSource() == start ) {
- new Window() ;
- }
- else if( e.getSource() == info ) {
- Object[] options = {"OK"};
- JOptionPane.showOptionDialog( null, "Programmiert von Chris : ) ", "Information", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[ 0 ] ) ;
- }
- else if( e.getSource() == settings ) {
-
- }
- else if( e.getSource() == exit ) {
- System.exit( 0 ) ;
- }
- }
-
-
-
-
-
-
-
-
- public static void main( String[] args ) {
-
- Menu menu = new Menu( "Menü" ) ;
- menu.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ) ;
- menu.setSize( 400, 400 ) ;
- menu.setLocationRelativeTo( null ) ;
- menu.setLayout( null ) ;
- menu.setVisible( true ) ;
- }
- }
-
-
select language
-
select style
goto line: