Enabling and Disabling the Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lost Prophet
    New Member
    • Mar 2008
    • 14

    Enabling and Disabling the Button

    I have a problem. I have code that generates a GUI. This is the first thing that the application does.

    I want to incorporate a button, that when information is available becomes enabled but when information isnt available is disabled.

    Using the buttonname.setE nabled(false) does not work. It initially does but the button never becomes enabled. Ive tried using various structures of where I have placed the buttonname.setE nabled(true) but the GUI is not being updated. Any ideas on how I can update the GUI when buttonname.setE nabled(true) is accessed??

    Thanks
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    You can use ActionListeners so that once everything that needs to be entered has been entered, you call setEnabled(true ). If you need help with them (they have quirks), poke around here for help. Google will probably also prove helpful.

    Comment

    • krishnanghri
      New Member
      • Mar 2008
      • 1

      #3
      If u can use a button as setEnable(true) it just has focus to the button.
      You can try using a ActionEvent with KeyListener.

      Whenever a key is stroked ur button condition should become true..
      or else it will be in default mode setEnable(false );

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by Lost Prophet
        I have a problem. I have code that generates a GUI. This is the first thing that the application does.

        I want to incorporate a button, that when information is available becomes enabled but when information isnt available is disabled.

        Using the buttonname.setE nabled(false) does not work. It initially does but the button never becomes enabled. Ive tried using various structures of where I have placed the buttonname.setE nabled(true) but the GUI is not being updated. Any ideas on how I can update the GUI when buttonname.setE nabled(true) is accessed??

        Thanks
        w.r.t. the boldface part: then the error must be somewhere else in your code. Don't
        work around your bug, fix it instead.

        kind regards,

        Jos

        Comment

        Working...