Disabling a textbox in NetBeans
1 answer
You can have two toggles to show active / inactive state. Add an action listener to each, and when "active" is clicked, you call setEditable (true) on the JTextField and when the "inactive" JRadioButton is called, you call setEditable (false).
JTextField textField = new JTextField();
JRadioButton activeButton = new JRadioButton("Active");
JRadioButton inactiveButton = new JRadioButton("Inactive");
activeButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
textField.setEditable(true);
}
});
inactiveButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
textField.setEditable(false);
}
});
+3
a source to share