İbrahim Akgün
İbrahim Akgün

Reputation: 1567

How can I make a dynamic JTabbedPane?

I want to do dynamic JTabbedPane, for example:

JTabbedPane tabbedPane = new JTabbedPane();
ImageIcon icon = createImageIcon("images/middle.gif");
JComponent panel1 = makeTextPanel("Panel #1");
tabbedPane.addTab("Tab 1", icon, panel1,"Does nothing");

I can dynamically adding tabs to tabbedpane container. But problem is how can I design panels that I want to add tabbedpane. It's too hard to make from code behind. I can only add a label that's it. Is there any way to Design my panel then add it Jtabbedpane from code behind?

Upvotes: 1

Views: 3018

Answers (2)

Tom Neyland
Tom Neyland

Reputation: 6968

If you are using some sort of swing GUI designer then create a class (design the gui) for the panel that you want to add to the tabbed pane, and then to dynamicaly add that panel to the tabbed pane just go tabbedpane.addTab("Something",null,new MyPredesignedPanel(),"Something");

Upvotes: 0

omerkudat
omerkudat

Reputation: 10051

Why is it more difficult than dynamically adding tabs? Are you perhaps not using the right sort of LayoutManager? Generally, if you choose a good layout manager configuring panels will be much easier. I use the JGoodies Forms, and I heard good things about MigLayout.

Upvotes: 2

Related Questions