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

Recommended Answers

All 6 Replies

TextFields are enabled by default....

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


then how can we add message dailog box to text field

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.

Member Avatar

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.