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
4
votes
1 answer

Change color of JTabbedPane border

I'm trying to change the color of the default blue-gray border on my JTabbedPane. You can see the border circled in the image below. I want to make this a dark gray color. I've tried using the following UIManager properties (which result in the UI…
petehallw
  • 1,014
  • 6
  • 21
  • 49
4
votes
1 answer

Use mouse to scroll through tabs in JTabbedPane

I have a JTabbedPane in a scroll tab layout, so that all the tabs sit nicely on one row. Is there a way to allow the user to scroll through them with the mouse wheel, or is the only way to navigate the JTabbedPane.SCROLL_TAB_LAYOUT with the…
17slim
  • 1,233
  • 1
  • 16
  • 21
4
votes
1 answer

How to define action of a tab in Java when a button is clicked

I have a JButton called addAlbum and want it to start a tab when clicked. So I added: private void addAlbumButtonActionPerformed(java.awt.event.ActionEvent evt) { new AddAlbumPage().setVisible(true); JTabbedPane tabbedPane = new…
Nicky Mirfallah
  • 1,004
  • 4
  • 16
  • 38
4
votes
1 answer

Size issues with JTabbedPane and fixed height content

While writing this question I have been able to find a way to get it to behave the way I wanted. Based on this, I am still posting the question as other people might face similar issues. I have the following issues with the sizing of a JTabbedPane…
msch
  • 178
  • 2
  • 8
4
votes
3 answers

Override default look and feel Java

I want to override java look and feel. I just want to show the buttons differently. I want all the features of Windows Look and Feel but only buttons differently. I hope you get my point. Color color = new Color(220, 220, 220, 200); …
AZ_
  • 21,688
  • 25
  • 143
  • 191
4
votes
1 answer

Empty JTabbedPane

I'm having an issue creating an empty JTabbedPane where the only portion to be seen on the GUI are the row of tabs. Everytime I add a new tab with an "empty" component, the height of the JTabbedPane increases, but why? The current workaround is to…
splungebob
  • 5,357
  • 2
  • 22
  • 45
4
votes
3 answers

Force Horizontal Tab Text on Left Aligned JTabbedPane

I am trying to make a JTabbedPane in Java 7 on OSX that has tabs positioned to the left with their text horizontal (instead of vertical). However, with the code: import javax.swing.*; import java.awt.Dimension; class Probs extends JDialog { …
cryptopi
  • 303
  • 9
  • 19
4
votes
2 answers

Java JTabbedPane Inset Color

I was wondering how you would get the color of the inset of a JTabbedPane. I cannot seem to get this color. Every attempt I make I get 236,236,236 which is the outside frame color, where the inside frame color is about 10 darker, 227,227,227 (using…
dannyn382
  • 363
  • 2
  • 5
  • 15
4
votes
2 answers

Swing AncestorListener: Don't fire for tab switching?

I'm using the following code to let my component register/unregister event listeners when it's added/removed respectively. addAncestorListener(new AncestorListener() { @Override public void ancestorRemoved(AncestorEvent event) { …
Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301
4
votes
1 answer

Focusing a JTextArea in a JTabbedPane

I'm programming a chat client in Java, where I'd like to have one single JDialog for all open chats. So I decided to work with a JTabbedPane where a tab represents a single chat. I put a JPanel into every tab, which simply contains a JTextPane for…
Cosmo Jasra
  • 263
  • 2
  • 11
4
votes
4 answers

Java Swing - Knowing if tab has been removed/added in ChangeListener

Let's say I have JTabbedPane with a ChangeListener JTabbedPane tabbedPane = new JTabbedPane(); // Add few tabs ..... ..... tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { // How to…
Krishnaraj
  • 2,360
  • 1
  • 32
  • 55
4
votes
2 answers

Add a JLabel in the JTabbedPane header

I have this JDialog with a JTabbedPane: I just want to add a JLabel in the right-top area of the JTabbedPane so i can fire some events (e.g close the JDialog). And i don't want to make it a JFrame. PS: I know that is may be duplicated, but none of…
imanis_tn
  • 1,150
  • 1
  • 12
  • 33
4
votes
3 answers

JTabbedPane: show task progress in a tab

I have a simple Swing Java application that performs searches, and the results are shown in a new tab. While the search is running, I want to show a progress icon or animation in the title of the tab. I tried adding a gif icon, but it doesn't…
Paco
  • 468
  • 5
  • 10
3
votes
1 answer

Refresh tab name from result of getName()

I'm adding a custom component to a JTabbedPane. The title of the tab is determined by getName() in the component. Now at some point the result of getName() changes, but the tab title is not automatically refreshed (as can be expected). How can I…
Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301
3
votes
1 answer

How-to Prevent JTabbedPane with rows of tabs from reordering the rows when selected?

I have a Swing JTabbedPane with several rows of tabs, which show summary information from various parts of my application. I'd like to let the user double-click on any tab to display the full contents in a window, but the tab rows are moved around…
oldingn
  • 86
  • 4