JIDE: RangeSlider:

- updated with latest changes from FlatSliderUI
- use static FlatSliderUI methods for thumb painting
- hover/pressed feedback on single thumb
- hover/pressed feedback on middle track and both thumbs
- added JSlider components to FlatRangeSliderTest for easier testing/comparing
This commit is contained in:
Karl Tauber
2020-11-17 18:07:11 +01:00
parent 6e55e0a183
commit e337e5bbd8
8 changed files with 288 additions and 95 deletions

View File

@@ -843,10 +843,12 @@ Slider.foreground #ff0000 javax.swing.plaf.ColorUIResource [UI]
Slider.highlight #ffffff javax.swing.plaf.ColorUIResource [UI]
Slider.horizontalSize 200,21 java.awt.Dimension
Slider.hoverThumbColor #0000ff javax.swing.plaf.ColorUIResource [UI]
Slider.hoverTrackColor #4444ff javax.swing.plaf.ColorUIResource [UI]
Slider.minimumHorizontalSize 36,21 java.awt.Dimension
Slider.minimumVerticalSize 21,36 java.awt.Dimension
Slider.onlyLeftMouseButtonDrag true
Slider.pressedThumbColor #00ff00 javax.swing.plaf.ColorUIResource [UI]
Slider.pressedTrackColor #88ff88 javax.swing.plaf.ColorUIResource [UI]
Slider.shadow #a0a0a0 javax.swing.plaf.ColorUIResource [UI]
Slider.thumbColor #880000 javax.swing.plaf.ColorUIResource [UI]
Slider.thumbWidth 11

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.testing.jideoss;
import com.formdev.flatlaf.FlatDefaultsAddon;
/**
* JIDE Common Layer addon for FlatLaf for testing.
* <p>
* Finds JIDE Common Layer addon .properties file for the given LaF class
* in the same package as this class.
*
* @author Karl Tauber
*/
public class FlatJideOssDefaultsTestAddon
extends FlatDefaultsAddon
{
}

View File

