6 Replies Latest reply on Jun 25, 2009 1:29 PM by 843804

    setvisible with java 1.6.11 and up

      Help please!!!

      We have an application that switches out panels in a JSplitPane. One of the panels is a very large JScrolledPane and when setting the visibility to false it can lock the application 30-60 seconds. This all started happening with the 1.6.11 update. Has anyone seen this or have any clues on why?

        • 1. Re: setvisible with java 1.6.11 and up
          Well, after a little more digging, it is not setvisible that is the issue, it is the remove(component) that seems to be the problem.
          • 2. Re: setvisible with java 1.6.11 and up
            Can you prepare an SSCCE that demonstrates the same behaviour you describe?

            And as an aside, it is rarely, if ever, necessary to call setVisible(boolean) on anything short of root (JFrame, JDialog..) components.
            • 3. Re: setvisible with java 1.6.11 and up
              Thanks for the reply. And here you go. But, now I have a bigger problem. This works for 1.5 thru 1.6.14!!! Granted our panels are move complex, but it still should not lock up the application during the remove call.

              Thanks again,

              import java.awt.*;
              import java.awt.event.*;
              import javax.swing.*;
              import javax.swing.table.*;

              public class RemoveExample {
              static JFrame frame = new JFrame("Remove Issue");
              static JSplitPane mainPanel = new JSplitPane();
              static JSplitPane panel1 = new JSplitPane();
              static JSplitPane panel2 = new JSplitPane();

              public static void main(String args[]) {
                   JPanel buttonPanel = new JPanel(new FlowLayout());
                   JButton button = new JButton("Switch Panels");
                   button.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        if (panel1.isVisible()) {
                        } else {



                   panel1.setLeftComponent(new JScrollPane(new JTree()));
                   panel1.setRightComponent(new JLabel("small panel"));

                   JTabbedPane tabs = new JTabbedPane();
                   JPanel thumbnails = new JPanel(new GridLayout(0, 5, 10, 10));
                   DefaultTableModel dtm = new DefaultTableModel();
                   JTable table = new JTable(dtm);

                   tabs.addTab("Thumbnails", new JScrollPane(thumbnails));
                   tabs.addTab("List", new JScrollPane(table));

                   panel2.setLeftComponent(new JScrollPane(new JTree()));

                   frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
                   frame.setSize(1000, 800);
                   LoadThread loader = new LoadThread(thumbnails, table);

              public static class LoadThread extends Thread {
                   JPanel thumbs;
                   JTable table;

                   public LoadThread(JPanel thumbs, JTable table) {
                   this.thumbs = thumbs;
                   this.table = table;

                   public void run() {
                   DefaultTableModel dtm = (DefaultTableModel)table.getModel();
                   for (int i = 0; i < 4000; i++) {
                        JLabel label = new JLabel("image " + i);
              // set image icon.
                        //label.setIcon(new ImageIcon("image.jpg"));
                        dtm.insertRow(i, new String[]{ "image " + i, "Name", "Gallery",
                                       "Owner", "Uploaded", "Size(KB)" } );

              Edited by: Pegasus-3326 on Jun 25, 2009 4:38 AM
              • 4. Re: setvisible with java 1.6.11 and up
                As a side note, this problem seems to be fixed with the latest 1.7 build.
                • 5. Re: setvisible with java 1.6.11 and up
                  As a side note, this problem seems to be fixed with the latest 1.7 build.>
                  What 'problem'? Your next to last post was confusing to me because you stated you now had code that worked, yet alluded to 'another' problem but neglected to mention what it was. Taxes, death, ..absent mindedness? I thought I'd wait for you to clarify.

                  BTW. When posting code, code snippets, HTML/XML or input/output, please use the code tags. To do that, select the code and click the CODE button seen on the Plain Text tab of the message posting form.
                  • 6. Re: setvisible with java 1.6.11 and up
                    Sorry, I am new to this site, but I will get better with time. Anyway, let me start over.

                    We have an application, currently in beta, that started having problems with the 6.11 and up updates. The problem is when switching out (container add/remove) very large panels. The application "hangs" for x number of seconds depending on size, one of our test cases hangs for 60 seconds. So, you asked me to put together an example of the problem. So I put something together that sort of resembled our use case. The sample code posted worked without problems, which frustrated me to no end. But, this was a very simple mock up and i did not what to leave you hanging without any reply, since you were nice enough to ask for more information. After that post, I started building out the sample code to see if I could find the breaking point; and also, decided to check for any java updates coming. Well, I found java 1.7 and decided to see what would happen. To my surprise and frustration the hanging problem went away.