mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 06:50:56 +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() {
|
||||
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.getHorizontalScrollBar().addAdjustmentListener( new AdjustmentHandler( "list horz" ) );
|
||||
|
||||
@@ -119,6 +128,10 @@ public class FlatSmoothScrollingTest
|
||||
textArea.setText( text );
|
||||
textPane.setText( text );
|
||||
editorPane.setText( text );
|
||||
|
||||
textArea.select( 0, 0 );
|
||||
textPane.select( 0, 0 );
|
||||
editorPane.select( 0, 0 );
|
||||
}
|
||||
|
||||
private void smoothScrollingChanged() {
|
||||
@@ -165,6 +178,7 @@ public class FlatSmoothScrollingTest
|
||||
//---- smoothScrollingCheckBox ----
|
||||
smoothScrollingCheckBox.setText("Smooth scrolling");
|
||||
smoothScrollingCheckBox.setSelected(true);
|
||||
smoothScrollingCheckBox.setMnemonic('S');
|
||||
smoothScrollingCheckBox.addActionListener(e -> smoothScrollingChanged());
|
||||
add(smoothScrollingCheckBox, "cell 0 0,alignx left,growx 0");
|
||||
|
||||
@@ -188,16 +202,6 @@ public class FlatSmoothScrollingTest
|
||||
|
||||
//======== treeScrollPane ========
|
||||
{
|
||||
|
||||
//---- tree ----
|
||||
tree.setModel(new DefaultTreeModel(
|
||||
new DefaultMutableTreeNode("root") {
|
||||
{
|
||||
add(new DefaultMutableTreeNode("a"));
|
||||
add(new DefaultMutableTreeNode("b"));
|
||||
add(new DefaultMutableTreeNode("c"));
|
||||
}
|
||||
}));
|
||||
treeScrollPane.setViewportView(tree);
|
||||
}
|
||||
add(treeScrollPane, "cell 1 2");
|
||||
@@ -306,7 +310,7 @@ public class FlatSmoothScrollingTest
|
||||
@Override
|
||||
public Point getViewPosition() {
|
||||
Point viewPosition = super.getViewPosition();
|
||||
System.out.println( " viewPosition " + viewPosition.x + "," + viewPosition.y );
|
||||
// System.out.println( " viewPosition " + viewPosition.x + "," + viewPosition.y );
|
||||
return viewPosition;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ new FormModel {
|
||||
name: "smoothScrollingCheckBox"
|
||||
"text": "Smooth scrolling"
|
||||
"selected": true
|
||||
"mnemonic": 83
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "smoothScrollingChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,alignx left,growx 0"
|
||||
@@ -51,18 +52,6 @@ new FormModel {
|
||||
name: "treeScrollPane"
|
||||
add( new FormComponent( "javax.swing.JTree" ) {
|
||||
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 ) {
|
||||
"value": "cell 1 2"
|
||||
|
||||
Reference in New Issue
Block a user