Created
May 21, 2012 18:54
-
-
Save Jimshii/2763938 to your computer and use it in GitHub Desktop.
Simple menu stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package skeleton; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import javax.swing.JFrame; | |
import javax.swing.SwingUtilities; | |
import javax.swing.JMenu; | |
import javax.swing.JMenuBar; | |
import javax.swing.JMenuItem; | |
public class Example extends JFrame { | |
/** | |
* | |
*/ | |
private static final long serialVersionUID = 1L; | |
public Example() { | |
initUI(); | |
} | |
public final void initUI() { | |
JMenuBar menubar = new JMenuBar(); | |
JMenu game = new JMenu("Game"); | |
JMenu Options = new JMenu("Settings"); | |
Options.setToolTipText("Change your game options"); | |
Options.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent event) { | |
} | |
}); | |
JMenuItem Vset = new JMenuItem("Visual Settings"); | |
Vset.setToolTipText("Settings related to viewing the game"); | |
JMenuItem Aset = new JMenuItem("Audio Settings"); | |
Aset.setToolTipText("Settings related to sound"); | |
JMenuItem Gset = new JMenuItem("Game Settings"); | |
Gset.setToolTipText("Overall game settings"); | |
Options.add(Vset); | |
Options.add(Aset); | |
Options.add(Gset); | |
JMenu Exit = new JMenu("Exit"); | |
Exit.setToolTipText("Exit application"); | |
Exit.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent event) { | |
System.exit(0); | |
} | |
}); | |
game.add(Options); | |
game.addSeparator(); | |
game.add(Exit); | |
menubar.add(game); | |
setJMenuBar(menubar); | |
setTitle("Simple menu"); | |
setSize(300, 200); | |
setLocationRelativeTo(null); | |
setDefaultCloseOperation(EXIT_ON_CLOSE); | |
} | |
public static void main(String[] args) { | |
SwingUtilities.invokeLater(new Runnable() { | |
public void run() { | |
Example ex = new Example(); | |
ex.setVisible(true); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment