class Fenster extends JFrame {
Fenster(){
super("Mein Fenster");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(250, 200);
Container contentPane=getContentPane();
contentPane.setLayout(new FlowLayout(FlowLayout.CENTER));
JTextField myTextField;
myTextField = new JTextField("Hello World");
contentPane.add(myTextField);
myTextField.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
myTextField.setText("");
}
});
this.setResizable(false);
this.setLocation(200, 200);
this.setVisible(true);
}
}
super("Mein Fenster");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(250, 200);
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout(FlowLayout.CENTER));
final JTextField myTextField2;
myTextField2 = new JTextField("Hello World");
contentPane.add(myTextField2);
final JTextField myTextField;
myTextField = new JTextField("Hello World");
contentPane.add(myTextField);
myTextField.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
myTextField.setText("");
}
});
setResizable(false);
setLocation(200, 200);
setVisible(true);
ich habe ein Jtextfield wo am Anfang z.b hier eingeben seht und ich möchte es gerne wenn das Feld Fokussiert das es geleert wird
import java.awt.Component;
import java.util.Arrays;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Test {
public Test() {
initComponent();
}
private void initComponent(){
JFrame f = new JFrame();
JPanel1 //... mehr Component,Listeners etc
}
}
import java.awt.Component;
import java.util.Arrays;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Test {
public Test() {
JFrame f = new JFrame();
JPanel1 //...mehr Component,Listeners etc
}
}
...
initMenu();
initPanel1();
initPanel2();
...