Java Code Examples for javax.swing.JTabbedPane#getTabPlacement()

The following examples show how to use javax.swing.JTabbedPane#getTabPlacement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BoxTabbedPaneUI.java    From pumpernickel with MIT License 6 votes vote down vote up
protected GradientPaint createContentGradient(JComponent c,
		boolean isSelected) {
	JTabbedPane tabs = getTabbedPaneParent(c);
	int placement = tabs == null ? SwingConstants.TOP : tabs
			.getTabPlacement();
	Color outer = isSelected ? contentOuterSelected
			: contentOuterNormal;
	Color inner = isSelected ? contentInnerSelected
			: contentInnerNormal;
	if (placement == SwingConstants.LEFT) {
		return (new GradientPaint(0, 0, outer, c.getWidth(), 0, inner));
	} else if (placement == SwingConstants.RIGHT) {
		return (new GradientPaint(0, 0, inner, c.getWidth(), 0, outer));
	} else if (placement == SwingConstants.BOTTOM) {
		return (new GradientPaint(0, 0, inner, 0, c.getHeight(), outer));
	} else {
		return (new GradientPaint(0, 0, outer, 0, c.getHeight(), inner));
	}
}
 
Example 2
Source File: BoxTabbedPaneUI.java    From pumpernickel with MIT License 6 votes vote down vote up
@Override
public void formatControlRow(JTabbedPane tabs, JPanel tabsContainer) {

	Border border;
	Paint paint = createBorderGradient(tabs.getTabPlacement());
	if (tabs.getTabPlacement() == SwingConstants.BOTTOM) {
		border = new PartialLineBorder(paint, true, true,
				tabs.getTabCount() == 0, true);
	} else if (tabs.getTabPlacement() == SwingConstants.LEFT) {
		border = new PartialLineBorder(paint, true,
				tabs.getTabCount() == 0, true, true);
	} else if (tabs.getTabPlacement() == SwingConstants.RIGHT) {
		border = new PartialLineBorder(paint, true, true, true,
				tabs.getTabCount() == 0);
	} else {
		border = new PartialLineBorder(paint, tabs.getTabCount() == 0,
				true, true, true);
	}

	tabsContainer.setUI(new GradientPanelUI(createContentGradient(tabs,
			false)));
	tabsContainer.setBorder(border);
}
 
Example 3
Source File: BoxTabbedPaneUI.java    From pumpernickel with MIT License 6 votes vote down vote up
@Override
public void formatTabContent(JTabbedPane tabs, JComponent c) {
	if (contentBorder) {
		Border border;
		if (tabs.getTabPlacement() == SwingConstants.LEFT) {
			border = new PartialLineBorder(borderNormalDark, true,
					false, true, true);
		} else if (tabs.getTabPlacement() == SwingConstants.BOTTOM) {
			border = new PartialLineBorder(borderNormalDark, true,
					true, false, true);
		} else if (tabs.getTabPlacement() == SwingConstants.RIGHT) {
			border = new PartialLineBorder(borderNormalDark, true,
					true, true, false);
		} else {
			border = new PartialLineBorder(borderNormalDark, false,
					true, true, true);
		}
		c.setBorder(border);
	}
}
 
Example 4
Source File: TabOverviewButton.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Updates the location of <code>this</code> tab overview button.
 *
 * @param tabbedPane
 *            Tabbed pane.
 * @param tabAreaInsets
 *            Tab area insets.
 */
public void updateLocation(JTabbedPane tabbedPane, Insets tabAreaInsets) {
    if (tabbedPane == null)
        return;

    // Lock the button for the bounds change
    this.putClientProperty(TabOverviewButton.OWN_BOUNDS, Boolean.TRUE);
    int buttonSize = SubstanceSizeUtils.getLookupButtonSize();

    switch (tabbedPane.getTabPlacement()) {
    case SwingConstants.TOP:
        if (tabbedPane.getComponentOrientation().isLeftToRight())
            this.setBounds(2, tabAreaInsets.top, buttonSize, buttonSize);
        else
            this.setBounds(tabbedPane.getBounds().width - tabAreaInsets.right - buttonSize - 2,
                    tabAreaInsets.top, buttonSize, buttonSize);
        break;
    case SwingConstants.BOTTOM:
        if (tabbedPane.getComponentOrientation().isLeftToRight())
            this.setBounds(2,
                    tabbedPane.getBounds().height - tabAreaInsets.bottom - buttonSize - 4,
                    buttonSize, buttonSize);
        else
            this.setBounds(tabbedPane.getBounds().width - tabAreaInsets.right - buttonSize - 2,
                    tabbedPane.getBounds().height - tabAreaInsets.bottom - buttonSize - 4,
                    buttonSize, buttonSize);
        break;
    case SwingConstants.LEFT:
        this.setBounds(2, tabAreaInsets.top - 1, buttonSize, buttonSize);
        break;
    case SwingConstants.RIGHT:
        this.setBounds(tabbedPane.getBounds().width - tabAreaInsets.right - buttonSize - 2,
                tabAreaInsets.top - 1, buttonSize, buttonSize);
        break;
    }
    // Unlock the button for the bounds change
    this.putClientProperty(TabOverviewButton.OWN_BOUNDS, null);
}
 
Example 5
Source File: CloseTabPaneUI.java    From iBioSim with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
	JTabbedPane pane = (JTabbedPane) e.getSource();
	CloseTabPaneUI ui = (CloseTabPaneUI) pane.getUI();
	int tabPlacement = pane.getTabPlacement();
	if (tabPlacement == TOP || tabPlacement == BOTTOM) {
		ui.navigateSelectedTab(WEST);
	}
	else {
		ui.navigateSelectedTab(NORTH);
	}
}
 
Example 6
Source File: CloseTabPaneUI.java    From iBioSim with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
	JTabbedPane pane = (JTabbedPane) e.getSource();
	CloseTabPaneUI ui = (CloseTabPaneUI) pane.getUI();
	int tabPlacement = pane.getTabPlacement();
	if (tabPlacement == TOP || tabPlacement == BOTTOM) {
		ui.navigateSelectedTab(EAST);
	}
	else {
		ui.navigateSelectedTab(SOUTH);
	}
}
 
Example 7
Source File: TabbedPaneTabAreaPainter.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * @see com.seaglasslookandfeel.painter.AbstractRegionPainter#doPaint(java.awt.Graphics2D,
 *      javax.swing.JComponent, int, int, java.lang.Object[])
 */
protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object[] extendedCacheKeys) {
    JTabbedPane tabPane     = (JTabbedPane) c;
    int         orientation = tabPane.getTabPlacement();

    if (orientation == JTabbedPane.LEFT || orientation == JTabbedPane.RIGHT) {
        paintVerticalLine(g, c, 0, height / 2, width, height);
    } else {
        paintHorizontalLine(g, c, 0, height / 2, width, height);
    }
}