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

JTabbedPane - focus last focused component after tab change

When changing tabs, JTabbedPane always focuses the first focusable Component inside the tab. How can I change its behaviour so that it will either focus the last focused component or none at all? Invoking requestFocus afterwards is not an option…
Markus
  • 43
  • 1
  • 4
2
votes
1 answer

Java: How to refresh a JTabbedPane?

The program is supposed to refresh both tabbed panes every time a new choose drop down is selected. Unfortunatly, nothing is repainted/refreshed. I have already tried both repaint and revalidate in multiple areas of the code. Does anyone know what I…
Jayden
  • 71
  • 1
  • 6
2
votes
1 answer

How do I go about setting the exact style for tabs in a JTabbedPane?

I have looked around and I cannot figure out how to do it. Should I use the Synth look & feel? How would I go about doing this?
Dara Java
  • 2,410
  • 3
  • 27
  • 52
2
votes
1 answer

Reordering tabs in a JTabbedPane in java

Is there a way to swap two tabs? I have a touchscreen monitor with a java app with four tabs: Silkscreen Prep 1, Silkscreen Prep 2, Silkscreen 1, Silkscreen 2 and I want to swap Silkscreen Prep 2 and Silkscreen one so that a worker on the left side…
davidahines
  • 3,976
  • 16
  • 53
  • 87
2
votes
1 answer

Remove Unexpected border of JTabbedPane

I am trying to add tabs in a JTabbedPane. It is displaying the below mentioned white borderline which I am not expecting here as Every color is already set to Black except the white color for the text colors. What I might be missing. I am trying to…
Jamshaid
  • 370
  • 2
  • 11
  • 40
2
votes
1 answer

JTabbedPane: How to restrict user from moving out of current tab

How can I restrict the user from going away from the current tab. I need to show a confirmation message to save/discard changes before leaving the current tab. How can I implement this functionality in a JTabbedPane?
Khalid Amin
  • 872
  • 3
  • 12
  • 26
2
votes
1 answer

Tracking focus problem (JTabbedPane)

I'd like to track the focus for all components in my Java application. I registered a method which works for most of the components, but it does not work for changing tabs. Here's the…
Max
  • 79
  • 4
2
votes
1 answer

Scroll remaining tabs to visible after tab removal from a SCROLL_TAB_LAYOUT JTabbedPane

How does one scroll remaining tabs to visible after a single tab is removed from tail of a JTabbedPane with SCROLL_TAB_LAYOUT tab layout policy set. Default behavior seems to be to not do anything - user is forced to use scroll buttons to bring…
predi
  • 5,528
  • 32
  • 60
2
votes
2 answers

adding tabs in java (swing)

i was given a project to make a java program named doctors care which has login panel( username and password) and a panel which has 3 tabs. the problem is i could add only one tab and when i tried to add another tab by duplicating the objects( like…
code_buoy22
  • 43
  • 1
  • 1
  • 8
2
votes
0 answers

JTabbedPane "border bug" Windows LAF

I noticed something similar to a bug when using JTabbedPane in Windows Look And Feel (on Windows 10). The tabbed pane has a grey extra border on the right (2 pixels) and on the left (1 pixel). That border is not visible if the tabbed pane is inside…
Ansharja
  • 1,237
  • 1
  • 14
  • 37
2
votes
1 answer

java actionlistener on a tab

Is it possible to put an actionlistener on a tab in swing? If it is please could you post a small example?
Harry Martland
  • 604
  • 2
  • 14
  • 26
2
votes
0 answers

How do I make one component visible in more than one pane in a JTabbedPane?

I was wondering if there was a way to make one component (in this case a JPanel) visible in more than one of the tabs. I have a simple JFrame which is completely filled with a JTabbedPane. Each tab has a slightly different function, which is why…
Aragorn Crozier
  • 364
  • 2
  • 12
2
votes
0 answers

How can I use tabInsets when using getSystemLookAndFeelClassName()?

I need to set UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) to make the button size just around its name, but when I do this UIManager.put("TabbedPane.tabInsets", new Insets(2, 2, 2, 50)) has no longer effect, making the…
florin.iliescu
  • 302
  • 4
  • 10
2
votes
1 answer

Adding multiple real-time graphs from XChart onto a JPanel

I am in charge of creating a GUI in Java to monitor heart rates of multiple people over regions (modified for confidentiality reasons). There are a total of 8 regions, and each region contains 8 people. These are indicated by a JTabbedPane, 1 tab…
Yuki
  • 33
  • 2
  • 7
2
votes
1 answer

Java MVC Pattern on a JTabbedPane

I've been trying to follow an MVC pattern on my code and I was creating a system in which I have a JTabbedPane with Jbuttons inside the panel on my View, The content's info in the Model, and a the actionlisteners on my Controller. The problem I've…