So I got know this is a popular question and already found the solution. But when I try this it doesn't work properly.
My JTextField is empty and the button isn't enabled. When I write something in my textfield the button doesn't get enabled.
So my program should check this field every second whether it's empty or not. As soon as someone writes something into the textfield the button should be enabled.^^
loginbt = new JButton("Login");
loginbt.addActionListener(new loginHandler());
add(loginbt);
if(name.getText().equals("")) {
loginbt.setEnabled(false);
}else {
loginbt.setEnabled(true);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…