Results 1 to 12 of 12
  1. #1
    THEL0SER is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default Making Buttons appear and dissappear

    I am new to java, and was wondering if it is possible to make it so when I click one button, it will make one or more new buttons appear. Conversely, can I click one button to make one or more other buttons disappear?

    Would I perhaps use relational or logical operators to do this?

    Thank you in advance for any help or insight!

    :)

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,537
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by THEL0SER View Post
    I am new to java, and was wondering if it is possible to make it so when I click one button, it will make one or more new buttons appear. Conversely, can I click one button to make one or more other buttons disappear?

    Would I perhaps use relational or logical operators to do this?

    Thank you in advance for any help or insight!

    :)
    A JButton can be set (in)visible with the setVisible( ... ) method. An ActionListener object can be 'attached' to a JButton and its actionPerformed( ... ) method is called when a JButton is pressed. Also read the API documentation for that class.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Assuming we're talking Swing.

    OP, if you are still having problems, you may want to provide us with more details on the problem. Please see the second link in my signature links below on how to ask smart questions.

  4. #4
    THEL0SER is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    OK, thanks a lot!

    I am VERY new to java, but at least knowing what I need now should point me in the right direction. I will see if I can find some example code of this being used somewhere.

    Thanks again!
    : )

  5. #5
    THEL0SER is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    One more question, would it be possible to click a button, and make a table appear?

    Thanks!

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,965
    Rep Power
    8

    Default

    Quote Originally Posted by THEL0SER View Post
    One more question, would it be possible to click a button, and make a table appear?

    Thanks!
    What happened when you tried? Check out the API for useful functions.

    Java Platform SE 6

  7. #7
    THEL0SER is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    I am familiar with basic html coding, but I don't have a grasp on the basics of java. My knowledge so far is limited to just copying tutorial java scripts, and substituting my own variables.

    I was able to eliminate more than 100 html pages for an art gallery website with simple java code someone came up with, so now I am interested in learning more, but it is a bit overwhelming, since I am more of an artist, and it takes me while to grasp how code works. So I just hope to verify that want I want to do is possible, before I spend hours and hours getting confused.

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,965
    Rep Power
    8

    Default

    That's fine, but you're going to spend a lot more time asking "Is this possible? What about this?" Checking out the API for useful functions (which often link to tutorials) is a much better approach. Plus, people will grow pretty impatient with answering questions without seeing some effort on your part.

    I suggest you start at the basic tutorials and slowly work your way up: The Java™ Tutorials

  9. #9
    THEL0SER is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    Okay, you are right. Thanks for your time!

    Maybe I will be back in a few months after I've learned the basics!

  10. #10
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,965
    Rep Power
    8

    Default

    Quote Originally Posted by THEL0SER View Post
    Okay, you are right. Thanks for your time!

    Maybe I will be back in a few months after I've learned the basics!
    Well I'm not saying you can't ask questions here- in fact, asking questions as you go through the tutorials is probably a very good idea.

    You can't expect to dive right into the deep end of Swing without some basic background first, is all.

    Much luck.

  11. #11
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by THEL0SER View Post
    I am familiar with basic html coding, but I don't have a grasp on the basics of java. My knowledge so far is limited to just copying tutorial java scripts, and substituting my own variables.

    I was able to eliminate more than 100 html pages for an art gallery website with simple java code someone came up with, so now I am interested in learning more, but it is a bit overwhelming, since I am more of an artist, and it takes me while to grasp how code works. So I just hope to verify that want I want to do is possible, before I spend hours and hours getting confused.
    I've got a sneaking suspicion that the OP is talking about javascript not Java. He may be newbie enough to not realize that there's a difference.

  12. #12
    THEL0SER is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    Yes, I didn't know that there was a difference :) ...

    I will go take a look at wikipedia now...

Similar Threads

  1. actions for buttons
    By steel in forum AWT / Swing
    Replies: 1
    Last Post: 12-02-2010, 05:42 AM
  2. Help with Buttons
    By wld4ubabay in forum New To Java
    Replies: 20
    Last Post: 05-17-2010, 08:13 AM
  3. Where To Get Pop Up Buttons
    By hitmen in forum AWT / Swing
    Replies: 7
    Last Post: 03-26-2009, 04:05 AM
  4. Applet buttons
    By h3ckf1r3 in forum Java Applets
    Replies: 6
    Last Post: 09-22-2008, 09:15 PM
  5. How to use SWT Buttons
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 04:44 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
  •