Questions tagged [jtabbedpane]

A Java Swing component that lets the user switch between a group of components by clicking on a tab with a given title and/or icon.

A Java Swing component that lets the user switch between a group of components by clicking on a tab with a given title and/or icon.

JTabbedPane may have tabs header along any of the four edges. Each tab header consists of the name and optional icon. Clicking on the tab header brings the associated tab to the top. The tab itself can any any single component (most often it is JPanel). Tab components are added to the tabbed pane like keys to the map:

tabbedPane.addTab("My tab", myComponent);

Duplicate tabs headers are possible but usually not used as they may be confusing. JTabbedPane also has methods to remove tabs and replace the tab header texts or icons.

For examples and information on using tabbed panes see How to Use Tabbed Panes.

824 questions
45
votes
2 answers

JTabbedPane ChangeListener

I need to detect when the selected tab changes, and get its index. The following code works, but it fires the println as many times as the amount of tabs currently loaded: tabbedPane.addChangeListener(new ChangeListener() { public void…
deprecated
  • 5,142
  • 3
  • 41
  • 62
32
votes
7 answers

How to add close button to a JTabbedPane Tab?

I'm working in with a JTabbedPane, I need to add a close button in the tabs to close the current one. I have been searching and as I understand I must extend from JPanel and add the close button as they say here But, is there a way to add the close…
Hermandroid
  • 2,120
  • 4
  • 29
  • 35
28
votes
2 answers

How to add tabs to JTabbedPane using WindowBuilder

Ok so I've recently found out about WindowBuilder (Eclipse IDE) that aids in faster creation of Swing applications. I have a added a JTabbedPane using the drag and drop facility. How can I add tabs to it? I have gone through the properties but I…
Saurabh Jain
  • 1,600
  • 1
  • 20
  • 30
22
votes
6 answers

How to switch tabs in jTabbedPane by clicking a Button?

I have two JTabbedPanes, JTabbedPane1 & 2 How can I press button in JTabbedPane2 to show JTabbedPane1 ? Here is the code for JTabbedPane: public class TabbedPane extends JFrame { public TabbedPane() { setTitle("Tabbed Pane"); …
tiendv
  • 2,307
  • 7
  • 23
  • 34
17
votes
7 answers

Is there a way to hide the tab bar of JTabbedPane if only one tab exists?

I want a behavior similar to e.g. Firefox where the list of available tabs does only show up if at least two tabs exist. I wasn't able to find anything like that, yet. The best idea I had was changing the layout manually: in case of one component,…
Huxi
  • 4,242
  • 3
  • 33
  • 31
17
votes
2 answers

NetBeans: How to enable/disable specific tab in JTabedPane

I am developing a small desktop application in Netbeans. on my UI i have a JTabbedPane having 3 tabs in it now i come across a situation where i need to temporarily disable 2nd and 3rd tab. How could i do that programatically. Rightnow i am using…
Jame
  • 21,150
  • 37
  • 80
  • 107
12
votes
3 answers

How can I change the shape of a JTabbedPane tab?

I am trying to change the shape of the tabs in a JTabbedPane. Using setTabComponentAt(0, someComponent); doesn't change the exterior of the tab, which is a rectangle with a diagonal top-left corner. What may be done to change the shape?
farm ostrich
  • 5,881
  • 14
  • 55
  • 81
11
votes
2 answers

Java: JProgressBar (or equivalent) in a JTabbedPane tab title

If I really wanted to do something like that, can I put a JProgressBar (or it's equivalent) in a JTabbedPane tab? (I mean, not in the tab itself, How would I do something like that? EDIT I really do want to put the progressbar in the title of the…
NoozNooz42
  • 4,238
  • 6
  • 33
  • 53
9
votes
4 answers

JTabbedPane customize tab look

I want to customize the look of the tabs in JTabbedPane. I want to start from the simplest and plainest behavior: no borders, solid color. The problem is that a non-plainess still remains: the tabs slight margin overlap. You see that since the…
AgostinoX
  • 7,477
  • 20
  • 77
  • 137
9
votes
2 answers

How to check whether the tab is active or not in JTabbedPane?

How can I check whether a tab in a JTabbedPane instance is active or not, in the class of the tab (nested class) itself and not in the enclosing class? I know that there is a method booloean isEnabledAt(int index); but this method can only be…
Supereme
  • 2,379
  • 12
  • 46
  • 67
9
votes
1 answer

JTabbedPane: icon on left side of tabs

hello i am using the nimbus look-and-feel and have a tabbedpane with an icon and text. now the icon appears on the right side of the text, while i would like to have it on the left side. also i would like to add some spacing between the icon and the…
clamp
  • 33,000
  • 75
  • 203
  • 299
8
votes
2 answers

Select tab by title

I have create a simple code : import javax.swing.*; import java.awt.event.*; import java.awt.*; class tab extends JFrame { JTabbedPane tab=new JTabbedPane(); JTextField input=new JTextField(); JButton button=new JButton("process"); …
newbie
  • 929
  • 17
  • 35
8
votes
4 answers

Java: "Add Tab Button" for a JTabbedPane

Is it possible to add a button to a tabbed pane like in firefox. The plus-button is what I want. Thanks
Martijn Courteaux
  • 67,591
  • 47
  • 198
  • 287
7
votes
2 answers

JTabbedPane.getTabComponentAt(int) returning null

I have the following code : JTabbedPane container; ... AWindow page = WinUtils.buildWindow(); boolean existing = checkIfExists(page); // in this code, this will always be false if(!existing) { String tabName =…
Geo
  • 93,257
  • 117
  • 344
  • 520
7
votes
5 answers

Java JTabbedPane, how can I select a tab from a button?

How can I select a tab as if it was clicked by clicking on a button? I have googled and looked at all the actions but there are just just so many... :( Anyone know off hand? Thanks in advance!
Relequestual
  • 11,631
  • 6
  • 47
  • 83
1
2 3
54 55