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

JTabbedPanel change selected tab background color

I'm attempting to change the color of the border of a JTabbedPane based on the selected tab. Using answers here and on the web, I've managed this: import java.awt.*; import javax.swing.*; import javax.swing.event.ChangeEvent; import…
erics12357
  • 49
  • 1
  • 9
2
votes
1 answer

Putting multiple JPanels inside a JTabbed pane

I've looked around a while and also played around trying to add multiple panels to a JTabbedPane. My question is: Is it possible to add the same Jpanel to multiple TabbedPanes. Everything way that I tried, it doesn't seem to work correctly. This is…
jbolt
  • 688
  • 3
  • 16
  • 37
2
votes
3 answers

JPanels not added to JTabbedPane

For my homework extra credit I am creating a JTabbedPane and adding two Jpanels. I feel like I am very close, but it still does not compile. When I run it, both JPanels open, but the JTabbedPane does not. I get a lot of Unknown Source errors. I…
user2802785
  • 109
  • 1
  • 4
  • 11
2
votes
1 answer

JTabbedPane. Select tab on left mouse button click only

I want to set the most common JTabbedPane mouse event behavior, but I cannot find appropriate options to set: Left mouse button click - Select tab. Right mouse button click - Open current tab' dropdown menu. Wheel mouse button click - Close the…
SeniorJD
  • 6,946
  • 4
  • 36
  • 53
2
votes
2 answers

Fire stateChanged event on JTabbedPane

I have JTabbedPane with fade animation, which is performed when user clicks tabs. To handle animation I override stateChanged method. public class AnimatedJTabbedPane extends JTabbedPane implements ChangeListener, TimingTarget{ /** * */ private…
Demiurg
  • 347
  • 1
  • 4
  • 14
2
votes
2 answers

JTabbedPane tab component resize to fit

I want to make my tab labels share the JTabbedPane width. If there's one tab, fit whole width, if two tabs, share width, if three, 1/3 for each and so on... i don't even know if it's possible to do it without putting a component there and resizing…
2
votes
1 answer

Button size settled as mini

Based on http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/size.html with the purpose to create a button that fits one tab from JTabbedPane How to add close button to a JTabbedPane Tab? I built the code below. It should show a mini button…
Victor Oliveira
  • 3,293
  • 7
  • 47
  • 77
2
votes
2 answers

Open New Tab on Button Click in JAVA

I have One JFrame and two JPanels. Jframe contains JTabbedPane, MenuBar and one menuItem. When I click on the menuitem, a panel is added to the JTabbedPane. The code is this - private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt)…
Ajay Sainy
  • 279
  • 1
  • 9
  • 21
2
votes
1 answer

How to programmatically click a tab in JTabbedPane?

I am using a glasspane on the top of my application. However I want the JTabbedPane to be clickable. I know how to do it with JButton by adding a mouse listener on the glasspane and then use this method getDeepestComponentAt() from SwingUtilities.…
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434
2
votes
3 answers

Change JTabbedPane component on select tab

I've got a JTabbedPane and i need to substitute tab 1 component when user select it. I can't directly add the right component at application start because i don't have full data to generate it. I need something like this: int tabTochange = 1; …
Alvins
  • 867
  • 16
  • 27
2
votes
3 answers

Adding a JPanel to a JPanel

I have attached my code below, a screen shot of my program, and a drawing of what I want the tab to look like. I need my JPanel textPanel to appear below the JButtons on the tab LLP. I have tried to add textPanel to the tabsPanel but when I do that…
Kendra Cheatham
  • 117
  • 5
  • 16
2
votes
3 answers

When does a JTabbedPane component get its size?

I need to know the size of a JPanel when I add it to a JTabbedPane to compute other values. If I call the add(Component) method, when does the Component get its size? For example, JTabbedPane tabbedPane = new JTabbedPane(); JPanel panel = new…
joshreesjones
  • 1,934
  • 5
  • 24
  • 42
2
votes
1 answer

JTabbedPane FlowLayout throws ArrayIndexOutOfBoundsException

I'm trying to apply the flow layout to a JTabbedPane so that I can set the hgap(0) and vgap(0). The default layout for the JTabbedPane leaves gaps all around. The following code throws when I try to set the layout: import…
Brandon
  • 22,723
  • 11
  • 93
  • 186
2
votes
2 answers

How to disable CONTROL+PAGE_UP of a JTabbedPane?

How to disable the default behavior of CONTROL+PAGE_UP and CONTROL+PAGE_DOWN of a JTabbedPane?
user811773
2
votes
2 answers

Remove content padding on JTabbedPane in Substance LAF

I'm doing some experiments with Substance LAF and I'm trying to remove padding between tabs. With default ui I used: UIManager.getDefaults().put("TabbedPane.contentBorderInsets", new…
user629926
  • 1,910
  • 2
  • 18
  • 43