Tree: hide default closed/opened/leaf icons by default

This commit is contained in:
Karl Tauber
2022-11-14 14:21:28 +01:00
parent 2be2dae3d6
commit b736502c27
11 changed files with 49 additions and 2 deletions

View File

@@ -495,6 +495,13 @@ public class FlatComponents2Test
tree.setEditable( editable );
}
private void showDefaultIcons() {
boolean showDefaultIcons = showDefaultIconsCheckBox.isSelected();
UIManager.put( "Tree.showDefaultIcons", showDefaultIcons ? true : null );
for( JTree tree : allTrees )
tree.updateUI();
}
private void treeMouseClicked( MouseEvent e ) {
JTree tree = (JTree) e.getSource();
int x = e.getX();
@@ -594,6 +601,7 @@ public class FlatComponents2Test
treePaintLinesCheckBox = new JCheckBox();
treeRedLinesCheckBox = new JCheckBox();
treeEditableCheckBox = new JCheckBox();
showDefaultIconsCheckBox = new JCheckBox();
JPanel tableOptionsPanel = new JPanel();
JLabel autoResizeModeLabel = new JLabel();
autoResizeModeField = new JComboBox<>();
@@ -754,7 +762,6 @@ public class FlatComponents2Test
//---- tree1 ----
tree1.setShowsRootHandles(true);
tree1.setEditable(true);
tree1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@@ -980,6 +987,11 @@ public class FlatComponents2Test
treeEditableCheckBox.setText("editable");
treeEditableCheckBox.addActionListener(e -> treeEditableChanged());
treeOptionsPanel.add(treeEditableCheckBox, "cell 0 4");
//---- showDefaultIconsCheckBox ----
showDefaultIconsCheckBox.setText("show default icons");
showDefaultIconsCheckBox.addActionListener(e -> showDefaultIcons());
treeOptionsPanel.add(showDefaultIconsCheckBox, "cell 0 4");
}
add(treeOptionsPanel, "cell 0 4 4 1");
@@ -1116,6 +1128,7 @@ public class FlatComponents2Test
private JCheckBox treePaintLinesCheckBox;
private JCheckBox treeRedLinesCheckBox;
private JCheckBox treeEditableCheckBox;
private JCheckBox showDefaultIconsCheckBox;
private JComboBox<String> autoResizeModeField;
private JComboBox<String> sortIconPositionComboBox;
private JCheckBox showHorizontalLinesCheckBox;

View File

@@ -184,7 +184,6 @@ new FormModel {
add( new FormComponent( "javax.swing.JTree" ) {
name: "tree1"
"showsRootHandles": true
"editable": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -476,6 +475,16 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "showDefaultIconsCheckBox"
"text": "show default icons"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showDefaultIcons", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4 4 1"
} )