|
|
Java Quellcode |
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 |
import java.io.*; import javax.swing.*; import java.net.*; import java.awt.*; import java.awt.event.*; public class progressbar { public static void main(String[] args) { Frame fenster = new Frame(); fenster.setSize(100, 100); fenster.setTitle("LOADING"); fenster.setLayout(null); JButton b = new JButton("Calculate"); b.addActionListener(new ActionListener()); { public void actionPerformed(ActionEvent e) { for (int i = 0; i > 100; i++) { // Als Beispiel für eine // rechenintensive Operation try { Thread.sleep(100); } catch (InterruptedException ex) {} progressBar.setValue(i); button.setLabel("klick mich"); button.setBounds(50, 50, 50, 50); fenster.add(JButton); progressBar.setValue(i); progressBar.paint(progressBar.getGraphics()); fenster.setValue(true); fenster.setLocation(new Point(100, 100)); } } } |
|
|
Java Quellcode |
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 |
import java.awt.*; import java.awt.event.ActionListener; public class buttonfunktion { public static void main(String[] args) { Frame fenster = new Frame(); fenster.setSize(250, 150); fenster.setLayout(null); fenster.setTitle("Button-Funktion"); Button button = new Button(); button.setBounds(25, 25 , 25, 25); button.setLabel("CLOSE"); button.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { System.exit( 0 ); } } ); fenster.add(button); fenster.setLocation(new Point(100, 100)); fenster.setVisible(true); } } |
|
|
Java Quellcode |
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 48 49 50 51 52 53 54 55 56 57 |
import java.awt.*; import java.awt.event.ActionListener; import java.io.*; import javax.swing.*; import java.net.*; import java.awt.event.*; import java.applet.Applet; public class Project { public static void main(String[] args) { Frame fenster = new Frame(); fenster.setSize(250, 150); fenster.setLayout(null); fenster.setTitle("Button-Funktion"); Button button = new Button(); button.setBounds(25, 25 , 25, 25); button.setLabel("CLOSE"); button.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { System.exit( 0 ); } } ); fenster.add(button); JButton b = new JButton("Calculate"); b.addActionListener(new ActionListener()); { public void actionPerformed(ActionEvent e){ for (int i = 0; i > 100; i++) { try { Thread.sleep(100); } catch (InterruptedException ex) {} progressBar.setValue(i); } } button.setLabel("klick mich"); button.setBounds(50, 50, 50, 50); fenster.add(JButton); progressBar.setValue(i); progressBar.paint(progressBar.getGraphics()); fenster.setValue(true); fenster.setLocation(new Point(100, 100)); fenster.setLocation(new Point(100, 100)); fenster.setVisible(true); }; }; }; |
die würde dir die ganzen Fehler innerhalb des Quelltextes anzeigen.|
|
Java Quellcode |
1 |
b.addActionListener(new ActionListener()); { |
|
|
Java Quellcode |
1 |
b.addActionListener(new ActionListener() { |