Habe folgendes Problem:
Ich muss eine sich ändernde Zahl in ein Textfield schreiben.
Das problem ist dass ich keine NON-STATIC variablen in STATIC Textfield schreiken kann.
Wie Kann ich es den jetzt machen??
Wert0,1 und 2 sind strings und bekomme sie spläter im main.
Hab echt keine ahnung wie ich dass machen soll, wieleicht weiss einer von euch wie dies zu machen ist.
Ich muss eine sich ändernde Zahl in ein Textfield schreiben.
Das problem ist dass ich keine NON-STATIC variablen in STATIC Textfield schreiken kann.
Wie Kann ich es den jetzt machen??
Code:
import java.awt.Font;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Boxes {
public static void addInternalToDesktop( JDesktopPane desktop ) {
JInternalFrame iframe;
iframe = new JInternalFrame( "Wert 1", // title
true, // resizable
true, // closeable
true, // maximizable
true ); // iconifiable
iframe.setSize(1600, 1140/3);
iframe.setLocation(0, 1140/3);
iframe.add( new JScrollPane(new JTextArea()) );
iframe.setVisible( true );
JTextField iIText;
iIText = new JTextField("Wert 1:" + Wert1);
iIText.setFont( new Font("Serif", Font.BOLD, 20) );
iIText.setLocation(0, 0);
iIText.setSize(100, 100);
iframe.add(iIText);
desktop.add( iframe );
}
public static void addInternalToDesktop1( JDesktopPane desktop ) {
JInternalFrame iframe;
iframe = new JInternalFrame( "Wert 2", // title
true, // resizable
true, // closeable
true, // maximizable
true ); // iconifiable
iframe.setSize(1600, 1140/3);
iframe.setLocation(0, (2*1140)/3);
iframe.add( new JScrollPane(new JTextArea()) );
iframe.setVisible( true );
JTextField iIText;
iIText = new JTextField("Wert 2:" + Wert2);
iIText.setFont( new Font("Serif", Font.BOLD, 20) );
iframe.add(iIText);
desktop.add( iframe );
}
public static void addInternalToDesktop2( JDesktopPane desktop ) {
JInternalFrame iframe;
iframe = new JInternalFrame( "Wert 0", // title
true, // resizable
true, // closeable
true, // maximizable
true ); // iconifiable
iframe.setSize(1600, 1140/3);
iframe.setLocation(0, 0);
iframe.add( new JScrollPane(new JTextArea()) );
iframe.setVisible( true );
JTextField iIText;
iIText = new JTextField("Wert 0:" + Wert0);
iIText.setFont( new Font("Serif", Font.BOLD, 20) );
iframe.add(iIText);
desktop.add( iframe );
}
public static void main( String[] args ) {
JFrame f = new JFrame("Informations");
f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
JDesktopPane desktop = new JDesktopPane();
f.add( desktop );
f.setSize( 1600, 1140 );
addInternalToDesktop( desktop );
addInternalToDesktop1( desktop );
addInternalToDesktop2( desktop );
f.setVisible( true );
}
}
Wert0,1 und 2 sind strings und bekomme sie spläter im main.
Hab echt keine ahnung wie ich dass machen soll, wieleicht weiss einer von euch wie dies zu machen ist.