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
6
votes
2 answers

Tabs at fixed positions in JTabbedPane or in one row

In our application that has a JTabbedPane with unlimited tabs, when the width of the tabs exceeds the tabbed pane's width, the tabs start wrapping into several rows. When you then click on a tab in one of the upper rows, the complete row comes down…
micro
  • 322
  • 2
  • 12
6
votes
3 answers

Set size of tab in JTabbedPane

Is there any way to change size of tab in JTabbedPane? I mean not all panel but only the small tab that user has to click to see what is under it.
Bulit
  • 975
  • 6
  • 15
  • 26
6
votes
2 answers

How to change background color of JTabbedPane?

I know you can modify the LaF properties, but how do you accomplish this without doing such? I only ask because setBackground doesn't seem to do it. Note that I'm looking to change the following properties: TabbedPane.background (or…
mre
  • 43,520
  • 33
  • 120
  • 170
6
votes
2 answers

How to inform the user that a specific Tab in a JTabbedPane needs attention?

Say you have a user interface with five or more tabs, and you need to inform the user that tab "2" needs attention. Is there a way to do this? For example make the tab flash orange, or change the colour of the tab? I have had no success with…
David
  • 15,652
  • 26
  • 115
  • 156
6
votes
1 answer

validate() tree throws NullPointerException on L&F change?

public class TabbedArea extends JTabbedPane { public void addArea(){ add(component); final JPanel panel = new JPanel(new BorderLayout()); panel.add(new JLabel(title), BorderLayout.LINE_START); JButton closeButton = new JButton(new…
Misha Griffiths
  • 228
  • 2
  • 9
6
votes
2 answers

Closeable JTabbedPane - alignment of the close button

I have implemented my own closeable JTabbedPane (essentially following advice from here - by extending JTabbedPane and overriding some methods and calling setTabComponentAt(...)). It works perfectly except one thing - when there are too many tabs to…
Roderick
  • 63
  • 1
  • 7
6
votes
3 answers

Controlling Color in Java Tabbed Pane

I have been going nuts trying to figure this out. I am trying to elimenate a light blue background that appears in a JTabbedPane. I've tried everything and nothing seems to work. Below is my code. If you run it, it will show the tab, when…
Elliott
  • 5,523
  • 10
  • 48
  • 87
6
votes
2 answers

Hide tab from JTabbedPane

I'm using Netbeans gui to create a simple app. This is my structure (the layout is free design ): Basically I have 3 tabs and want to hide one of them (the select one in the image) based on a condition. Something like if the user as some privileges…
Favolas
  • 6,963
  • 29
  • 75
  • 127
6
votes
3 answers

Forbid tab change in a JTabbedPane

I'm trying to prevent the user from changing a tab when the current tab is not valid. So when he clicks on a tab, I want to check if the current one is "valid", and if not, stay on the current tab. I tried to use a VetoableChangeListener which…
Nanocom
  • 3,696
  • 4
  • 31
  • 46
6
votes
2 answers

Java JTabbedPane allow Tab to switch to only if true

I have some validation that I perform when the user clicks on a tab. If validation == true then allow the tab to show (or to switch to). Right now I am using the StateChanged event to validate. The problem is, when you click on a tab it shows the…
jadrijan
  • 1,438
  • 4
  • 31
  • 48
5
votes
1 answer

Nimbus L&F missing divider at JTabbedPane set to scroll

I am missing the blue horizontal divider between the tabs and the content in a Nimbus L&F TabbedPane set to SCROLL (other L&Fs (default & windows) provide those). As you can see the problem is limited to new JTabbedPane(JTabbedPane.TOP,…
Omphaloskopie
  • 1,952
  • 1
  • 14
  • 24
5
votes
5 answers

How to create vertical tabs in Java?

I would like to get the effect like if JTabbedPane would be turned 90 degrees counterclockwise (only tabs but not the content inside tabs). What is the best way to implement that in Java?
bancer
  • 7,475
  • 7
  • 39
  • 58
5
votes
3 answers

Java: remove margin / padding on a JTabbedPane

I'd like to know how to remove the margins between my JtabbedPane and my JFrame content pane and between my JTabbedPane and its internal JPanel. I circled the margins I want to remove. the green line is here to show the gap between the jpanel inside…
grandouassou
  • 2,500
  • 3
  • 25
  • 60
5
votes
1 answer

Right click JPopupMenu on JTabbedPane

I have a JTabbedPane with a custom tab component. I want to be able to right click anywhere on the tab and show a JPopupMenu. The problem I'm having is that there is dead space on each tab where the JPopupMenu does not appear with a right click. …
mainstringargs
  • 13,563
  • 35
  • 109
  • 174
5
votes
5 answers

Tab component consuming mouse so tabs won't change

I have a problem that when I add a mouse listener to a component that is used as a tab, I can't switch tabs. This demonstrates the problem: import javax.swing.*; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; public…
Boomah
  • 1,172
  • 13
  • 24
1
2
3
54 55