@@ -18,6 +18,7 @@ package com.formdev.flatlaf.testing.jideoss;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
@@ -50,13 +51,19 @@ public class FlatRangeSliderTest
}
private void paintLabels() {
horizontalRangeSlider.setPaintLabels( paintLabel.isSelected() );
verticalRangeSlider.setPaintLabels( paintLabel.isSelected() );
boolean selected = paintLabel.isSelected();
horizontalRangeSlider.setPaintLabels( selected );
verticalRangeSlider.setPaintLabels( selected );
horizontalSlider.setPaintLabels( selected );
verticalSlider.setPaintLabels( selected );
}
private void paintTicks() {
horizontalRangeSlider.setPaintTicks( paintTick.isSelected() );
verticalRangeSlider.setPaintTicks( paintTick.isSelected() );
boolean selected = paintTick.isSelected();
horizontalRangeSlider.setPaintTicks( selected );
verticalRangeSlider.setPaintTicks( selected );
horizontalSlider.setPaintTicks( selected );
verticalSlider.setPaintTicks( selected );
}
private void initComponents() {
@@ -64,8 +71,14 @@ public class FlatRangeSliderTest
JLabel tabbedPaneLabel = new JLabel();
JLabel horizontalLabel = new JLabel();
horizontalRangeSlider = new RangeSlider();
horizontalSlider = new JSlider();
horizontalRangeSlider2 = new RangeSlider();
horizontalSlider2 = new JSlider();
JLabel verticalLabel = new JLabel();
verticalRangeSlider = new RangeSlider();
verticalSlider = new JSlider();
verticalRangeSlider2 = new RangeSlider();
verticalSlider2 = new JSlider();
paintTick = new JCheckBox();
paintLabel = new JCheckBox();
@@ -74,10 +87,13 @@ public class FlatRangeSliderTest
"insets dialog,hidemode 3",
// columns
"[left]" +
"[fill]",
"[240,left]",
// rows
"[fill]" +
"[center]" +
"[]" +
"[]" +
"[]" +
"[grow,fill]" +
"[]"));
@@ -88,57 +104,92 @@ public class FlatRangeSliderTest
//---- horizontalLabel ----
horizontalLabel.setText("Horizontal");
add(horizontalLabel, "cell 0 1");
add(horizontalRangeSlider, "cell 1 1");
//---- horizontalRangeSlider ----
horizontalRangeSlider.setLowValue(30);
horizontalRangeSlider.setHighValue(80);
horizontalRangeSlider.setMajorTickSpacing(10);
horizontalRangeSlider.setMinorTickSpacing(5);
horizontalRangeSlider.setPaintTicks(true);
horizontalRangeSlider.setPaintLabels(true);
add(horizontalRangeSlider, "cell 1 1,growx");
//---- horizontalSlider ----
horizontalSlider.setMinorTickSpacing(5);
horizontalSlider.setPaintTicks(true);
horizontalSlider.setMajorTickSpacing(10);
horizontalSlider.setPaintLabels(true);
horizontalSlider.setValue(30);
add(horizontalSlider, "cell 1 2,growx");
//---- horizontalRangeSlider2 ----
horizontalRangeSlider2.setLowValue(30);
horizontalRangeSlider2.setHighValue(80);
add(horizontalRangeSlider2, "cell 1 3,growx");
//---- horizontalSlider2 ----
horizontalSlider2.setValue(30);
add(horizontalSlider2, "cell 1 4,growx");
//---- verticalLabel ----
verticalLabel.setText("Vertical");
add(verticalLabel, "cell 0 2,aligny top,growy 0");
add(verticalLabel, "cell 0 5,aligny top,growy 0");
//---- verticalRangeSlider ----
verticalRangeSlider.setOrientation(SwingConstants.VERTICAL);
add(verticalRangeSlider, "cell 1 2,alignx left,growx 0");
verticalRangeSlider.setLowValue(30);
verticalRangeSlider.setHighValue(80);
verticalRangeSlider.setMajorTickSpacing(10);
verticalRangeSlider.setMinorTickSpacing(5);
verticalRangeSlider.setPaintTicks(true);
verticalRangeSlider.setPaintLabels(true);
add(verticalRangeSlider, "cell 1 5,alignx left,growx 0");
//---- verticalSlider ----
verticalSlider.setMinorTickSpacing(5);
verticalSlider.setPaintTicks(true);
verticalSlider.setMajorTickSpacing(10);
verticalSlider.setPaintLabels(true);
verticalSlider.setOrientation(SwingConstants.VERTICAL);
verticalSlider.setValue(30);
add(verticalSlider, "cell 1 5");
//---- verticalRangeSlider2 ----
verticalRangeSlider2.setOrientation(SwingConstants.VERTICAL);
verticalRangeSlider2.setLowValue(30);
verticalRangeSlider2.setHighValue(80);
add(verticalRangeSlider2, "cell 1 5");
//---- verticalSlider2 ----
verticalSlider2.setOrientation(SwingConstants.VERTICAL);
verticalSlider2.setValue(30);
add(verticalSlider2, "cell 1 5");
//---- paintTick ----
paintTick.setText("PaintTicks");
paintTick.setMnemonic('T');
paintTick.setSelected(true);
paintTick.addActionListener(e -> paintTicks());
add(paintTick, "cell 0 3 2 1");
add(paintTick, "cell 0 6 2 1");
//---- paintLabel ----
paintLabel.setText("PaintLabels");
paintLabel.setMnemonic('L');
paintLabel.setSelected(true);
paintLabel.addActionListener(e -> paintLabels());
add(paintLabel, "cell 0 3 2 1");
add(paintLabel, "cell 0 6 2 1");
// JFormDesigner - End of component initialization //GEN-END:initComponents
horizontalRangeSlider.setOrientation( SwingConstants.HORIZONTAL );
horizontalRangeSlider.setMinimum( 0 );
horizontalRangeSlider.setMaximum( 100 );
horizontalRangeSlider.setLowValue( 10 );
horizontalRangeSlider.setHighValue( 90 );
horizontalRangeSlider.setLabelTable( horizontalRangeSlider.createStandardLabels( 10 ) );
horizontalRangeSlider.setMinorTickSpacing( 5 );
horizontalRangeSlider.setMajorTickSpacing( 10 );
horizontalRangeSlider.setPaintTicks( true );
horizontalRangeSlider.setPaintLabels( true );
verticalRangeSlider.setOrientation( SwingConstants.VERTICAL );
verticalRangeSlider.setMinimum( 0 );
verticalRangeSlider.setMaximum( 100 );
verticalRangeSlider.setLowValue( 10 );
verticalRangeSlider.setHighValue( 90 );
verticalRangeSlider.setLabelTable( horizontalRangeSlider.createStandardLabels( 10 ) );
verticalRangeSlider.setMinorTickSpacing( 5 );
verticalRangeSlider.setMajorTickSpacing( 10 );
verticalRangeSlider.setPaintTicks( true );
verticalRangeSlider.setPaintLabels( true );
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private RangeSlider horizontalRangeSlider;
private JSlider horizontalSlider;
private RangeSlider horizontalRangeSlider2;
private JSlider horizontalSlider2;
private RangeSlider verticalRangeSlider;
private JSlider verticalSlider;
private RangeSlider verticalRangeSlider2;
private JSlider verticalSlider2;
private JCheckBox paintTick;
private JCheckBox paintLabel;
// JFormDesigner - End of variables declaration //GEN-END:variables

