Skip to content

Commit

Permalink
Fix regression in tabbed pane scroll layout mode
Browse files Browse the repository at this point in the history
Need to use buttons marked as `@RadianceInternalButton` so that they do not get treated as tab components

Fixes #398
  • Loading branch information
kirill-grouchnikov committed Aug 18, 2022
1 parent f04fa8e commit 5addb52
Showing 1 changed file with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,39 @@ public void componentRemoved(ContainerEvent e) {
modifiedTimelines.remove(tabComponent);
}
}
}

@RadianceInternalButton
@RadianceInternalArrowButton
private static class TabbedPaneScrollButton extends JButton implements UIResource {
/**
* Simple constructor.
*/
public TabbedPaneScrollButton() {
super();
this.setRequestFocusEnabled(false);
this.setIconTextGap(0);
}

@Override
public boolean isFocusable() {
return false;
}

@Override
public Insets getInsets() {
return new Insets(0, 0, 0, 0);
}

@Override
public Insets getInsets(Insets insets) {
if (insets == null) {
insets = new Insets(0, 0, 0, 0);
} else {
insets.set(0, 0, 0, 0);
}
return insets;
}
}

/**
Expand Down Expand Up @@ -887,25 +919,7 @@ protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x,

@Override
protected JButton createScrollButton(final int direction) {
JButton ssb = new JButton() {
@Override
public Insets getInsets() {
return new Insets(0, 0, 0, 0);
}

@Override
public Insets getInsets(Insets insets) {
if (insets == null) {
insets = new Insets(0, 0, 0, 0);
} else {
insets.set(0, 0, 0, 0);
}
return insets;
}
};

ssb.setRequestFocusEnabled(false);
ssb.setIconTextGap(0);
JButton ssb = new TabbedPaneScrollButton();
RadianceThemingCortex.ComponentOrParentScope.setButtonIgnoreMinimumSize(ssb, Boolean.TRUE);
RadianceThemingCortex.ComponentScope.setButtonStraightSides(
ssb, EnumSet.allOf(RadianceThemingSlices.Side.class));
Expand Down

0 comments on commit 5addb52

Please sign in to comment.