mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 06:20:53 +03:00
TabbedPane:
- updated comment regarding unsupported scroll buttons in right-to-left component orientation (see issue #815) - removed unused on wrong code that tries to layout scroll buttons for right-to-left
This commit is contained in:
@@ -3767,9 +3767,20 @@ debug*/
|
|||||||
boolean hideDisabledScrollButtons = (scrollButtonsPolicy == AS_NEEDED_SINGLE && scrollButtonsPlacement == BOTH);
|
boolean hideDisabledScrollButtons = (scrollButtonsPolicy == AS_NEEDED_SINGLE && scrollButtonsPlacement == BOTH);
|
||||||
boolean trailingScrollButtons = (scrollButtonsPlacement == TRAILING);
|
boolean trailingScrollButtons = (scrollButtonsPlacement == TRAILING);
|
||||||
|
|
||||||
// for right-to-left always use "more tabs" button for horizontal scrolling
|
// For right-to-left, always use "more tabs" button for horizontal scrolling
|
||||||
// because methods scrollForward() and scrollBackward() in class
|
// because methods scrollForward() and scrollBackward() in class
|
||||||
// BasicTabbedPaneUI.ScrollableTabSupport do not work for right-to-left
|
// BasicTabbedPaneUI.ScrollableTabSupport do not work for right-to-left.
|
||||||
|
//
|
||||||
|
// One problem is that BasicTabbedPaneUI.getClosestTab(), which is used
|
||||||
|
// to compute leadingTabIndex, does not work for right-to-left because is uses "binary" search
|
||||||
|
// on rects[] to find tab, but rects[] is ordered in reverse order for right-to-left.
|
||||||
|
// So leadingTabIndex is either zero or tabCount.
|
||||||
|
// Therefore increasing/decreasing leadingTabIndex in scrollForward()
|
||||||
|
// and scrollBackward() does not work as expected.
|
||||||
|
// Also backward/forward scroll buttons are not correctly enabled/disabled.
|
||||||
|
//
|
||||||
|
// Fixing this would require replacing nearly whole functionality of class
|
||||||
|
// BasicTabbedPaneUI.ScrollableTabSupport, which is not possible because it is private.
|
||||||
boolean leftToRight = isLeftToRight();
|
boolean leftToRight = isLeftToRight();
|
||||||
if( !leftToRight && isHorizontalTabPlacement( tabPane.getTabPlacement() ) ) {
|
if( !leftToRight && isHorizontalTabPlacement( tabPane.getTabPlacement() ) ) {
|
||||||
useMoreTabsButton = true;
|
useMoreTabsButton = true;
|
||||||
@@ -3863,8 +3874,7 @@ debug*/
|
|||||||
// layout forward button on trailing side
|
// layout forward button on trailing side
|
||||||
if( !hideDisabledScrollButtons || viewSize.width - viewPosition.x > w ) {
|
if( !hideDisabledScrollButtons || viewSize.width - viewPosition.x > w ) {
|
||||||
int buttonWidth = forwardButton.getPreferredSize().width;
|
int buttonWidth = forwardButton.getPreferredSize().width;
|
||||||
forwardButton.setBounds( leftToRight ? (x + w - buttonWidth) : x, y, buttonWidth, h );
|
forwardButton.setBounds( x + w - buttonWidth, y, buttonWidth, h );
|
||||||
x += leftToRight ? 0 : buttonWidth;
|
|
||||||
w -= buttonWidth;
|
w -= buttonWidth;
|
||||||
forwardButtonVisible = true;
|
forwardButtonVisible = true;
|
||||||
}
|
}
|
||||||
@@ -3874,12 +3884,11 @@ debug*/
|
|||||||
int buttonWidth = backwardButton.getPreferredSize().width;
|
int buttonWidth = backwardButton.getPreferredSize().width;
|
||||||
if( trailingScrollButtons ) {
|
if( trailingScrollButtons ) {
|
||||||
// on trailing side
|
// on trailing side
|
||||||
backwardButton.setBounds( leftToRight ? (x + w - buttonWidth) : x, y, buttonWidth, h );
|
backwardButton.setBounds( x + w - buttonWidth, y, buttonWidth, h );
|
||||||
x += leftToRight ? 0 : buttonWidth;
|
|
||||||
} else {
|
} else {
|
||||||
// on leading side
|
// on leading side
|
||||||
backwardButton.setBounds( leftToRight ? x : (x + w - buttonWidth), y, buttonWidth, h );
|
backwardButton.setBounds( x, y, buttonWidth, h );
|
||||||
x += leftToRight ? buttonWidth : 0;
|
x += buttonWidth;
|
||||||
}
|
}
|
||||||
w -= buttonWidth;
|
w -= buttonWidth;
|
||||||
backwardButtonVisible = true;
|
backwardButtonVisible = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user