Results 1 to 3 of 3
  1. #1
    JonoF is offline Member
    Join Date
    Apr 2009
    Posts
    13
    Rep Power
    0

    Default [SOLVED] JButton actionlistener, if statement, JLabel visibility

    Right i have no idea how to do this, or even if it can be done, so I'm just gonna put it out there.

    I have a JButton with an actionListener, and i want it to do something dependent on whether a JLabel is visible or not.

    Pseudo code:

    JButton pressed
    {
    if label1.visible = true
    { do this code }

    if else label2.visible = true
    { do this code }

    if else label3.visible = true
    { do this code }
    }


    Any ideas?

  2. #2
    JonoF is offline Member
    Join Date
    Apr 2009
    Posts
    13
    Rep Power
    0

    Default

    Nevermind, just found the isVisible method

    SOLVED

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default

    Quote Originally Posted by JonoF View Post
    Any ideas?
    Check the JLabel API documentation to see if their are publically accessible fields like visible for a JLabel. (or for that matter any other Swing components.)

    Failing that look for a method that returns this information. You may have to search through the superclass methods as well. If there were such a method it is the sort of thing that any Component might have.

    [Edit]
    Too slow!

Similar Threads

  1. ActionListener Error
    By blackstormattack in forum New To Java
    Replies: 1
    Last Post: 03-05-2009, 09:36 AM
  2. Newbie help on visibility and static final
    By tornado in forum New To Java
    Replies: 3
    Last Post: 11-28-2008, 02:32 AM
  3. Demonstrating the ActionListener
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 04-23-2008, 09:20 PM
  4. How to use KeyListener and ActionListener
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 04-23-2008, 09:19 PM
  5. ActionListener interface
    By tsantana in forum New To Java
    Replies: 2
    Last Post: 03-30-2008, 11:24 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
  •