Hi,

I am struggling with a Layout problem. Here is the definition of the problem:-

1) I have a JFrame where I specify space alignment in GroupLayout for JScrollPane as per the other (JButton/ comboBox etc..). My JScrollPane contains a JTable. I use get and set methods to set scrollpane values which is created in the JFileChooser code.

2) Now while updating my JTable content using JFileChooser. I create JScrollPane and add it to the JFrame outside JFileChooser:-
Here is my JFileChooser code snippet.

constructTable(filename);
               scroll = new JScrollPane(table);
               setScrollPane(scroll);
                //JFrame.add(scroll);
               jframe.repaint();

Later I add it outside JFilechooser to the GroupLayout which is then added to the jframe

jframe.add(grouppanell);

The problem is that when the JTable is added after the Jfilechooser adds a file. The ScrollPane comes always at the top thus dismantling all my grouplayout alignment.

Now one solution to it is if I specify the scrollpane Layout using GridBagLayout in the JFileChooser code itself but when I maximize or minimize the wiindow again The Layout alignments are destroyed and scrollpane dissappears. When I click it appears again.

Jframe.setLayout(new GridBagLayout());
                GridBagConstraints c = new GridBagConstraints();
                boolean shouldFill = true;
                if (shouldFill) {
		//natural height, maximum width
		c.fill = GridBagConstraints.HORIZONTAL;
                }
                c.fill = GridBagConstraints.HORIZONTAL;
                c.ipady = -102;      //make this component tall
                c.weightx = 0.0;
                c.gridwidth = 0;
                c.gridx = 0;
                c.gridy = 0;
                jframe.add(scroll, c);//This way works but scrollpane disaapears when maximize window

This way works where I use GridbagLayout and scrollpane in JFileChooser itself but when I maximize or minimize the window scrollpane disappears and when I sometimes click it comes back.!!!!
mysterious.
Is there is way out of this riddle ?

I have tried a lot now but didn't get any success so far.

Thanks in advance

Could you show all your gui code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.