I am developing an java gui. It has TabedPane. I have added panel to tab. How to add jtable to panel which is in tab2;
Asked
Active
Viewed 1,901 times
-2
-
have you tried getTabComponentAt(int index)? – Jonas Eicher Dec 05 '12 at 16:37
2 Answers
1
To get the compoenent at a particular index use getComponentAt (as suggested by Jonas Eicher in the comment.)
JPanel tabPanel = (JPanel) tabbedPane.getComponentAt(index);
Add your table to the panel like the following.
tabPanel.add(new JScrollPane(table));

Amarnath
- 8,736
- 10
- 54
- 81
0
Just create fields or local variables for your components, so you can reference them, i.e.:
JPanel panel = new JPanel();
JTable table = new JTable();
tabbedPane.insertTab("title", null, panel, null, 0);
panel.add(table);

Jonas Eicher
- 1,413
- 12
- 18