SWING / NOTES</>↗Swing19 Oct 2010
To remove tabs from JTabbedPane we can use the following remove methods: remove(int index) method to remove a tab at the specified index. remove(Component component) method to remove a tab that has the specified child component. removeAll() method to remove all tabs. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class TabbedPaneRemoveTab extends JPanel { public […]
SWING / NOTES</>↗Swing19 Oct 2010
To assign a keyboard shortcut for accessing JTabbedPane‘s tab you can use the setMnemonicAt(int tabIndex, int mnemonic) method of the JTabbedPane class. The tabIndex parameter is a zero-based value parameter which means that the first tab is at index number 0. For the mnenomic parameter you can use constants value defined in the java.awt.event.KeyEvent class. […]
SWING / NOTES</>↗Swing19 Oct 2010
To set a tool tips for JTabbedPane‘s tabs you need to pass the tool tips when adding a new tab to the JTabbedPane. The addTab() method accept the following parameters: the tab’s title, image icon, a component that is going to be the content of the tabs and a string of tool tips information. When […]
SWING / NOTES</>↗Swing18 Oct 2010
To enable or disable tabs in JTabbedPane you can use the JTabbedPane‘s setEnableAt(int index, boolean enable) method. The index is zero based, this means that the first tab is at index number 0. The enable parameter when set to true will enable the tab while setting to false will disable the tab. package org.kodejava.swing; import […]
SWING / NOTES</>↗Swing18 Oct 2010
The example below demonstrates how to change the color of the tabs in JTabbedPane component. The JTabbedPane‘s methods that you can use the change foreground and background color are: setForeground(Color color) for changing the foreground color of all tabs. setBackground(Color color) for changing the background color of all tabs. setForegroundAt(int index, Color color) for changing […]
SWING / NOTES</>↗Swing18 Oct 2010
When adding a tabs to JTabbedPane you can define the icon for the tabs. This icon will be displayed beside the tab’s title in enable or disable state of the tabs. To make the user interface better you can also define a disabled icon for the tab. This icon will be displayed when the state […]