mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
Spinner: reduced gap between up and down arrows, which was increased by previous commit (issue #329)
This commit is contained in:
@@ -18,6 +18,7 @@ FlatLaf Change Log
|
||||
- Fixed white lines at bottom and right side of window (in dark themes on HiDPI
|
||||
screens with scaling enabled).
|
||||
- ScrollBar: Fixed left/top arrow icon location (if visible). (issue #329)
|
||||
- Spinner: Fixed up/down arrow icon location.
|
||||
- ToolTip: Fixed positioning of huge tooltips. (issue #333)
|
||||
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ public class FlatArrowButton
|
||||
protected final Color pressedBackground;
|
||||
|
||||
private int arrowWidth = DEFAULT_ARROW_WIDTH;
|
||||
private int xOffset = 0;
|
||||
private int yOffset = 0;
|
||||
private float xOffset = 0;
|
||||
private float yOffset = 0;
|
||||
|
||||
private boolean hover;
|
||||
private boolean pressed;
|
||||
@@ -117,19 +117,19 @@ public class FlatArrowButton
|
||||
return pressed;
|
||||
}
|
||||
|
||||
public int getXOffset() {
|
||||
public float getXOffset() {
|
||||
return xOffset;
|
||||
}
|
||||
|
||||
public void setXOffset( int xOffset ) {
|
||||
public void setXOffset( float xOffset ) {
|
||||
this.xOffset = xOffset;
|
||||
}
|
||||
|
||||
public int getYOffset() {
|
||||
public float getYOffset() {
|
||||
return yOffset;
|
||||
}
|
||||
|
||||
public void setYOffset( int yOffset ) {
|
||||
public void setYOffset( float yOffset ) {
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ public class FlatSpinnerUI
|
||||
FlatArrowButton button = new FlatArrowButton( direction, arrowType, buttonArrowColor,
|
||||
buttonDisabledArrowColor, buttonHoverArrowColor, null, buttonPressedArrowColor, null );
|
||||
button.setName( name );
|
||||
button.setYOffset( (direction == SwingConstants.NORTH) ? 1 : -1 );
|
||||
button.setYOffset( (direction == SwingConstants.NORTH) ? 1.25f : -1.25f );
|
||||
if( direction == SwingConstants.NORTH )
|
||||
installNextButtonListeners( button );
|
||||
else
|
||||
|
||||
@@ -660,7 +660,7 @@ public class FlatUIUtils
|
||||
* @since 1.1
|
||||
*/
|
||||
public static void paintArrow( Graphics2D g, int x, int y, int width, int height,
|
||||
int direction, boolean chevron, int arrowSize, int xOffset, int yOffset )
|
||||
int direction, boolean chevron, int arrowSize, float xOffset, float yOffset )
|
||||
{
|
||||
// compute arrow width/height
|
||||
int aw = UIScale.scale( arrowSize + (chevron ? 0 : 1) );
|
||||
@@ -679,8 +679,8 @@ public class FlatUIUtils
|
||||
int extra = chevron ? 1 : 0;
|
||||
|
||||
// compute arrow location
|
||||
float ox = ((width - (aw + extra)) / 2f) + UIScale.scale( (float) xOffset );
|
||||
float oy = ((height - (ah + extra)) / 2f) + UIScale.scale( (float) yOffset );
|
||||
float ox = ((width - (aw + extra)) / 2f) + UIScale.scale( xOffset );
|
||||
float oy = ((height - (ah + extra)) / 2f) + UIScale.scale( yOffset );
|
||||
int ax = x + ((direction == SwingConstants.WEST) ? -Math.round( -ox ) : Math.round( ox ));
|
||||
int ay = y + ((direction == SwingConstants.NORTH) ? -Math.round( -oy ) : Math.round( oy ));
|
||||
|
||||
|
||||
@@ -73,6 +73,25 @@ public class FlatPaintingTest
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void offsetChanged() {
|
||||
float offset = (float) offsetSpinner.getValue();
|
||||
System.out.println( offset );
|
||||
|
||||
arrowPainter5.setYOffset( offset );
|
||||
arrowPainter6.setYOffset( -offset );
|
||||
|
||||
arrowPainter7.setXOffset( offset );
|
||||
arrowPainter8.setXOffset( -offset );
|
||||
|
||||
arrowPainter13.setYOffset( offset );
|
||||
arrowPainter14.setYOffset( -offset );
|
||||
|
||||
arrowPainter15.setXOffset( offset );
|
||||
arrowPainter16.setXOffset( -offset );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void vectorChanged() {
|
||||
boolean vector = vectorCheckBox.isSelected();
|
||||
|
||||
@@ -84,7 +103,7 @@ public class FlatPaintingTest
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void checkBox1ActionPerformed() {
|
||||
private void arrowButtonChanged() {
|
||||
boolean button = buttonCheckBox.isSelected();
|
||||
|
||||
FlatTestFrame.updateComponentsRecur( (Container) getViewport().getView(), (c, type) -> {
|
||||
@@ -143,11 +162,11 @@ public class FlatPaintingTest
|
||||
FlatPaintingTest.ArrowPainter arrowPainter3 = new FlatPaintingTest.ArrowPainter();
|
||||
FlatPaintingTest.ArrowPainter arrowPainter4 = new FlatPaintingTest.ArrowPainter();
|
||||
JPanel panel1 = new JPanel();
|
||||
FlatPaintingTest.ArrowPainter arrowPainter5 = new FlatPaintingTest.ArrowPainter();
|
||||
FlatPaintingTest.ArrowPainter arrowPainter6 = new FlatPaintingTest.ArrowPainter();
|
||||
arrowPainter5 = new FlatPaintingTest.ArrowPainter();
|
||||
arrowPainter6 = new FlatPaintingTest.ArrowPainter();
|
||||
JPanel panel2 = new JPanel();
|
||||
FlatPaintingTest.ArrowPainter arrowPainter7 = new FlatPaintingTest.ArrowPainter();
|
||||
FlatPaintingTest.ArrowPainter arrowPainter8 = new FlatPaintingTest.ArrowPainter();
|
||||
arrowPainter7 = new FlatPaintingTest.ArrowPainter();
|
||||
arrowPainter8 = new FlatPaintingTest.ArrowPainter();
|
||||
JPanel panel5 = new JPanel();
|
||||
JLabel arrowWidthLabel = new JLabel();
|
||||
arrowWidthSpinner = new JSpinner();
|
||||
@@ -155,6 +174,8 @@ public class FlatPaintingTest
|
||||
arrowHeightSpinner = new JSpinner();
|
||||
JLabel arrowSizeLabel = new JLabel();
|
||||
arrowSizeSpinner = new JSpinner();
|
||||
JLabel offsetLabel = new JLabel();
|
||||
offsetSpinner = new JSpinner();
|
||||
vectorCheckBox = new JCheckBox();
|
||||
buttonCheckBox = new JCheckBox();
|
||||
FlatPaintingTest.ArrowPainter arrowPainter9 = new FlatPaintingTest.ArrowPainter();
|
||||
@@ -162,11 +183,11 @@ public class FlatPaintingTest
|
||||
FlatPaintingTest.ArrowPainter arrowPainter11 = new FlatPaintingTest.ArrowPainter();
|
||||
FlatPaintingTest.ArrowPainter arrowPainter12 = new FlatPaintingTest.ArrowPainter();
|
||||
JPanel panel3 = new JPanel();
|
||||
FlatPaintingTest.ArrowPainter arrowPainter13 = new FlatPaintingTest.ArrowPainter();
|
||||
FlatPaintingTest.ArrowPainter arrowPainter14 = new FlatPaintingTest.ArrowPainter();
|
||||
arrowPainter13 = new FlatPaintingTest.ArrowPainter();
|
||||
arrowPainter14 = new FlatPaintingTest.ArrowPainter();
|
||||
JPanel panel4 = new JPanel();
|
||||
FlatPaintingTest.ArrowPainter arrowPainter15 = new FlatPaintingTest.ArrowPainter();
|
||||
FlatPaintingTest.ArrowPainter arrowPainter16 = new FlatPaintingTest.ArrowPainter();
|
||||
arrowPainter15 = new FlatPaintingTest.ArrowPainter();
|
||||
arrowPainter16 = new FlatPaintingTest.ArrowPainter();
|
||||
|
||||
//======== this ========
|
||||
setBorder(null);
|
||||
@@ -519,6 +540,7 @@ public class FlatPaintingTest
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- arrowWidthLabel ----
|
||||
@@ -548,17 +570,26 @@ public class FlatPaintingTest
|
||||
arrowSizeSpinner.addChangeListener(e -> arrowSizeChanged());
|
||||
panel5.add(arrowSizeSpinner, "cell 1 2");
|
||||
|
||||
//---- offsetLabel ----
|
||||
offsetLabel.setText("Offset:");
|
||||
panel5.add(offsetLabel, "cell 0 3");
|
||||
|
||||
//---- offsetSpinner ----
|
||||
offsetSpinner.setModel(new SpinnerNumberModel(1.0F, null, null, 0.05F));
|
||||
offsetSpinner.addChangeListener(e -> offsetChanged());
|
||||
panel5.add(offsetSpinner, "cell 1 3");
|
||||
|
||||
//---- vectorCheckBox ----
|
||||
vectorCheckBox.setText("vector");
|
||||
vectorCheckBox.addActionListener(e -> vectorChanged());
|
||||
panel5.add(vectorCheckBox, "cell 0 3 2 1,alignx left,growx 0");
|
||||
panel5.add(vectorCheckBox, "cell 0 4 2 1,alignx left,growx 0");
|
||||
|
||||
//---- buttonCheckBox ----
|
||||
buttonCheckBox.setText("FlatArrowButton");
|
||||
buttonCheckBox.addActionListener(e -> checkBox1ActionPerformed());
|
||||
panel5.add(buttonCheckBox, "cell 0 4 2 1,alignx left,growx 0");
|
||||
buttonCheckBox.addActionListener(e -> arrowButtonChanged());
|
||||
panel5.add(buttonCheckBox, "cell 0 5 2 1,alignx left,growx 0");
|
||||
}
|
||||
flatTestPanel1.add(panel5, "cell 6 5,aligny top,growy 0");
|
||||
flatTestPanel1.add(panel5, "cell 6 5 1 2,aligny top,growy 0");
|
||||
|
||||
//---- arrowPainter9 ----
|
||||
arrowPainter9.setScale(8.0F);
|
||||
@@ -635,11 +666,20 @@ public class FlatPaintingTest
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||
private FlatPaintingTest.ArrowPainter arrowPainter5;
|
||||
private FlatPaintingTest.ArrowPainter arrowPainter6;
|
||||
private FlatPaintingTest.ArrowPainter arrowPainter7;
|
||||
private FlatPaintingTest.ArrowPainter arrowPainter8;
|
||||
private JSpinner arrowWidthSpinner;
|
||||
private JSpinner arrowHeightSpinner;
|
||||
private JSpinner arrowSizeSpinner;
|
||||
private JSpinner offsetSpinner;
|
||||
private JCheckBox vectorCheckBox;
|
||||
private JCheckBox buttonCheckBox;
|
||||
private FlatPaintingTest.ArrowPainter arrowPainter13;
|
||||
private FlatPaintingTest.ArrowPainter arrowPainter14;
|
||||
private FlatPaintingTest.ArrowPainter arrowPainter15;
|
||||
private FlatPaintingTest.ArrowPainter arrowPainter16;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
|
||||
//---- class BorderPainter ------------------------------------------------
|
||||
@@ -792,8 +832,8 @@ public class FlatPaintingTest
|
||||
private int direction = SwingConstants.SOUTH;
|
||||
private boolean chevron = true;
|
||||
private int arrowSize = FlatArrowButton.DEFAULT_ARROW_WIDTH;
|
||||
private int xOffset = 0;
|
||||
private int yOffset = 0;
|
||||
private float xOffset = 0;
|
||||
private float yOffset = 0;
|
||||
private float scale = 1;
|
||||
private boolean halfWidth;
|
||||
private boolean halfHeight;
|
||||
@@ -845,19 +885,19 @@ public class FlatPaintingTest
|
||||
this.arrowSize = arrowSize;
|
||||
}
|
||||
|
||||
public int getXOffset() {
|
||||
public float getXOffset() {
|
||||
return xOffset;
|
||||
}
|
||||
|
||||
public void setXOffset( int xOffset ) {
|
||||
public void setXOffset( float xOffset ) {
|
||||
this.xOffset = xOffset;
|
||||
}
|
||||
|
||||
public int getYOffset() {
|
||||
public float getYOffset() {
|
||||
return yOffset;
|
||||
}
|
||||
|
||||
public void setYOffset( int yOffset ) {
|
||||
public void setYOffset( float yOffset ) {
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
JFDML JFormDesigner: "7.0.3.1.342" Java: "15" encoding: "UTF-8"
|
||||
JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8"
|
||||
|
||||
new FormModel {
|
||||
contentType: "form/swing"
|
||||
@@ -383,6 +383,9 @@ new FormModel {
|
||||
"h": 10
|
||||
"halfHeight": true
|
||||
"YOffset": 1
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
||||
name: "arrowPainter6"
|
||||
@@ -390,6 +393,9 @@ new FormModel {
|
||||
"h": 10
|
||||
"halfHeight": true
|
||||
"YOffset": -1
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 4 5,align left top,grow 0 0"
|
||||
@@ -403,6 +409,9 @@ new FormModel {
|
||||
"w": 10
|
||||
"halfWidth": true
|
||||
"XOffset": 1
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
||||
name: "arrowPainter8"
|
||||
@@ -411,6 +420,9 @@ new FormModel {
|
||||
"w": 10
|
||||
"halfWidth": true
|
||||
"XOffset": -1
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 5,align left top,grow 0 0"
|
||||
@@ -418,7 +430,7 @@ new FormModel {
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "hidemode 3"
|
||||
"$columnConstraints": "[fill][fill]"
|
||||
"$rowConstraints": "[][][][][]"
|
||||
"$rowConstraints": "[][][][][][]"
|
||||
} ) {
|
||||
name: "panel5"
|
||||
"border": new javax.swing.border.TitledBorder( "Arrow Control" )
|
||||
@@ -479,6 +491,25 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "offsetLabel"
|
||||
"text": "Offset:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JSpinner" ) {
|
||||
name: "offsetSpinner"
|
||||
"model": new javax.swing.SpinnerNumberModel {
|
||||
stepSize: 0.05f
|
||||
value: 1.0f
|
||||
}
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "offsetChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "vectorCheckBox"
|
||||
"text": "vector"
|
||||
@@ -487,7 +518,7 @@ new FormModel {
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "vectorChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3 2 1,alignx left,growx 0"
|
||||
"value": "cell 0 4 2 1,alignx left,growx 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "buttonCheckBox"
|
||||
@@ -495,12 +526,12 @@ new FormModel {
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "checkBox1ActionPerformed", false ) )
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "arrowButtonChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 4 2 1,alignx left,growx 0"
|
||||
"value": "cell 0 5 2 1,alignx left,growx 0"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 6 5,aligny top,growy 0"
|
||||
"value": "cell 6 5 1 2,aligny top,growy 0"
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
||||
name: "arrowPainter9"
|
||||
@@ -545,6 +576,9 @@ new FormModel {
|
||||
"chevron": false
|
||||
"halfHeight": true
|
||||
"YOffset": 1
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
||||
name: "arrowPainter14"
|
||||
@@ -553,6 +587,9 @@ new FormModel {
|
||||
"chevron": false
|
||||
"halfHeight": true
|
||||
"YOffset": -1
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 4 6,align left top,grow 0 0"
|
||||
@@ -567,6 +604,9 @@ new FormModel {
|
||||
"chevron": false
|
||||
"halfWidth": true
|
||||
"XOffset": 1
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
||||
name: "arrowPainter16"
|
||||
@@ -576,6 +616,9 @@ new FormModel {
|
||||
"chevron": false
|
||||
"halfWidth": true
|
||||
"XOffset": -1
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 6,align left top,grow 0 0"
|
||||
|
||||
Reference in New Issue
Block a user