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);
}
loginbt.setEnabled(name.getText().length()!=0);
– Satherloginbt.setEnabled(name.getText().isEmpty());
– Aime