blob: 4b9e8e3b45f13c989f9e2461ff233f0fda195c64 (
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
|
/* Listing3714.java */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Listing3714
extends JFrame
implements ActionListener
{
private JProgressBar pb;
private int value = 0;
public Listing3714()
{
super("JProgressBar");
addWindowListener(new WindowClosingAdapter(true));
Container cp = getContentPane();
//Fortschrittsanzeige
pb = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
pb.setStringPainted(true);
cp.add(pb, BorderLayout.NORTH);
//Weiter-Button
JButton button = new JButton("Weiter");
button.addActionListener(this);
cp.add(button, BorderLayout.SOUTH);
}
public void actionPerformed(ActionEvent event)
{
value = (value >= 100 ? 0 : value + 5);
pb.setValue(value);
}
public static void main(String[] args)
{
Listing3714 frame = new Listing3714();
frame.setLocation(100, 100);
frame.setSize(300, 150);
frame.setVisible(true);
}
}
|