mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
- ScrollBar: show "pressed" feedback on track/thumb only for left mouse button; if absolute positioning is enabled (the default), then also for middle mouse button
- Arrow buttons in ComboBox, Spinner, ScrollBar and TabbedPane: show "pressed" feedback only for left mouse button
This commit is contained in:
@@ -8,6 +8,11 @@ FlatLaf Change Log
|
||||
- ComboBox and Spinner: Fixed missing arrow buttons if preferred height is zero.
|
||||
Minimum width of arrow buttons is 3/4 of default width.
|
||||
- TabbedPane: Switch and close tabs on left mouse click only. (PR #595)
|
||||
- ScrollBar: Show "pressed" feedback on track/thumb only for left mouse button.
|
||||
If absolute positioning is enabled (the default), then also for middle mouse
|
||||
button.
|
||||
- Arrow buttons in ComboBox, Spinner, ScrollBar and TabbedPane: Show "pressed"
|
||||
feedback only for left mouse button.
|
||||
|
||||
|
||||
## 2.5
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import javax.swing.plaf.basic.BasicArrowButton;
|
||||
|
||||
@@ -82,15 +83,19 @@ public class FlatArrowButton
|
||||
|
||||
@Override
|
||||
public void mousePressed( MouseEvent e ) {
|
||||
if( SwingUtilities.isLeftMouseButton( e ) ) {
|
||||
pressed = true;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased( MouseEvent e ) {
|
||||
if( SwingUtilities.isLeftMouseButton( e ) ) {
|
||||
pressed = false;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,6 +352,9 @@ public class FlatScrollBarUI
|
||||
|
||||
@Override
|
||||
protected void paintTrack( Graphics g, JComponent c, Rectangle trackBounds ) {
|
||||
if( trackBounds.isEmpty() || !scrollbar.isEnabled() )
|
||||
return;
|
||||
|
||||
g.setColor( getTrackColor( c, hoverTrack, isPressed && hoverTrack && !hoverThumb ) );
|
||||
paintTrackOrThumb( g, c, trackBounds, trackInsets, trackArc );
|
||||
}
|
||||
@@ -452,18 +455,31 @@ public class FlatScrollBarUI
|
||||
|
||||
@Override
|
||||
public void mousePressed( MouseEvent e ) {
|
||||
if( SwingUtilities.isLeftMouseButton( e ) || isAbsolutePositioning( e ) ) {
|
||||
isPressed = true;
|
||||
repaint();
|
||||
|
||||
// update hover because BasicScrollBarUI.TrackListener.mousePressed()
|
||||
// moves the track on middle-click (if absolute positioning is enabled)
|
||||
if( isAbsolutePositioning( e ) )
|
||||
update( e.getX(), e.getY() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased( MouseEvent e ) {
|
||||
if( SwingUtilities.isLeftMouseButton( e ) || isAbsolutePositioning( e ) ) {
|
||||
isPressed = false;
|
||||
repaint();
|
||||
}
|
||||
|
||||
update( e.getX(), e.getY() );
|
||||
}
|
||||
|
||||
private boolean isAbsolutePositioning( MouseEvent e ) {
|
||||
return getSupportsAbsolutePositioning() && SwingUtilities.isMiddleMouseButton( e );
|
||||
}
|
||||
|
||||
private void update( int x, int y ) {
|
||||
boolean inTrack = getTrackBounds().contains( x, y );
|
||||
boolean inThumb = getThumbBounds().contains( x, y );
|
||||
|
||||
Reference in New Issue
Block a user