Skip to content
Advertisement

JTable not visible inside JScrollPane

I have a JTable inside a JScrollPane. I want to show the table only when a particular button is pressed otherwise it should not be shown.

Inorder to incorporate that I have set the setVisible method of the ScrollPane to false while declaring and I set it to true inside the actionPerformed method of the JButton.

But the JTable is not visible even when I press the JButton.

Here’s my code:

JavaScript

I have used group layout so the ScrollPane is added to frame with group layout.

Also the JTable is visible when I do not change the setVisible at all (by default true)

Any help is appreciated…

Advertisement

Answer

When you add components to a visible GUI the basic logic is:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement