Results 1 to 6 of 6
  1. #1
    michalss is offline Member
    Join Date
    Mar 2011
    Posts
    17
    Rep Power
    0

    Default setVisible does not work

    Hi all,

    I have a strange problem i cannot solve for days. Pls have a look on this code:

    Java Code:
     private void treeAccountsMouseClicked(java.awt.event.MouseEvent evt) {
            
            DefaultMutableTreeNode node = (DefaultMutableTreeNode)treeAccounts.getLastSelectedPathComponent();
            String output = treeAccounts.getLastSelectedPathComponent().toString();
            
            //System.out.println(output);
            
            if ("Accounts".equals(output)) {
                tableAccounts.setVisible(true);
                     
            } else {
               tableAccounts.setVisible(false);
               
            }
        }
    Nothing interesting going on, but this tableAccounts.setVisible(false); does not do anything it should hide the swing component but it does not. I have also try repaint, invalidate(), revalidate, nothing works. But for example panel is working just fine. Any idea, it is mistery i dont understand. From my point of view it is a hure BUG in java it self.

    Regards

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default

    Post your Short, Self Contained, Correct Example that demonstrates the problem.

  3. #3
    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 camickr View Post
    Post your Short, Self Contained, Correct Example that demonstrates the problem.
    I second that. I'll bet that he has shadowed the tableAccounts variable so that the one being set visible and invisible is not the one being displayed, but again, since the problem is not in the code posted, I again strongly second the recommendation that the OP create and post an SSCCE.

    To the OP, please read the link as we don't want to see all of your code or even code snippets as folks often post the wrong snippet and not the one that shows the problem (as you've done here). Better to create a new small compilable runnable program that demonstrates the problem. Again, the link will explain all.

  4. #4
    michalss is offline Member
    Join Date
    Mar 2011
    Posts
    17
    Rep Power
    0

    Default

    Well. What i want to archive is to hide jTable component during the click button event. It simple does not hide it! It does not do anything. My guess when i use setVisible false it should hide it but it wont. There is no any example needed. I found this on java as a major bug and it is case by treading. I was wonder there might be some workaround?

  5. #5
    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 michalss View Post
    Well. What i want to archive is to hide jTable component during the click button event. It simple does not hide it! It does not do anything. My guess when i use setVisible false it should hide it but it wont. There is no any example needed. I found this on java as a major bug and it is case by treading. I was wonder there might be some workaround?
    It's a bug alright, but the odds are 999999 to 1 that it's a bug in your code not in "Java". But until you show the code we can discuss all we want but we won't be able to help you to a solution.

  6. #6
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

    Default

    The first question that comes in my mind is, Are you sure that method is even called??

Similar Threads

  1. Replies: 4
    Last Post: 12-27-2010, 03:43 PM
  2. .setVisible(false); not working... grr...
    By Roclemir in forum New To Java
    Replies: 8
    Last Post: 05-29-2010, 12:22 AM
  3. can't get setVisible(false) to work
    By alexander.s in forum AWT / Swing
    Replies: 0
    Last Post: 04-27-2010, 08:33 PM
  4. Replies: 4
    Last Post: 02-26-2009, 11:46 PM
  5. setVisible(true) does not work
    By Gajesh Tripathi in forum AWT / Swing
    Replies: 2
    Last Post: 10-27-2007, 07:32 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
  •