blob: 4ce36681cf55057c03b09434439e5733d658e1a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/* Listing3707.java */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Listing3707
extends JFrame
implements ActionListener
{
public Listing3707()
{
super("JButton");
addWindowListener(new WindowClosingAdapter(true));
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
JPanel panel = new JPanel();
//OK-Button
JButton okButton = new DefaultButton("OK", getRootPane());
okButton.addActionListener(this);
panel.add(okButton);
//Abbrechen-Button
JButton cancelButton = new CancelButton("Abbrechen");
cancelButton.addActionListener(this);
panel.add(cancelButton);
//Hilfe-Button
JButton helpButton = new JButton("Hilfe");
helpButton.setMnemonic('H');
helpButton.addActionListener(this);
panel.add(helpButton);
//Panel hinzuf�gen
cp.add(panel);
}
public void actionPerformed(ActionEvent event)
{
System.out.println(event.getActionCommand());
}
public static void main(String[] args)
{
Listing3707 frame = new Listing3707();
frame.setLocation(100, 100);
frame.setSize(300, 100);
frame.setVisible(true);
}
}
|