Java Utililty Methods JTabbedPane

List of utility methods to do JTabbedPane

Description

The list of methods to do JTabbedPane are organized into topic(s).

Method

intgetOffsetOfVirtualColumn(Segment seg, int tabSize, int column, int[] totalVirtualWidth)
Returns the array offset of a virtual column number (taking tabs into account) in the segment.
int virtualPosition = 0;
for (int i = 0; i < seg.count; i++) {
    char ch = seg.array[seg.offset + i];
    if (ch == '\t') {
        int tabWidth = tabSize - virtualPosition % tabSize;
        if (virtualPosition >= column)
            return i;
        else
...
SimpleAttributeSetgetParagraphStyle(SimpleAttributeSet attrSet, int align, float firstLineIndent, float leftIndent, float rightIndent, float lineSpace, float spaceAbove, float spaceBelow, TabSet tabs)
get Paragraph Style
if (attrSet == null) {
    attrSet = new SimpleAttributeSet();
if (align >= 0)
    StyleConstants.setAlignment(attrSet, align);
if (firstLineIndent >= 0)
    StyleConstants.setFirstLineIndent(attrSet, firstLineIndent);
if (leftIndent >= 0)
...
intgetTabbedPaneComponentIndex(JTabbedPane tabbedPane, String title)
get Tabbed Pane Component Index
int index = -Integer.MAX_VALUE;
int count = tabbedPane.getTabCount();
for (int i = 0; i < count; i++) {
    if (tabbedPane.getTitleAt(i).toString().equalsIgnoreCase(title)) {
        index = i;
        break;
return index;
JTabbedPanegetTabbedPaneFor(Component c)
Get the tabbed pane for a component
if (c == null) {
    return null;
if (c instanceof JTabbedPane) {
    return (JTabbedPane) c;
return getTabbedPaneFor(c.getParent());
intgetTabComponentIndex(JTabbedPane tbp, Component component)
Returns index of a tab's component inside tabbed pane
int count = tbp.getTabCount();
for (int i = 0; i < count; i++) {
    if (component == tbp.getComponentAt(i)) {
        return i;
throw new IllegalArgumentException("No component found in the tabbed pane");
intgetTabIndex(final JTabbedPane tabs, final String title)
get Tab Index
for (int i = 0; i < tabs.getTabCount(); i++) {
    if (tabs.getTitleAt(i).equals(title)) {
        return i;
return -1;
intgetTabIndexAt(JTabbedPane tabbedPane, int x, int y)
get Tab Index At
TabbedPaneUI tabbedPaneUI = tabbedPane.getUI();
for (int k = 0; k < tabbedPane.getTabCount(); k++) {
    java.awt.Rectangle rectangle = tabbedPaneUI.getTabBounds(tabbedPane, k);
    if (rectangle.contains(x, y))
        return k;
return -1;
intgetTabPaneLeadingPlacement()
Gets the tab pane leading placement.
return isLeftOrientation() ? JTabbedPane.LEFT : JTabbedPane.RIGHT;
intgetTabsHeight()
get Tabs Height
return new JLabel("XXX").getPreferredSize().height + 2 + TAB_VERTICAL_PADDING * 2 + TABS_BORDER * 2;
intgetVirtualWidth(Segment seg, int tabSize)
Returns the virtual column number (taking tabs into account) of the specified offset in the segment.
int virtualPosition = 0;
for (int i = 0; i < seg.count; i++) {
    char ch = seg.array[seg.offset + i];
    if (ch == '\t') {
        virtualPosition += tabSize - virtualPosition % tabSize;
    } else {
        ++virtualPosition;
return virtualPosition;