Results 1 to 4 of 4
  1. #1
    mlibot is offline Member
    Join Date
    Sep 2009
    Rep Power

    Default How to set enabled my JButton...?

    My JButton will be disabled when running my program... my JButton will be enabled if the value or parameter are equal to 3...
    for example: 1 value is path of the file i selected.
    2 vaue is path of the directory i selected.
    3 value is path of i want to be creating a output.
    if this three value will complete my JButton will be going to enabled...
    and i have no problem with that.

    if i just type a words or letters let say "abcd" of the three TextField... my JButton will not be enabled what should i do to enabled my JButton even though I'm just type a words or letters...?

    Any Idea...?
    hope you help me.

    Thanks in Advance...

  2. #2
    CodesAway's Avatar
    CodesAway is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    Can you paste your code that has the problem. To be honest, I can't figure out a word of what you're saying, but that's because you haven't pasted code that one can check out and see what the problem is.
    CodesAway -
    writing tools that make writing code a little easier

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


    Perhaps a DocumentListener on the JTextFields that need to be complete and only enable the button if al 3 aren't empty. If this doesn't help, then post an SSCCE.

  4. #4
    Willi's Avatar
    Willi is offline Member
    Join Date
    Oct 2009
    Rep Power


    Did you try setEnabled(boolean isEnabled). I think this may help :

    Java Code:
    button.addActionListener(new ActionListener()
        public void run()
            if(!textField.getText().equals("")) // if the JTextField is not empty then enable the button
    the code check only 1 JTextField but you can add them if you want in your program.

Similar Threads

  1. how to enabled, disabled radio buttons
    By mlibot in forum NetBeans
    Replies: 9
    Last Post: 09-25-2009, 08:45 AM
  2. setIcon to jbutton
    By panic in forum New To Java
    Replies: 5
    Last Post: 05-15-2009, 06:33 PM
  3. Help with JButton
    By geoffreybarwise in forum New To Java
    Replies: 4
    Last Post: 05-21-2008, 11:48 AM
  4. JButton onClick?
    By Joe2003 in forum AWT / Swing
    Replies: 2
    Last Post: 01-06-2008, 04:04 PM
  5. Mouse over JButton
    By sandor in forum AWT / Swing
    Replies: 1
    Last Post: 05-17-2007, 10:15 PM

Posting Permissions

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