Java:
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class GUI extends JFrame {
public static JButton button4;
public static JButton button5;
public static boolean beginn = false;
public GUI() {
this.setSize(1000, 140);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setAlwaysOnTop(true);
button4 = new JButton("Start");
button5 = new JButton("Stopp");
JPanel panel1 = new JPanel(new GridLayout(2, 1));
panel1.add(button4);
panel1.add(button5);
this.add(panel1);
this.setVisible(true);
button4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
beginn = true;
JOptionPane.showMessageDialog((JButton) e.getSource(),
"Gestartet");
while (beginn) {
System.out.println(".");
}
}
});
button5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
beginn = false;
}
});
}
}
Ein einfaches Programm aber ich komm nicht aus der Schleife. Kann jemand den Code Korrigieren bitte?