mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 15:00:54 +03:00
FlatSmoothScrollingTest: allow enabling/disabling smooth scrolling with Alt+S without moving focus to checkbox; removed unused tree model
This commit is contained in:
@@ -44,6 +44,15 @@ public class FlatSmoothScrollingTest
|
|||||||
FlatSmoothScrollingTest() {
|
FlatSmoothScrollingTest() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
|
// allow enabling/disabling smooth scrolling with Alt+S without moving focus to checkbox
|
||||||
|
registerKeyboardAction(
|
||||||
|
e -> {
|
||||||
|
smoothScrollingCheckBox.setSelected( !smoothScrollingCheckBox.isSelected() );
|
||||||
|
smoothScrollingChanged();
|
||||||
|
},
|
||||||
|
KeyStroke.getKeyStroke( "alt " + (char) smoothScrollingCheckBox.getMnemonic() ),
|
||||||
|
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
||||||
|
|
||||||
listScrollPane.getVerticalScrollBar().addAdjustmentListener( new AdjustmentHandler( "list vert" ) );
|
listScrollPane.getVerticalScrollBar().addAdjustmentListener( new AdjustmentHandler( "list vert" ) );
|
||||||
listScrollPane.getHorizontalScrollBar().addAdjustmentListener( new AdjustmentHandler( "list horz" ) );
|
listScrollPane.getHorizontalScrollBar().addAdjustmentListener( new AdjustmentHandler( "list horz" ) );
|
||||||
|
|
||||||
@@ -119,6 +128,10 @@ public class FlatSmoothScrollingTest
|
|||||||
textArea.setText( text );
|
textArea.setText( text );
|
||||||
textPane.setText( text );
|
textPane.setText( text );
|
||||||
editorPane.setText( text );
|
editorPane.setText( text );
|
||||||
|
|
||||||
|
textArea.select( 0, 0 );
|
||||||
|
textPane.select( 0, 0 );
|
||||||
|
editorPane.select( 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void smoothScrollingChanged() {
|
private void smoothScrollingChanged() {
|
||||||
@@ -165,6 +178,7 @@ public class FlatSmoothScrollingTest
|
|||||||
//---- smoothScrollingCheckBox ----
|
//---- smoothScrollingCheckBox ----
|
||||||
smoothScrollingCheckBox.setText("Smooth scrolling");
|
smoothScrollingCheckBox.setText("Smooth scrolling");
|
||||||
smoothScrollingCheckBox.setSelected(true);
|
smoothScrollingCheckBox.setSelected(true);
|
||||||
|
smoothScrollingCheckBox.setMnemonic('S');
|
||||||
smoothScrollingCheckBox.addActionListener(e -> smoothScrollingChanged());
|
smoothScrollingCheckBox.addActionListener(e -> smoothScrollingChanged());
|
||||||
add(smoothScrollingCheckBox, "cell 0 0,alignx left,growx 0");
|
add(smoothScrollingCheckBox, "cell 0 0,alignx left,growx 0");
|
||||||
|
|
||||||
@@ -188,16 +202,6 @@ public class FlatSmoothScrollingTest
|
|||||||
|
|
||||||
//======== treeScrollPane ========
|
//======== treeScrollPane ========
|
||||||
{
|
{
|
||||||
|
|
||||||
//---- tree ----
|
|
||||||
tree.setModel(new DefaultTreeModel(
|
|
||||||
new DefaultMutableTreeNode("root") {
|
|
||||||
{
|
|
||||||
add(new DefaultMutableTreeNode("a"));
|
|
||||||
add(new DefaultMutableTreeNode("b"));
|
|
||||||
add(new DefaultMutableTreeNode("c"));
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
treeScrollPane.setViewportView(tree);
|
treeScrollPane.setViewportView(tree);
|
||||||
}
|
}
|
||||||
add(treeScrollPane, "cell 1 2");
|
add(treeScrollPane, "cell 1 2");
|
||||||
@@ -306,7 +310,7 @@ public class FlatSmoothScrollingTest
|
|||||||
@Override
|
@Override
|
||||||
public Point getViewPosition() {
|
public Point getViewPosition() {
|
||||||
Point viewPosition = super.getViewPosition();
|
Point viewPosition = super.getViewPosition();
|
||||||
System.out.println( " viewPosition " + viewPosition.x + "," + viewPosition.y );
|
// System.out.println( " viewPosition " + viewPosition.x + "," + viewPosition.y );
|
||||||
return viewPosition;
|
return viewPosition;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ new FormModel {
|
|||||||
name: "smoothScrollingCheckBox"
|
name: "smoothScrollingCheckBox"
|
||||||
"text": "Smooth scrolling"
|
"text": "Smooth scrolling"
|
||||||
"selected": true
|
"selected": true
|
||||||
|
"mnemonic": 83
|
||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "smoothScrollingChanged", false ) )
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "smoothScrollingChanged", false ) )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 0,alignx left,growx 0"
|
"value": "cell 0 0,alignx left,growx 0"
|
||||||
@@ -51,18 +52,6 @@ new FormModel {
|
|||||||
name: "treeScrollPane"
|
name: "treeScrollPane"
|
||||||
add( new FormComponent( "javax.swing.JTree" ) {
|
add( new FormComponent( "javax.swing.JTree" ) {
|
||||||
name: "tree"
|
name: "tree"
|
||||||
"model": new javax.swing.tree.DefaultTreeModel( new javax.swing.tree.DefaultMutableTreeNode {
|
|
||||||
userObject: "root"
|
|
||||||
add( new javax.swing.tree.DefaultMutableTreeNode {
|
|
||||||
userObject: "a"
|
|
||||||
} )
|
|
||||||
add( new javax.swing.tree.DefaultMutableTreeNode {
|
|
||||||
userObject: "b"
|
|
||||||
} )
|
|
||||||
add( new javax.swing.tree.DefaultMutableTreeNode {
|
|
||||||
userObject: "c"
|
|
||||||
} )
|
|
||||||
} )
|
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 2"
|
"value": "cell 1 2"
|
||||||
|
|||||||
Reference in New Issue
Block a user