Results 1 to 3 of 3
  1. #1
    harsimran05 is offline Member
    Join Date
    Sep 2011
    Rep Power

    Default isEnabled() method

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

    Java 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

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: isEnabled() method

    The code is written to be run when the tRate text field is created, so this behavior should come as no surprise. Writing an if block will not magically make it activate if tRate is enabled. Instead it will only be able to tell you the state of tRate at that point in time, right when the GUI is created. It seems you instead want to listen for when tRate is enabled, and that means having to listen for this event, probably by adding a PropertyChangeListener to your JTextField and listening for the "enabled" property.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

Similar Threads

  1. Replies: 18
    Last Post: 04-18-2011, 05:39 AM
  2. Turning Recursion Method into Iterative method
    By mattakuevan in forum New To Java
    Replies: 9
    Last Post: 06-15-2010, 06:46 AM
  3. Replies: 2
    Last Post: 03-26-2010, 05:12 PM
  4. Replies: 29
    Last Post: 09-25-2008, 07:55 PM
  5. cannot call private method from static method
    By jon80 in forum New To Java
    Replies: 3
    Last Post: 05-07-2008, 08:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts