Browse Source

Removed preview features. Moved indicator for LEFT,RIGHT,BOTTOM position to appropriate location.

pull/1/head
weisj 5 years ago
parent
commit
06701ae3cb
  1. 222
      src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java
  2. 269
      src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java
  3. 37
      src/main/java/com/weis/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java

222
src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java

@ -3,7 +3,6 @@ package com.weis.darklaf.ui.tabbedpane;
import com.weis.darklaf.components.ScrollPopupMenu;
import com.weis.darklaf.decorators.PopupMenuAdapter;
import com.weis.darklaf.icons.EmptyIcon;
import com.weis.darklaf.icons.IconLoader;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import com.weis.darklaf.util.GraphicsUtil;
@ -31,6 +30,8 @@ import java.util.function.Function;
public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
private static final int FOCUS_SIZE = 4;
private static final TabbedPaneTransferHandler TRANSFER_HANDLER = new TabbedPaneTransferHandler();
private final FocusListener focusListener = new FocusListener() {
@Override
@ -81,10 +82,18 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
final boolean isSelected) {
g.setColor(getTabBorderColor());
switch (tabPlacement) {
case TOP -> g.fillRect(x, y + h - 1, w, 1);
case BOTTOM -> g.fillRect(x, y, w, 1);
case LEFT -> g.fillRect(x + w - 1, y, 1, h);
case RIGHT -> g.fillRect(x, y, 1, h);
case TOP:
g.fillRect(x, y + h - 1, w, 1);
break;
case BOTTOM:
g.fillRect(x, y, w, 1);
break;
case LEFT:
g.fillRect(x + w - 1, y, 1, h);
break;
case RIGHT:
g.fillRect(x, y, 1, h);
break;
}
}
@ -104,10 +113,18 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
int y = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
int x = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
switch (tabPlacement) {
case TOP -> paintTabAreaBorder(g, tabPlacement, 0, 0, width, y);
case BOTTOM -> paintTabAreaBorder(g, tabPlacement, 0, height - y, width, y + 1);
case LEFT -> paintTabAreaBorder(g, tabPlacement, 0, 0, x, height);
case RIGHT -> paintTabAreaBorder(g, tabPlacement, width - x, 0, x, height);
case TOP:
paintTabAreaBorder(g, tabPlacement, 0, 0, width, y);
break;
case BOTTOM:
paintTabAreaBorder(g, tabPlacement, 0, height - y, width, y + 1);
break;
case LEFT:
paintTabAreaBorder(g, tabPlacement, 0, 0, x, height);
break;
case RIGHT:
paintTabAreaBorder(g, tabPlacement, width - x, 0, x, height);
break;
}
// If scrollable tabs are enabled, the tab area will be
@ -131,10 +148,18 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
((Graphics2D) g).setComposite(DarkUIUtil.ALPHA_COMPOSITE_2);
}
switch (tabPane.getTabPlacement()) {
case TOP -> g.fillRect(dropRect.x, dropRect.y, dropRect.width, dropRect.height - 1);
case BOTTOM -> g.fillRect(dropRect.x, dropRect.y + 1, dropRect.width, dropRect.height - 1);
case LEFT -> g.fillRect(dropRect.x, dropRect.y, dropRect.width - 1, dropRect.height);
case RIGHT -> g.fillRect(dropRect.x + 1, dropRect.y, dropRect.width - 1, dropRect.height);
case TOP:
g.fillRect(dropRect.x, dropRect.y, dropRect.width, dropRect.height - 1);
break;
case BOTTOM:
g.fillRect(dropRect.x, dropRect.y + 1, dropRect.width, dropRect.height - 1);
break;
case LEFT:
g.fillRect(dropRect.x, dropRect.y, dropRect.width - 1, dropRect.height);
break;
case RIGHT:
g.fillRect(dropRect.x + 1, dropRect.y, dropRect.width - 1, dropRect.height);
break;
}
context.restore();
}
@ -143,10 +168,18 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
final int x, final int y, final int w, final int h) {
g.setColor(getTabBorderColor());
switch (tabPlacement) {
case TOP -> g.fillRect(x, y + h - 1, w, 1);
case BOTTOM -> g.fillRect(x, y, w, 1);
case LEFT -> g.fillRect(w - 1, y, 1, h);
case RIGHT -> g.fillRect(x, y, 1, h);
case TOP:
g.fillRect(x, y + h - 1, w, 1);
break;
case BOTTOM:
g.fillRect(x, y, w, 1);
break;
case LEFT:
g.fillRect(w - 1, y, 1, h);
break;
case RIGHT:
g.fillRect(x, y, 1, h);
break;
}
}
@ -200,9 +233,18 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
g.setColor(getAccentColor(DarkUIUtil.hasFocus(tabPane)));
var r = rects[tabIndex];
switch (tabPlacement) {
case LEFT -> g.fillRect(r.x, r.y + r.height - 4, r.width - 1, 4);
case RIGHT -> g.fillRect(r.x + 1, r.y + r.height - 4, r.width - 1, 4);
default -> g.fillRect(r.x, r.y + r.height - 4, r.width, 4);
case LEFT:
g.fillRect(r.x + r.width - FOCUS_SIZE - 1, r.y, FOCUS_SIZE, r.height);
break;
case RIGHT:
g.fillRect(r.x + 1, r.y, FOCUS_SIZE, r.height);
break;
case BOTTOM:
g.fillRect(r.x, r.y + 1, r.width, FOCUS_SIZE);
break;
default:
g.fillRect(r.x, r.y + r.height - FOCUS_SIZE, r.width, FOCUS_SIZE);
break;
}
}
}
@ -410,21 +452,19 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
var rect = super.getTabBounds(pane, i);
if (scrollableTabLayoutEnabled() && rect != null
&& dropTargetIndex >= 0 && i == dropTargetIndex) {
switch (pane.getTabPlacement()) {
case TOP, BOTTOM -> {
int tabPlacement = pane.getTabPlacement();
if (tabPlacement == TOP || tabPlacement == BOTTOM) {
if (pane.getComponentOrientation().isLeftToRight()) {
rect.x -= dropRect.width;
rect.width += dropRect.width;
} else {
rect.width += dropRect.width;
}
}
case LEFT, RIGHT -> {
} else if (tabPlacement == LEFT || tabPlacement == RIGHT) {
rect.y -= dropRect.height;
rect.height += dropRect.height;
}
}
}
return rect;
}
@ -545,10 +585,15 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
}
}
private Icon getNewTabIcon() {
protected Icon getNewTabIcon() {
return UIManager.getIcon("TabbedPane.newTab.icon");
}
protected Icon getMoreTabsIcon() {
return UIManager.getIcon("TabbedPane.moreTabs.icon");
}
protected class MoreTabsButton extends DarkTabAreaButton {
private final Icon icon;
@ -556,7 +601,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
private final static int PAD = 2;
protected MoreTabsButton() {
icon = IconLoader.get().getUIAwareIcon("navigation/moreTabs.svg");
icon = getMoreTabsIcon();
setIcon(EmptyIcon.create(icon.getIconWidth(), icon.getIconHeight()));
putClientProperty("JButton.variant", "onlyLabel");
putClientProperty("JButton.buttonType", "square");
@ -578,11 +623,11 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
* A different icon might need a different offset.
*/
int off = 5;
switch (tabPane.getTabPlacement()) {
case TOP -> y += 2;
case BOTTOM -> y -= 1;
default -> {
}
int tabPlacement = tabPane.getTabPlacement();
if (tabPlacement == TOP) {
y += 2;
} else if (tabPlacement == BOTTOM) {
y -= 1;
}
icon.paintIcon(this, g, x, y);
@ -662,26 +707,30 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
var pref = scrollPopupMenu.getPreferredSize();
boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight();
switch (tabPane.getTabPlacement()) {
case LEFT -> scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth(),
case LEFT:
scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth(),
moreTabsButton.getHeight() - pref.height);
case RIGHT -> scrollPopupMenu.show(moreTabsButton, -pref.width,
break;
case RIGHT:
scrollPopupMenu.show(moreTabsButton, -pref.width,
moreTabsButton.getHeight() - pref.height);
case TOP -> {
break;
case TOP:
if (leftToRight) {
scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth() - pref.width,
moreTabsButton.getHeight());
} else {
scrollPopupMenu.show(moreTabsButton, 0, moreTabsButton.getHeight());
}
}
case BOTTOM -> {
break;
case BOTTOM:
if (leftToRight) {
scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth() - pref.width,
-pref.height);
} else {
scrollPopupMenu.show(moreTabsButton, 0, -pref.height);
}
}
break;
}
}
}
@ -866,8 +915,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
// Calculate how much space the tabs will need, based on the
// minimum size required to display largest child + content border
//
switch (tabPlacement) {
case LEFT, RIGHT -> {
if (tabPlacement == LEFT || tabPlacement == RIGHT) {
int tabHeight = calculateTabHeight(tabPlacement, tabPane.getSelectedIndex(),
getFontMetrics().getHeight());
if (scrollableTabSupport.moreTabsButton.isVisible()) {
@ -877,8 +925,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
tabExtent = preferredTabAreaWidth(tabPlacement,
height - tabAreaInsets.top - tabAreaInsets.bottom);
width += tabExtent;
}
default -> {
} else {
int tabWidth = calculateTabWidth(tabPlacement, tabPane.getSelectedIndex(), getFontMetrics());
if (scrollableTabSupport.moreTabsButton.isVisible()) {
tabWidth += scrollableTabSupport.moreTabsButton.getPreferredSize().width;
@ -887,7 +934,6 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
tabExtent = preferredTabAreaHeight(tabPlacement, width - tabAreaInsets.left - tabAreaInsets.right);
height += tabExtent;
}
}
return new Dimension(width + insets.left + insets.right + contentInsets.left + contentInsets.right,
height + insets.bottom + insets.top + contentInsets.top + contentInsets.bottom);
@ -902,9 +948,10 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
boolean verticalTabRuns = !isHorizontalTabPlacement();
boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight();
switch (tabPlacement) {
case LEFT, RIGHT -> maxTabWidth = calculateMaxTabWidth(tabPlacement);
default -> maxTabHeight = calculateMaxTabHeight(tabPlacement);
if (tabPlacement == LEFT || tabPlacement == RIGHT) {
maxTabWidth = calculateMaxTabWidth(tabPlacement);
} else {
maxTabHeight = calculateMaxTabHeight(tabPlacement);
}
runCount = 0;
@ -1347,59 +1394,51 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
if (numChildren > 0) {
switch (tabPlacement) {
case LEFT -> {
case LEFT:
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
th = bounds.height - insets.top - insets.bottom - tabAreaInsets.top - tabAreaInsets.bottom;
tx = insets.left + tabAreaInsets.left;
ty = insets.top + tabAreaInsets.top;
cx = insets.left + tw + contentInsets.left + tabAreaInsets.left + tabAreaInsets.right;
cy = insets.top + contentInsets.top;
cw = bounds.width - insets.left - insets.right - tw - contentInsets.left - contentInsets.right
- tabAreaInsets.left - tabAreaInsets.right;
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom;
tw -= tabAreaInsets.left + tabAreaInsets.right;
}
case RIGHT -> {
break;
case RIGHT:
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
th = bounds.height - insets.top - insets.bottom - tabAreaInsets.top - tabAreaInsets.bottom;
tx = bounds.width - insets.right - tw + tabAreaInsets.left;
ty = insets.top + tabAreaInsets.top;
cx = insets.left + contentInsets.left;
cy = insets.top + contentInsets.top;
cw = bounds.width - insets.left - insets.right - tw - contentInsets.left - contentInsets.right;
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom;
tw -= tabAreaInsets.left + tabAreaInsets.right;
}
case BOTTOM -> {
break;
case BOTTOM:
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right;
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
tx = insets.left + tabAreaInsets.left;
ty = bounds.height - insets.bottom - th + tabAreaInsets.top;
cx = insets.left + contentInsets.left;
cy = insets.top + contentInsets.top;
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right;
ch = bounds.height - insets.top - insets.bottom - th - contentInsets.top - contentInsets.bottom;
th -= tabAreaInsets.top + tabAreaInsets.bottom;
}
default -> {
break;
default:
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right;
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
tx = insets.left + tabAreaInsets.left;
ty = insets.top + tabAreaInsets.top;
cx = insets.left + contentInsets.left;
cy = insets.top + th + contentInsets.top;
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right;
ch = bounds.height - insets.top - insets.bottom - th - contentInsets.top - contentInsets.bottom;
th -= tabAreaInsets.top + tabAreaInsets.bottom;
}
break;
}
JButton moreTabs = scrollableTabSupport.moreTabsButton;
JComponent newTab = scrollableTabSupport.newTabButton;
@ -1418,15 +1457,13 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
? newTab.getPreferredSize()
: new Dimension(0, 0);
boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight();
switch (tabPlacement) {
case LEFT, RIGHT -> {
if (tabPlacement == LEFT || tabPlacement == RIGHT) {
vh = th - butSize.height - butSize2.height;
moreTabs.setBounds(tx, ty + vh + butSize2.height, maxTabWidth, butSize.height);
if (showNewTabButton) {
newTab.setBounds(tx, ty + vh, maxTabWidth, butSize2.height);
}
}
default -> {
} else {
if (leftToRight) {
vw = tw - butSize.width - butSize2.width;
moreTabs.setBounds(tx + vw + butSize2.width, ty, butSize.width, maxTabHeight);
@ -1442,7 +1479,6 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
tx += butSize.width + butSize2.width;
}
}
}
child.setBounds(tx, ty, vw, vh);
} else {
int tabHeight = maxTabHeight + tabAreaInsets.top + tabAreaInsets.bottom;
@ -1515,53 +1551,49 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
if (numChildren > 0) {
switch (tabPlacement) {
case LEFT -> {
case LEFT:
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
tx = insets.left + tabAreaInsets.left;
ty = insets.top + tabAreaInsets.top;
th = bounds.height - insets.top - tabAreaInsets.top - insets.bottom - tabAreaInsets.bottom;
cx = insets.left + tw + contentInsets.left + tabAreaInsets.left + tabAreaInsets.right;
cy = insets.top + contentInsets.top;
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right - tw
- tabAreaInsets.left - tabAreaInsets.right;
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom;
}
case RIGHT -> {
break;
case RIGHT:
tw = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
tx = bounds.width - insets.left - tw - tabAreaInsets.right - tabAreaInsets.left;
ty = insets.top + tabAreaInsets.top;
th = bounds.height - insets.top - tabAreaInsets.top - insets.bottom - tabAreaInsets.bottom;
cx = insets.left + contentInsets.left;
cy = insets.top + contentInsets.top;
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right - tw
- tabAreaInsets.left - tabAreaInsets.right;
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom;
}
case BOTTOM -> {
break;
case BOTTOM:
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
ty = bounds.height - insets.bottom - th;
tx = insets.left + tabAreaInsets.left;
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right;
cx = insets.left + contentInsets.left;
cy = insets.top + contentInsets.top;
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right;
ch = bounds.height - th - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom;
}
default -> {
break;
default:
ty = insets.top + tabAreaInsets.top;
tx = insets.left + tabAreaInsets.left;
tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right;
th = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
cx = insets.left + contentInsets.left;
cy = insets.top + th + contentInsets.top + tabAreaInsets.top + tabAreaInsets.bottom;
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right;
ch = bounds.height - th - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom
- tabAreaInsets.top - tabAreaInsets.bottom;
}
break;
}
tabAreaBounds.setRect(tx, ty, tw, th);
@ -1599,12 +1631,20 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
int centerY = (tabHeight - h) / 2;
int centerX = (tabWidth - w) / 2;
switch (tabPlacement) {
case LEFT -> comp.setBounds(insets.left + centerX, ty - b.height, w, b.height);
case RIGHT -> comp.setBounds(tx - tabAreaInsets.left + centerX, ty - b.height,
case LEFT:
comp.setBounds(insets.left + centerX, ty - b.height, w, b.height);
break;
case RIGHT:
comp.setBounds(tx - tabAreaInsets.left + centerX, ty - b.height,
w, b.height);
case TOP -> comp.setBounds(tx - b.width, insets.top + centerY, b.width, h);
case BOTTOM -> comp.setBounds(tx - b.width, ty - tabAreaInsets.bottom + centerY,
break;
case TOP:
comp.setBounds(tx - b.width, insets.top + centerY, b.width, h);
break;
case BOTTOM:
comp.setBounds(tx - b.width, ty - tabAreaInsets.bottom + centerY,
b.width, h);
break;
}
}
@ -1617,12 +1657,20 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
int centerY = (tabHeight - h) / 2;
int centerX = (tabWidth - w) / 2;
switch (tabPlacement) {
case LEFT -> comp.setBounds(insets.left + centerX, ty + th, w, b.height);
case RIGHT -> comp.setBounds(tx - tabAreaInsets.left + centerX, ty + th,
case LEFT:
comp.setBounds(insets.left + centerX, ty + th, w, b.height);
break;
case RIGHT:
comp.setBounds(tx - tabAreaInsets.left + centerX, ty + th,
w, b.height);
case TOP -> comp.setBounds(tx + tw, insets.top + centerY, b.width, h);
case BOTTOM -> comp.setBounds(tx + tw, ty - tabAreaInsets.bottom + centerY,
break;
case TOP:
comp.setBounds(tx + tw, insets.top + centerY, b.width, h);
break;
case BOTTOM:
comp.setBounds(tx + tw, ty - tabAreaInsets.bottom + centerY,
b.width, h);
break;
}
}

269
src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java

@ -25,6 +25,7 @@ import java.awt.event.ContainerListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
@ -48,33 +49,57 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
// Instance variables initialized at installation
/** The tab pane */
/**
* The tab pane
*/
protected JTabbedPane tabPane;
/** Highlight color */
/**
* Highlight color
*/
protected Color highlight;
/** Light highlight color */
/**
* Light highlight color
*/
protected Color lightHighlight;
/** Shadow color */
/**
* Shadow color
*/
protected Color shadow;
/** Dark shadow color */
/**
* Dark shadow color
*/
protected Color darkShadow;
/** Focus color */
/**
* Focus color
*/
protected Color focus;
protected Color selectedColor;
/** Text icon gap */
/**
* Text icon gap
*/
protected int textIconGap;
/** Tab run overlay */
/**
* Tab run overlay
*/
protected int tabRunOverlay;
/** Tab insets */
/**
* Tab insets
*/
protected Insets tabInsets;
/** Selected tab insets */
/**
* Selected tab insets
*/
protected Insets selectedTabPadInsets;
/** Tab area insets */
/**
* Tab area insets
*/
protected Insets tabAreaInsets;
/** Content border insets */
/**
* Content border insets
*/
protected Insets contentBorderInsets;
protected boolean tabsOverlapBorder;
protected boolean tabsOpaque = true;
@ -123,28 +148,48 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
// Transient variables (recalculated each time TabbedPane is layed out)
/** Tab runs */
/**
* Tab runs
*/
protected int[] tabRuns = new int[10];
/** Run count */
/**
* Run count
*/
protected int runCount = 0;
/** Selected run */
/**
* Selected run
*/
protected int selectedRun = -1;
/** Tab rects */
/**
* Tab rects
*/
protected Rectangle[] rects = new Rectangle[0];
/** Maximum tab height */
/**
* Maximum tab height
*/
protected int maxTabHeight;
/** Maximum tab width */
/**
* Maximum tab width
*/
protected int maxTabWidth;
// Listeners
/** Tab change listener */
/**
* Tab change listener
*/
protected ChangeListener tabChangeListener;
/** Property change listener */
/**
* Property change listener
*/
protected PropertyChangeListener propertyChangeListener;
/** Mouse change listener */
/**
* Mouse change listener
*/
protected MouseListener mouseListener;
/** Focus change listener */
/**
* Focus change listener
*/
protected FocusListener focusListener;
// Private instance data
@ -204,6 +249,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Create a UI.
*
* @param c a component
* @return a UI
*/
@ -259,7 +305,6 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
* the <code>JTabbedPane</code>.
*
* @return a layout manager object
*
* @see TabbedPaneLayout
* @see javax.swing.JTabbedPane#getTabLayoutPolicy
*/
@ -324,10 +369,10 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
* @param direction One of the SwingConstants constants:
* SOUTH, NORTH, EAST or WEST
* @return Widget for user to
* @see javax.swing.JTabbedPane#setTabPlacement
* @see javax.swing.SwingConstants
* @throws IllegalArgumentException if direction is not one of
* NORTH, SOUTH, EAST or WEST
* @see javax.swing.JTabbedPane#setTabPlacement
* @see javax.swing.SwingConstants
* @since 1.5
*/
protected JButton createScrollButton(int direction) {
@ -479,6 +524,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Creates a mouse listener.
*
* @return a mouse listener
*/
protected MouseListener createMouseListener() {
@ -487,6 +533,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Creates a focus listener.
*
* @return a focus listener
*/
protected FocusListener createFocusListener() {
@ -495,6 +542,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Creates a change listener.
*
* @return a change listener
*/
protected ChangeListener createChangeListener() {
@ -503,6 +551,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Creates a property change listener.
*
* @return a property change listener
*/
protected PropertyChangeListener createPropertyChangeListener() {
@ -538,8 +587,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
return (InputMap) DefaultLookup.get(tabPane, this,
"TabbedPane.ancestorInputMap");
}
else if (condition == JComponent.WHEN_FOCUSED) {
} else if (condition == JComponent.WHEN_FOCUSED) {
return (InputMap) DefaultLookup.get(tabPane, this,
"TabbedPane.focusInputMap");
}
@ -598,9 +646,8 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
}
mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, DarkUIUtil.getFocusAcceleratorKeyMask()),
"setSelectedIndex");
mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic,
SwingUtilities2.setAltGraphMask(
DarkUIUtil.getFocusAcceleratorKeyMask())),
mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, InputEvent.ALT_GRAPH_DOWN_MASK
| DarkUIUtil.getFocusAcceleratorKeyMask()),
"setSelectedIndex");
mnemonicToIndexMap.put(Integer.valueOf(mnemonic), Integer.valueOf(index));
}
@ -723,10 +770,10 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
* Returns the baseline for the specified tab.
*
* @param tab index of tab to get baseline for
* @exception IndexOutOfBoundsException if index is out of range
* (index &lt; 0 || index &gt;= tab count)
* @return baseline or a value &lt; 0 indicating there is no reasonable
* baseline
* @throws IndexOutOfBoundsException if index is out of range
* (index &lt; 0 || index &gt;= tab count)
* @since 1.6
*/
protected int getBaseline(int tab) {
@ -744,8 +791,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
int cellHeight = maxTabHeight - tabInsets.top - tabInsets.bottom;
return c.getBaseline(pref.width, pref.height) +
(cellHeight - pref.height) / 2 + tabInsets.top;
}
else {
} else {
View view = getTextViewForTab(tab);
if (view != null) {
int viewHeight = (int) view.getPreferredSpan(View.Y_AXIS);
@ -777,15 +823,13 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
case JTabbedPane.TOP:
if (tabPane.getTabCount() > 1) {
return 1;
}
else {
} else {
return -1;
}
case JTabbedPane.BOTTOM:
if (tabPane.getTabCount() > 1) {
return -1;
}
else {
} else {
return 1;
}
default: // RIGHT|LEFT
@ -816,8 +860,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
break;
}
}
}
else {
} else {
// left/right, tabs may be different sizes.
FontMetrics fontMetrics = getFontMetrics();
int fontHeight = fontMetrics.getHeight();
@ -870,7 +913,6 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
* @param g the graphics object to use for rendering
* @param tabPlacement the placement for the tabs within the JTabbedPane
* @param selectedIndex the tab index of the selected component
*
* @since 1.4
*/
protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex) {
@ -901,6 +943,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Paints a tab.
*
* @param g the graphics
* @param tabPlacement the tab placement
* @param rects rectangles
@ -1078,6 +1121,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Laysout a label.
*
* @param tabPlacement the tab placement
* @param metrics the font metric
* @param tabIndex the tab index
@ -1123,6 +1167,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Paints an icon.
*
* @param g the graphics
* @param tabPlacement the tab placement
* @param tabIndex the tab index
@ -1144,6 +1189,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Paints text.
*
* @param g the graphics
* @param tabPlacement the tab placement
* @param font the font
@ -1198,6 +1244,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the tab label shift x.
*
* @param tabPlacement the tab placement
* @param tabIndex the tab index
* @param isSelected selection status
@ -1223,6 +1270,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the tab label shift y.
*
* @param tabPlacement the tab placement
* @param tabIndex the tab index
* @param isSelected selection status
@ -1247,6 +1295,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Paints the focus indicator.
*
* @param g the graphics
* @param tabPlacement the tab placement
* @param rects rectangles
@ -1370,6 +1419,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Paints the tab background.
*
* @param g the graphics context in which to paint
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param tabIndex the index of the tab with respect to other tabs
@ -1404,6 +1454,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Paints the content border.
*
* @param g the graphics context in which to paint
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param selectedIndex the tab index of the selected component
@ -1453,11 +1504,9 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
Color color = UIManager.getColor("TabbedPane.contentAreaColor");
if (color != null) {
g.setColor(color);
}
else if ( selectedColor == null || selectedIndex == -1 ) {
} else if (selectedColor == null || selectedIndex == -1) {
g.setColor(tabPane.getBackground());
}
else {
} else {
g.setColor(selectedColor);
}
g.fillRect(x, y, w, h);
@ -1472,6 +1521,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Paints the content border top edge.
*
* @param g the graphics context in which to paint
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param selectedIndex the tab index of the selected component
@ -1511,6 +1561,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Paints the content border left edge.
*
* @param g the graphics context in which to paint
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param selectedIndex the tab index of the selected component
@ -1547,6 +1598,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Paints the content border bottom edge.
*
* @param g the graphics context in which to paint
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param selectedIndex the tab index of the selected component
@ -1590,6 +1642,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Paints the content border right edge.
*
* @param g the graphics context in which to paint
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param selectedIndex the tab index of the selected component
@ -1718,7 +1771,6 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
* @param tabIndex the index of the tab
* @param dest the rectangle where the result should be placed
* @return the resulting rectangle
*
* @since 1.4
*/
protected Rectangle getTabBounds(int tabIndex, Rectangle dest) {
@ -1760,8 +1812,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
if (useX) {
minLoc = rects[current].x;
maxLoc = minLoc + rects[current].width;
}
else {
} else {
minLoc = rects[current].y;
maxLoc = minLoc + rects[current].height;
}
@ -1770,14 +1821,12 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
if (min == max) {
return Math.max(0, current - 1);
}
}
else if (want >= maxLoc) {
} else if (want >= maxLoc) {
min = current;
if (max - min <= 1) {
return Math.max(current + 1, tabCount - 1);
}
}
else {
} else {
return current;
}
}
@ -1801,6 +1850,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the visible component.
*
* @return the visible component
*/
protected Component getVisibleComponent() {
@ -1809,6 +1859,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Sets the visible component.
*
* @param component the component
*/
protected void setVisibleComponent(Component component) {
@ -1827,6 +1878,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Assure the rectangles are created.
*
* @param tabCount the tab count
*/
protected void assureRectsCreated(int tabCount) {
@ -1855,6 +1907,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the run for a tab.
*
* @param tabCount the tab count
* @param tabIndex the tab index.
* @return the run for a tab
@ -1872,6 +1925,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the last tab in a run.
*
* @param tabCount the tab count
* @param run the run
* @return the last tab in a run
@ -1889,6 +1943,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the tab run overlay.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @return the tab run overlay
*/
@ -1898,6 +1953,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the tab run indent.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param run the tab run
* @return the tab run indent
@ -1908,6 +1964,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns whether or not the tab run should be padded.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param run the tab run
* @return whether or not the tab run should be padded
@ -1918,6 +1975,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns whether or not the tab run should be rotated.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @return whether or not the tab run should be rotated
*/
@ -1927,6 +1985,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the icon for a tab.
*
* @param tabIndex the index of the tab
* @return the icon for a tab
*/
@ -1943,7 +2002,6 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
* @param tabIndex the index of the tab
* @return the text view to render the tab's text or null if no
* specialized rendering is required
*
* @since 1.4
*/
protected View getTextViewForTab(int tabIndex) {
@ -1955,6 +2013,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Calculates the tab height.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param tabIndex the index of the tab with respect to other tabs
* @param fontHeight the font height
@ -1987,6 +2046,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Calculates the maximum tab height.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @return the maximum tab height
*/
@ -2003,6 +2063,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Calculates the tab width.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param tabIndex the index of the tab with respect to other tabs
* @param metrics the font metrics
@ -2034,6 +2095,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Calculates the maximum tab width.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @return the maximum tab width
*/
@ -2049,6 +2111,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Calculates the tab area height.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param horizRunCount horizontal run count
* @param maxTabHeight maximum tab height
@ -2065,6 +2128,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Calculates the tab area width.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param vertRunCount vertical run count
* @param maxTabWidth maximum tab width
@ -2081,6 +2145,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the tab insets.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param tabIndex the tab index
* @return the tab insets
@ -2091,6 +2156,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the selected tab pad insets.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @return the selected tab pad insets
*/
@ -2101,6 +2167,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the tab area insets.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @return the pad area insets
*/
@ -2111,6 +2178,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the content border insets.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @return the content border insets
*/
@ -2120,6 +2188,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the font metrics.
*
* @return the font metrics
*/
protected FontMetrics getFontMetrics() {
@ -2132,6 +2201,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Navigate the selected tab.
*
* @param direction the direction
*/
protected void navigateSelectedTab(int direction) {
@ -2214,6 +2284,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Select the next tab in the run.
*
* @param current the current tab
*/
protected void selectNextTabInRun(int current) {
@ -2228,6 +2299,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Select the previous tab in the run.
*
* @param current the current tab
*/
protected void selectPreviousTabInRun(int current) {
@ -2242,6 +2314,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Select the next tab.
*
* @param current the current tab
*/
protected void selectNextTab(int current) {
@ -2255,6 +2328,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Select the previous tab.
*
* @param current the current tab
*/
protected void selectPreviousTab(int current) {
@ -2268,6 +2342,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Selects an adjacent run of tabs.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param tabIndex the index of the tab with respect to other tabs
* @param offset selection offset
@ -2314,8 +2389,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
repaintTab(focusIndex);
focusIndex = index;
repaintTab(focusIndex);
}
else {
} else {
focusIndex = index;
}
}
@ -2352,6 +2426,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the tab run offset.
*
* @param tabPlacement the placement (left, right, bottom, top) of the tab
* @param tabCount the tab count
* @param tabIndex the index of the tab with respect to other tabs
@ -2426,6 +2501,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the previous tab index.
*
* @param base the base
* @return the previous tab index
*/
@ -2436,6 +2512,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the next tab index.
*
* @param base the base
* @return the next tab index
*/
@ -2445,6 +2522,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the next tab index in the run.
*
* @param tabCount the tab count
* @param base the base
* @return the next tab index in the run
@ -2463,6 +2541,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the previous tab index in the run.
*
* @param tabCount the tab count
* @param base the base
* @return the previous tab index in the run
@ -2481,6 +2560,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the previous tab run.
*
* @param baseRun the base run
* @return the previous tab run
*/
@ -2491,6 +2571,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the next tab run.
*
* @param baseRun the base run
* @return the next tab run
*/
@ -2500,6 +2581,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Rotates the insets.
*
* @param topInsets the top insets
* @param targetInsets the target insets
* @param targetPlacement the target placement
@ -2565,52 +2647,44 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
public void actionPerformed(ActionEvent e) {
String key = getName();
JTabbedPane pane = (JTabbedPane) e.getSource();
DarkTabbedPaneUIBridge ui = (DarkTabbedPaneUIBridge) DarkUIUtil.getUIOfType(pane.getUI(), DarkTabbedPaneUIBridge.class);
DarkTabbedPaneUIBridge ui = (DarkTabbedPaneUIBridge) DarkUIUtil
.getUIOfType(pane.getUI(),
DarkTabbedPaneUIBridge.class);
if (ui == null) {
return;
}
if (key == NEXT) {
ui.navigateSelectedTab(SwingConstants.NEXT);
}
else if (key == PREVIOUS) {
} else if (key == PREVIOUS) {
ui.navigateSelectedTab(SwingConstants.PREVIOUS);
}
else if (key == RIGHT) {
} else if (key == RIGHT) {
ui.navigateSelectedTab(SwingConstants.EAST);
}
else if (key == LEFT) {
} else if (key == LEFT) {
ui.navigateSelectedTab(SwingConstants.WEST);
}
else if (key == UP) {
} else if (key == UP) {
ui.navigateSelectedTab(SwingConstants.NORTH);
}
else if (key == DOWN) {
} else if (key == DOWN) {
ui.navigateSelectedTab(SwingConstants.SOUTH);
}
else if (key == PAGE_UP) {
} else if (key == PAGE_UP) {
int tabPlacement = pane.getTabPlacement();
if (tabPlacement == TOP || tabPlacement == BOTTOM) {
ui.navigateSelectedTab(SwingConstants.WEST);
} else {
ui.navigateSelectedTab(SwingConstants.NORTH);
}
}
else if (key == PAGE_DOWN) {
} else if (key == PAGE_DOWN) {
int tabPlacement = pane.getTabPlacement();
if (tabPlacement == TOP || tabPlacement == BOTTOM) {
ui.navigateSelectedTab(SwingConstants.EAST);
} else {
ui.navigateSelectedTab(SwingConstants.SOUTH);
}
}
else if (key == REQUEST_FOCUS) {
} else if (key == REQUEST_FOCUS) {
pane.requestFocus();
}
else if (key == REQUEST_FOCUS_FOR_VISIBLE) {
} else if (key == REQUEST_FOCUS_FOR_VISIBLE) {
ui.requestFocusForVisibleComponent();
}
else if (key == SET_SELECTED) {
} else if (key == SET_SELECTED) {
String command = e.getActionCommand();
if (command != null && command.length() > 0) {
@ -2623,19 +2697,16 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
pane.setSelectedIndex(index.intValue());
}
}
}
else if (key == SELECT_FOCUSED) {
} else if (key == SELECT_FOCUSED) {
int focusIndex = ui.getFocusIndex();
if (focusIndex != -1) {
pane.setSelectedIndex(focusIndex);
}
}
else if (key == SCROLL_FORWARD) {
} else if (key == SCROLL_FORWARD) {
if (ui.scrollableTabLayoutEnabled()) {
ui.tabScroller.scrollForward(pane.getTabPlacement());
}
}
else if (key == SCROLL_BACKWARD) {
} else if (key == SCROLL_BACKWARD) {
if (ui.scrollableTabLayoutEnabled()) {
ui.tabScroller.scrollBackward(pane.getTabPlacement());
}
@ -2649,9 +2720,11 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
*/
public class TabbedPaneLayout implements LayoutManager {
public void addLayoutComponent(String name, Component comp) {}
public void addLayoutComponent(String name, Component comp) {
}
public void removeLayoutComponent(Component comp) {}
public void removeLayoutComponent(Component comp) {
}
public Dimension preferredLayoutSize(Container parent) {
return calculateSize(false);
@ -2663,6 +2736,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the calculated size.
*
* @param minimum use the minimum size or preferred size
* @return the calculated size
*/
@ -2722,6 +2796,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the preferred tab area height.
*
* @param tabPlacement the tab placement
* @param width the width
* @return the preferred tab area height
@ -2752,6 +2827,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Returns the preferred tab area width.
*
* @param tabPlacement the tab placement
* @param height the height
* @return the preferred tab area widty
@ -2781,7 +2857,9 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
return total;
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@SuppressWarnings("deprecation")
public void layoutContainer(Container parent) {
/* Some of the code in this method deals with changing the
@ -2948,6 +3026,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Calculate the tab rectangles.
*
* @param tabPlacement the tab placement
* @param tabCount the tab count
*/
@ -3138,6 +3217,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Rotates the run-index array so that the selected run is run[0].
*
* @param tabPlacement the tab placement
* @param selectedRun the selected run
*/
@ -3153,6 +3233,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Normalizes the tab runs.
*
* @param tabPlacement the tab placement
* @param tabCount the tab count
* @param start the start
@ -3228,6 +3309,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Pads the tab run.
*
* @param tabPlacement the tab placement
* @param start the start
* @param end the end
@ -3266,6 +3348,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
/**
* Pads selected tab.
*
* @param tabPlacement the tab placement
* @param selectedIndex the selected index
*/
@ -3855,8 +3938,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
if (e.getSource() == scrollForwardButton) {
actionKey = "scrollTabsForwardAction";
}
else {
} else {
actionKey = "scrollTabsBackwardAction";
}
Action action = map.get(actionKey);
@ -3904,6 +3986,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
}
setBackground(bgColor);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
DarkTabbedPaneUIBridge.this.paintTabArea(g, tabPane.getTabPlacement(),
@ -3952,11 +4035,9 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
if (name == "mnemonicAt") {
updateMnemonics();
pane.repaint();
}
else if (name == "displayedMnemonicIndexAt") {
} else if (name == "displayedMnemonicIndexAt") {
pane.repaint();
}
else if (name =="indexForTitle") {
} else if (name == "indexForTitle") {
calculatedBaseline = false;
Integer index = (Integer) e.getNewValue();
updateHtmlViews(index, false);
@ -4079,8 +4160,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
// This will trigger the focusIndex to change by way
// of stateChanged.
tabPane.setSelectedIndex(tabIndex);
}
else if (tabPane.isRequestFocusEnabled()) {
} else if (tabPane.isRequestFocusEnabled()) {
// Clicking on selected tab, try and give the tabbedpane
// focus. Repaint will occur in focusGained.
tabPane.requestFocus();
@ -4104,6 +4184,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
public void focusGained(FocusEvent e) {
setFocusIndex(tabPane.getSelectedIndex(), true);
}
public void focusLost(FocusEvent e) {
repaintTab(focusIndex);
}
@ -4151,6 +4232,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
isRunsDirty = true;
updateHtmlViews(tp.indexOfComponent(child), true);
}
public void componentRemoved(ContainerEvent e) {
JTabbedPane tp = (JTabbedPane) e.getContainer();
Component child = e.getChild();
@ -4233,6 +4315,7 @@ public class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstan
public void focusGained(FocusEvent e) {
getHandler().focusGained(e);
}
public void focusLost(FocusEvent e) {
getHandler().focusLost(e);
}

37
src/main/java/com/weis/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java

@ -201,7 +201,8 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
}
switch (tabPlacement) {
case TOP, BOTTOM -> {
case TOP:
case BOTTOM:
if (destTabbedPane.getComponentOrientation().isLeftToRight()) {
if (tab >= destTabbedPane.getTabCount() && !lastInSource) {
destRect.x += destRect.width;
@ -223,8 +224,9 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
}
}
dropRect.y = destRect.y + destRect.height - dropRect.height;
}
case LEFT, RIGHT -> {
break;
case LEFT:
case RIGHT:
if (tab >= destTabbedPane.getTabCount()) {
destRect.y += destRect.height;
}
@ -233,14 +235,14 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
if (lastTab != -1 && lastTab < tab) {
dropRect.y -= dropRect.height;
}
}
break;
}
} else {
if (source == destTabbedPane && (tab == sourceIndex || tab == sourceIndex + 1)) {
dropRect.setRect(0, 0, 0, 0);
} else {
switch (destTabbedPane.getTabPlacement()) {
case TOP, BOTTOM -> {
int placement = destTabbedPane.getTabPlacement();
if (placement == TOP || placement == BOTTOM) {
var b = ui.getTabAreaBounds();
if (tab == destTabbedPane.getTabCount()) {
dropRect.x = destRect.x + destRect.width / 2;
@ -271,10 +273,7 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
}
}
dropRect.y = destRect.y + destRect.height - dropRect.height;
}
case LEFT, RIGHT -> {
}
} else if (placement == LEFT || placement == RIGHT) {
}
}
}
@ -333,15 +332,15 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
bounds.height = Math.min(bounds.y + bounds.height - y, maxb.x + maxb.height - y);
}
switch (tabbedPane.getTabPlacement()) {
case TOP, BOTTOM -> {
int tabPlacement = tabbedPane.getTabPlacement();
if (tabPlacement == TOP || tabPlacement == BOTTOM) {
if (tabbedPane.getComponentOrientation().isLeftToRight()) {
tab = p.x <= bounds.x + bounds.width / 2 ? 0 : tabbedPane.getTabCount();
} else {
tab = p.x >= bounds.x + bounds.width / 2 ? 1 : tabbedPane.getTabCount();
}
}
case LEFT, RIGHT -> tab = p.y <= bounds.y + bounds.height / 2 ? 0 : tabbedPane.getTabCount();
} else if (tabPlacement == LEFT || tabPlacement == RIGHT) {
tab = p.y <= bounds.y + bounds.height / 2 ? 0 : tabbedPane.getTabCount();
}
}
} else {
@ -359,7 +358,8 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
var sb = (ui.scrollableTabLayoutEnabled()) ? t.getTabBounds() : EMPTY_RECT;
switch (tabbedPane.getTabPlacement()) {
case TOP, BOTTOM -> {
case TOP:
case BOTTOM:
if (tabbedPane.getComponentOrientation().isLeftToRight()) {
if (p.x >= b.x + sb.width + (b.width - sb.width) / 2) {
tab += 1;
@ -369,12 +369,13 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
tab += 1;
}
}
}
case LEFT, RIGHT -> {
break;
case LEFT:
case RIGHT:
if (p.y >= b.y + sb.height + (b.height - sb.height) / 2) {
tab += 1;
}
}
break;
}
}
}

Loading…
Cancel
Save