From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../hjp5/examples/Listing3714.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/hjp5/examples/Listing3714.java (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing3714.java') diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Listing3714.java b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3714.java new file mode 100644 index 0000000..4b9e8e3 --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3714.java @@ -0,0 +1,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); + } +} \ No newline at end of file -- cgit v1.2.3