ScrollBar: show decrease/increase arrow buttons if client property "JScrollBar.showButtons" is set to true on JScrollPane or JScrollBar (issue #25)

This commit is contained in:
Karl Tauber
2019-12-03 10:53:39 +01:00
parent 2cc8327a08
commit 48e38b2855
10 changed files with 341 additions and 115 deletions

View File

@@ -46,6 +46,8 @@ class MoreComponentsPanel
JPanel panel1 = new JPanel();
JScrollBar scrollBar2 = new JScrollBar();
JScrollBar scrollBar3 = new JScrollBar();
JScrollBar scrollBar7 = new JScrollBar();
JScrollBar scrollBar8 = new JScrollBar();
JSeparator separator2 = new JSeparator();
JSlider slider2 = new JSlider();
JSlider slider4 = new JSlider();
@@ -60,6 +62,8 @@ class MoreComponentsPanel
JLabel scrollBarLabel = new JLabel();
JScrollBar scrollBar1 = new JScrollBar();
JScrollBar scrollBar4 = new JScrollBar();
JScrollBar scrollBar5 = new JScrollBar();
JScrollBar scrollBar6 = new JScrollBar();
JLabel separatorLabel = new JLabel();
JSeparator separator1 = new JSeparator();
JPanel panel2 = new JPanel();
@@ -102,6 +106,8 @@ class MoreComponentsPanel
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]"));
//---- scrollPaneLabel ----
@@ -121,20 +127,29 @@ class MoreComponentsPanel
scrollPane13.setViewportView(panel1);
}
add(scrollPane13, "cell 1 0,grow,width 70,height 70");
add(scrollBar2, "cell 2 0 1 4,growy");
add(scrollBar2, "cell 2 0 1 6,growy");
//---- scrollBar3 ----
scrollBar3.setEnabled(false);
add(scrollBar3, "cell 2 0 1 4,growy");
add(scrollBar3, "cell 2 0 1 6,growy");
//---- scrollBar7 ----
scrollBar7.putClientProperty("JScrollBar.showButtons", true);
add(scrollBar7, "cell 2 0 1 6,growy");
//---- scrollBar8 ----
scrollBar8.setEnabled(false);
scrollBar8.putClientProperty("JScrollBar.showButtons", true);
add(scrollBar8, "cell 2 0 1 6,growy");
//---- separator2 ----
separator2.setOrientation(SwingConstants.VERTICAL);
add(separator2, "cell 2 0 1 4,growy");
add(separator2, "cell 2 0 1 6,growy");
//---- slider2 ----
slider2.setOrientation(SwingConstants.VERTICAL);
slider2.setValue(30);
add(slider2, "cell 2 0 1 4,growy");
add(slider2, "cell 2 0 1 6,growy");
//---- slider4 ----
slider4.setMinorTickSpacing(10);
@@ -143,19 +158,19 @@ class MoreComponentsPanel
slider4.setPaintLabels(true);
slider4.setOrientation(SwingConstants.VERTICAL);
slider4.setValue(30);
add(slider4, "cell 2 0 1 4,growy");
add(slider4, "cell 2 0 1 6,growy");
add(scrollPane14, "cell 3 0,grow");
//---- progressBar3 ----
progressBar3.setOrientation(SwingConstants.VERTICAL);
progressBar3.setValue(50);
add(progressBar3, "cell 4 0 1 4,growy");
add(progressBar3, "cell 4 0 1 6,growy");
//---- progressBar4 ----
progressBar4.setOrientation(SwingConstants.VERTICAL);
progressBar4.setValue(55);
progressBar4.setStringPainted(true);
add(progressBar4, "cell 4 0 1 4,growy");
add(progressBar4, "cell 4 0 1 6,growy");
//======== toolBar2 ========
{
@@ -178,7 +193,7 @@ class MoreComponentsPanel
toggleButton7.setIcon(UIManager.getIcon("Tree.closedIcon"));
toolBar2.add(toggleButton7);
}
add(toolBar2, "cell 4 0 1 4,growy");
add(toolBar2, "cell 4 0 1 6,growy");
//---- scrollBarLabel ----
scrollBarLabel.setText("JScrollBar:");
@@ -193,30 +208,41 @@ class MoreComponentsPanel
scrollBar4.setEnabled(false);
add(scrollBar4, "cell 1 2,growx");
//---- scrollBar5 ----
scrollBar5.setOrientation(Adjustable.HORIZONTAL);
scrollBar5.putClientProperty("JScrollBar.showButtons", true);
add(scrollBar5, "cell 1 3,growx");
//---- scrollBar6 ----
scrollBar6.setOrientation(Adjustable.HORIZONTAL);
scrollBar6.setEnabled(false);
scrollBar6.putClientProperty("JScrollBar.showButtons", true);
add(scrollBar6, "cell 1 4,growx");
//---- separatorLabel ----
separatorLabel.setText("JSeparator:");
add(separatorLabel, "cell 0 3");
add(separator1, "cell 1 3,growx");
add(separatorLabel, "cell 0 5");
add(separator1, "cell 1 5,growx");
//======== panel2 ========
{
panel2.setBorder(new TitledBorder("TitledBorder"));
panel2.setLayout(new FlowLayout());
}
add(panel2, "cell 3 3,grow");
add(panel2, "cell 3 5,grow");
//---- sliderLabel ----
sliderLabel.setText("JSlider:");
add(sliderLabel, "cell 0 4");
add(sliderLabel, "cell 0 6");
//---- slider1 ----
slider1.setValue(30);
add(slider1, "cell 1 4 3 1,aligny top,grow 100 0");
add(slider1, "cell 1 6 3 1,aligny top,grow 100 0");
//---- slider6 ----
slider6.setEnabled(false);
slider6.setValue(30);
add(slider6, "cell 1 4 3 1,aligny top,growy 0");
add(slider6, "cell 1 6 3 1,aligny top,growy 0");
//---- slider3 ----
slider3.setMinorTickSpacing(10);
@@ -224,7 +250,7 @@ class MoreComponentsPanel
slider3.setMajorTickSpacing(50);
slider3.setPaintLabels(true);
slider3.setValue(30);
add(slider3, "cell 1 5 3 1,aligny top,grow 100 0");
add(slider3, "cell 1 7 3 1,aligny top,grow 100 0");
//---- slider5 ----
slider5.setMinorTickSpacing(10);
@@ -233,41 +259,41 @@ class MoreComponentsPanel
slider5.setPaintLabels(true);
slider5.setEnabled(false);
slider5.setValue(30);
add(slider5, "cell 1 5 3 1,aligny top,growy 0");
add(slider5, "cell 1 7 3 1,aligny top,growy 0");
//---- progressBarLabel ----
progressBarLabel.setText("JProgressBar:");
add(progressBarLabel, "cell 0 6");
add(progressBarLabel, "cell 0 8");
//---- progressBar1 ----
progressBar1.setValue(50);
add(progressBar1, "cell 1 6 3 1,growx");
add(progressBar1, "cell 1 8 3 1,growx");
//---- progressBar2 ----
progressBar2.setStringPainted(true);
progressBar2.setValue(55);
add(progressBar2, "cell 1 6 3 1,growx");
add(progressBar2, "cell 1 8 3 1,growx");
//---- indeterminateCheckBox ----
indeterminateCheckBox.setText("indeterminate");
indeterminateCheckBox.addActionListener(e -> indeterminateCheckBoxActionPerformed());
add(indeterminateCheckBox, "cell 4 6");
add(indeterminateCheckBox, "cell 4 8");
//---- toolTipLabel ----
toolTipLabel.setText("JToolTip:");
add(toolTipLabel, "cell 0 7");
add(toolTipLabel, "cell 0 9");
//---- toolTip1 ----
toolTip1.setTipText("Some text in tool tip.");
add(toolTip1, "cell 1 7 3 1");
add(toolTip1, "cell 1 9 3 1");
//---- toolTip2 ----
toolTip2.setTipText("Tool tip with\nmultiple\nlines.");
add(toolTip2, "cell 1 7 3 1");
add(toolTip2, "cell 1 9 3 1");
//---- toolBarLabel ----
toolBarLabel.setText("JToolBar:");
add(toolBarLabel, "cell 0 8");
add(toolBarLabel, "cell 0 10");
//======== toolBar1 ========
{
@@ -297,7 +323,7 @@ class MoreComponentsPanel
toggleButton6.setSelected(true);
toolBar1.add(toggleButton6);
}
add(toolBar1, "cell 1 8 3 1,growx");
add(toolBar1, "cell 1 10 3 1,growx");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}

