Java:
package Grafik;
import javax.swing.*;
public class Oberfläche{
public static void main( String[] args ) {
JFrame f = new JFrame( "Fenster" ) ;
f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
f.setSize( 1000,500 );
f.setLocation(250,200);
f.setLayout(null);
String text = "Name";
JLabel label = new JLabel( text );
f.add( label );
label.setSize(100,100);
label.setLocation(100,100);
JTextField name = new JTextField( "jan");
name.setSize(100,20);
name.setLocation(200,140);
f.add(name);
String text1 = "Wohnort" ;
JLabel label1 = new JLabel ( text1);
f.add(label1);
label1.setSize(100,100);
label1.setLocation(100,200);
JTextField wohnort = new JTextField("rodenbach " );
wohnort.setSize(100,20);
wohnort.setLocation(200,240);
f.add(wohnort);
JCheckBox cb1 = new JCheckBox( "Aktzeptieren" );
f.add(cb1);
cb1.setSize(100,100);
cb1.setLocation(100,300);
JCheckBox cb2 = new JCheckBox( "Nicht Aktzeptieren");
f.add(cb2);
cb2.setSize(200,100);
cb2.setLocation(200,300);
f.setVisible( true );
for(;;){ //besser aktionlistener
if(cb1.isSelected()){
// String text3 = "Ausgabe:"+wohnort+name;
JLabel label3 = new JLabel( "Ausgabe:"+wohnort+name);
f.add( label3 );
label3.setSize(1000,100);
label3.setLocation(400,400);
}
}
}
}
wie kann man die Endlosschleife for( ; ; ) mit einem aktionlistener ausdrücken
danke