-3

I made a button Invisible in Java using On Click Listener. Now I want to make the button visible again how can I do it?

Y.T.
  • 1
  • 1
    Assuming this is a jButton and you used `myButton.setVisibility(false);`, can you just `myButton.setVisibility(true);`? – CollinD Oct 01 '15 at 19:43
  • Setting a button to be invisible also effectively makes it unclickable. That means that you will not be able to set it to be visible again in its own OnClick; you'll have to put the `setVisibility` call elsewhere, perhaps on a different button. – Mage Xy Oct 01 '15 at 20:12

1 Answers1

-1

Using swt as an example, ensure you declare the widget somewhere that is accessible by all the areas you want to change visibility.

Button myButton;  // eg. instance variable

Then create the button (eg. in your Composite..)

myButton = new Button(..);

Then each place (eg. in your listeners) you can set these to either true or false:

myButton.setVisible(true);
myButton.setVisible(false);
ergonaut
  • 6,929
  • 1
  • 17
  • 47