Skip to content
Home
Post Code
Jass (Warcraft III)
Wurst
GUI (Warcraft III)
Galaxy (StarCraft II)
GUI (StarCraft II)
C++
Java
Delphi
Text
Search Code
Compare Code
Uploads
Draw
Create New Drawing
View Drawings
Graph
Log in
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
{
// JButtons fürs Menü erstellen
private JButton start;
private JButton settings;
private JButton info;
private JButton exit;
// Konstruktor für die Menu-GUI
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);
}
// Actionevents für die JButtons
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)
{
// settings();
}
else
if
(e
.
getSource()
=
=
exit)
{
System.exit(0);
}
}
// Platzhalter für den Menüpunkt: Einstellungen
//
// public static void settings() {
//
// }
// Startpunkt fürs Programm: Ruft den Konstruktor auf und passt ihn an
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
jass
java
> delphi
C++
php
GSL
galaxy
visualBasic
wurst
Text
Markdown
select style
> default
bbcode - default
Jasscraft
jasscraft html
visual
lightweight
lightweightNr
goto line:
Compare with:
text copy window
edit this code
post new code
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{ // JButtons fürs Menü erstellen private JButton start; private JButton settings; private JButton info; private JButton exit; // Konstruktor für die Menu-GUI 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); } // Actionevents für die JButtons 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) { // settings(); } else if (e.getSource() == exit) { System.exit(0); } } // Platzhalter für den Menüpunkt: Einstellungen // // public static void settings() { // // } // Startpunkt fürs Programm: Ruft den Konstruktor auf und passt ihn an 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); } }