View File

@@ -8,8 +8,8 @@ new FormModel {
}
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets dialog,hidemode 3"
"$columnConstraints": "[left][fill]"
"$rowConstraints": "[fill][center][grow,fill][]"
"$columnConstraints": "[left][240,left]"
"$rowConstraints": "[fill][center][][][][grow,fill][]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
@@ -26,26 +26,105 @@ new FormModel {
} )
add( new FormComponent( "com.jidesoft.swing.RangeSlider" ) {
name: "horizontalRangeSlider"
"lowValue": 30
"highValue": 80
"majorTickSpacing": 10
"minorTickSpacing": 5
"paintTicks": true
"paintLabels": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
"value": "cell 1 1,growx"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "horizontalSlider"
"minorTickSpacing": 5
"paintTicks": true
"majorTickSpacing": 10
"paintLabels": true
"value": 30
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2,growx"
} )
add( new FormComponent( "com.jidesoft.swing.RangeSlider" ) {
name: "horizontalRangeSlider2"
"lowValue": 30
"highValue": 80
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3,growx"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "horizontalSlider2"
"value": 30
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "verticalLabel"
"text": "Vertical"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2,aligny top,growy 0"
"value": "cell 0 5,aligny top,growy 0"
} )
add( new FormComponent( "com.jidesoft.swing.RangeSlider" ) {
name: "verticalRangeSlider"
"orientation": 1
"lowValue": 30
"highValue": 80
"majorTickSpacing": 10
"minorTickSpacing": 5
"paintTicks": true
"paintLabels": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2,alignx left,growx 0"
"value": "cell 1 5,alignx left,growx 0"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "verticalSlider"
"minorTickSpacing": 5
"paintTicks": true
"majorTickSpacing": 10
"paintLabels": true
"orientation": 1
"value": 30
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormComponent( "com.jidesoft.swing.RangeSlider" ) {
name: "verticalRangeSlider2"
"orientation": 1
"lowValue": 30
"highValue": 80
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "verticalSlider2"
"orientation": 1
"value": 30
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "paintTick"
@@ -57,7 +136,7 @@ new FormModel {
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintTicks", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3 2 1"
"value": "cell 0 6 2 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "paintLabel"
@@ -69,7 +148,7 @@ new FormModel {
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintLabels", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3 2 1"
"value": "cell 0 6 2 1"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )

View File

@@ -1 +1,2 @@
com.formdev.flatlaf.testing.jideoss.FlatJideOssDefaultsTestAddon
com.formdev.flatlaf.testing.swingx.FlatSwingXDefaultsTestAddon

View File

@@ -0,0 +1,20 @@
#
# Copyright 2020 FormDev Software GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#---- RangeSlider ----
Slider.hoverTrackColor=#44f
Slider.pressedTrackColor=#8f8