View File

@@ -9,7 +9,7 @@ new FormModel {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "hidemode 3"
"$columnConstraints": "[][][][][][]"
"$rowConstraints": "[][][][][][][][][]"
"$rowConstraints": "[][][][][][][][][][][]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
@@ -32,26 +32,39 @@ new FormModel {
add( new FormComponent( "javax.swing.JScrollBar" ) {
name: "scrollBar2"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0 1 4,growy"
"value": "cell 2 0 1 6,growy"
} )
add( new FormComponent( "javax.swing.JScrollBar" ) {
name: "scrollBar3"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0 1 4,growy"
"value": "cell 2 0 1 6,growy"
} )
add( new FormComponent( "javax.swing.JScrollBar" ) {
name: "scrollBar7"
"$client.JScrollBar.showButtons": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0 1 6,growy"
} )
add( new FormComponent( "javax.swing.JScrollBar" ) {
name: "scrollBar8"
"enabled": false
"$client.JScrollBar.showButtons": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0 1 6,growy"
} )
add( new FormComponent( "javax.swing.JSeparator" ) {
name: "separator2"
"orientation": 1
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0 1 4,growy"
"value": "cell 2 0 1 6,growy"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider2"
"orientation": 1
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0 1 4,growy"
"value": "cell 2 0 1 6,growy"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider4"
@@ -62,7 +75,7 @@ new FormModel {
"orientation": 1
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0 1 4,growy"
"value": "cell 2 0 1 6,growy"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane14"
@@ -77,7 +90,7 @@ new FormModel {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 0 1 4,growy"
"value": "cell 4 0 1 6,growy"
} )
add( new FormComponent( "javax.swing.JProgressBar" ) {
name: "progressBar4"
@@ -88,7 +101,7 @@ new FormModel {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 0 1 4,growy"
"value": "cell 4 0 1 6,growy"
} )
add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
name: "toolBar2"
@@ -113,7 +126,7 @@ new FormModel {
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 0 1 4,growy"
"value": "cell 4 0 1 6,growy"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "scrollBarLabel"
@@ -134,41 +147,56 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2,growx"
} )
add( new FormComponent( "javax.swing.JScrollBar" ) {
name: "scrollBar5"
"orientation": 0
"$client.JScrollBar.showButtons": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3,growx"
} )
add( new FormComponent( "javax.swing.JScrollBar" ) {
name: "scrollBar6"
"orientation": 0
"enabled": false
"$client.JScrollBar.showButtons": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "separatorLabel"
"text": "JSeparator:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
"value": "cell 0 5"
} )
add( new FormComponent( "javax.swing.JSeparator" ) {
name: "separator1"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3,growx"
"value": "cell 1 5,growx"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel2"
"border": new javax.swing.border.TitledBorder( "TitledBorder" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 3,grow"
"value": "cell 3 5,grow"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "sliderLabel"
"text": "JSlider:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
"value": "cell 0 6"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider1"
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 3 1,aligny top,grow 100 0"
"value": "cell 1 6 3 1,aligny top,grow 100 0"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider6"
"enabled": false
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 3 1,aligny top,growy 0"
"value": "cell 1 6 3 1,aligny top,growy 0"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider3"
@@ -178,7 +206,7 @@ new FormModel {
"paintLabels": true
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5 3 1,aligny top,grow 100 0"
"value": "cell 1 7 3 1,aligny top,grow 100 0"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider5"
@@ -189,13 +217,13 @@ new FormModel {
"enabled": false
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5 3 1,aligny top,growy 0"
"value": "cell 1 7 3 1,aligny top,growy 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "progressBarLabel"
"text": "JProgressBar:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
"value": "cell 0 8"
} )
add( new FormComponent( "javax.swing.JProgressBar" ) {
name: "progressBar1"
@@ -204,7 +232,7 @@ new FormModel {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6 3 1,growx"
"value": "cell 1 8 3 1,growx"
} )
add( new FormComponent( "javax.swing.JProgressBar" ) {
name: "progressBar2"
@@ -214,7 +242,7 @@ new FormModel {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6 3 1,growx"
"value": "cell 1 8 3 1,growx"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "indeterminateCheckBox"
@@ -224,31 +252,31 @@ new FormModel {
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "indeterminateCheckBoxActionPerformed", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 6"
"value": "cell 4 8"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "toolTipLabel"
"text": "JToolTip:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7"
"value": "cell 0 9"
} )
add( new FormComponent( "javax.swing.JToolTip" ) {
name: "toolTip1"
"tipText": "Some text in tool tip."
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7 3 1"
"value": "cell 1 9 3 1"
} )
add( new FormComponent( "javax.swing.JToolTip" ) {
name: "toolTip2"
"tipText": "Tool tip with\nmultiple\nlines."
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7 3 1"
"value": "cell 1 9 3 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "toolBarLabel"
"text": "JToolBar:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8"
"value": "cell 0 10"
} )
add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
name: "toolBar1"
@@ -282,7 +310,7 @@ new FormModel {
"selected": true
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 8 3 1,growx"
"value": "cell 1 10 3 1,growx"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )