0

i want to add isEnabled() method to JTextField, i write a code

tRate=new JTextField();
	if (tRate.isEnabled()){
	JOptionPane.showMessageDialog(c,"press any key to get rate");
		}

but it is giving message just after compilation of program instead when tRate is enabled

4
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by harsimran05
0

all the fields which are created are enabled by default
use this code to disable items

object.setEnabled(false);
1

Well according to my opnion better practice will be making a textfield and a small beautiful button with it. Disable text field. When the user press the button the message box display and ask for data and display it in textfield...
And i think you need confirmation box , not the messagebox.

1

Instead of testing your JTextfield to see if it isEnabled(),
use a variable and track it yourself.
You can set it using Object.setEnabled(Variable); as indicated by Majestics.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.