summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-08-16 00:31:19 +0000
committerRoman Kennke <roman@kennke.org>2006-08-16 00:31:19 +0000
commit481caf28e9fc9d889da795619f7cb51e91daf829 (patch)
treebb0f22cd16d6443188995da0ab6a66b1a0cae8fc /examples
parent51f09e9b69f9d887a9a04fc16730c7e1ac9db622 (diff)
downloadclasspath-481caf28e9fc9d889da795619f7cb51e91daf829.tar.gz
2006-08-16 Roman Kennke <kennke@aicas.com>
* javax/swing/plaf/metal/MetalTreeUI.java (LineStyleListener): New property listener, that updates the line style setting if the corresponding property changes. (lineStyleListener): New field. (lineStyle): New field. (LINE_STYLE_ANGLED): New constant field. (LINE_STYLE_HORIZONTAL): New constant field. (LINE_STYLE_NONE): New constant field. (LINE_STYLE_VALUE_ANGLED): New constant field. (LINE_STYLE_VALUE_HORIZONTAL): New constant field. (LINE_STYLE_VALUE_NONE): New constant field. (LINE_STYLE_PROPERTY): New constant field. (decodeLineStyle): Implemented. (installUI): Install line style listener. Set initial lineStyle. (uninstallUI): Uninstall line style listener. (paintHorizontalPartOfLeg): Only call super for angled lineStyle. (paintVerticalPartOfLeg): Only call super for angled lineStyle. (paintHorizontalSeparators): Implemented. (paint): If lineStyle==HORIZONTAL, call paintHorizontalSeparators(). * examples/gnu/classpath/examples/swing/TreeDemo.java (createContent): Add panel for selecting line styles.
Diffstat (limited to 'examples')
-rw-r--r--examples/gnu/classpath/examples/swing/TreeDemo.java35
1 files changed, 31 insertions, 4 deletions
diff --git a/examples/gnu/classpath/examples/swing/TreeDemo.java b/examples/gnu/classpath/examples/swing/TreeDemo.java
index 32f765f73..8da375071 100644
--- a/examples/gnu/classpath/examples/swing/TreeDemo.java
+++ b/examples/gnu/classpath/examples/swing/TreeDemo.java
@@ -39,17 +39,17 @@ exception statement from your version. */
package gnu.classpath.examples.swing;
import java.awt.BorderLayout;
-import java.awt.JobAttributes.DefaultSelectionType;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import javax.swing.DebugGraphics;
+import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
+import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
@@ -59,7 +59,6 @@ import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultTreeSelectionModel;
import javax.swing.tree.TreePath;
-import javax.swing.tree.TreeSelectionModel;
public class TreeDemo
extends JPanel
@@ -222,11 +221,39 @@ public class TreeDemo
p2.add(add);
p2.add(cbSingle);
p2.add(cbRoot);
-
+
tree.getSelectionModel().
setSelectionMode(DefaultTreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
+ // Panel for selecting line style.
+ ActionListener l = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ JRadioButton b = (JRadioButton) e.getSource();
+ tree.putClientProperty("JTree.lineStyle", b.getText());
+ tree.repaint();
+ }
+ };
+ JPanel lineStylePanel = new JPanel();
+ ButtonGroup buttons = new ButtonGroup();
+ lineStylePanel.add(new JLabel("Line style: "));
+ JRadioButton none = new JRadioButton("None");
+ lineStylePanel.add(none);
+ buttons.add(none);
+ none.addActionListener(l);
+ JRadioButton angled = new JRadioButton("Angled");
+ lineStylePanel.add(angled);
+ buttons.add(angled);
+ angled.addActionListener(l);
+ JRadioButton horizontal = new JRadioButton("Horizontal");
+ lineStylePanel.add(horizontal);
+ buttons.add(horizontal);
+ horizontal.addActionListener(l);
+ p2.add(lineStylePanel);
+
add(p2, BorderLayout.NORTH);
+
add(new JScrollPane(tree), BorderLayout.CENTER);
add(choice, BorderLayout.SOUTH);
}