15 changed files with 16 additions and 2295 deletions
			
			
		
								
									Binary file not shown.
								
							
						
					
								
									Binary file not shown.
								
							
						
					
								
									Binary file not shown.
								
							
						
					
								
									Binary file not shown.
								
							
						
					| @ -1,3 +1,3 @@ | |||
| Manifest-Version: 1.0 | |||
| Main-Class: com.insigma.utils.OsTest | |||
| Main-Class: com.insigma.HyToolApplication | |||
| 
 | |||
|  | |||
| @ -1,369 +0,0 @@ | |||
| package com.insigma.demos; | |||
| 
 | |||
| import java.awt.BorderLayout; | |||
| import java.awt.Dimension; | |||
| import java.util.MissingResourceException; | |||
| import java.util.ResourceBundle; | |||
| 
 | |||
| import javax.swing.BorderFactory; | |||
| import javax.swing.BoxLayout; | |||
| import javax.swing.Icon; | |||
| import javax.swing.ImageIcon; | |||
| import javax.swing.JApplet; | |||
| import javax.swing.JFrame; | |||
| import javax.swing.JPanel; | |||
| import javax.swing.UIManager; | |||
| import javax.swing.border.Border; | |||
| import javax.swing.border.EmptyBorder; | |||
| 
 | |||
| import org.jb2011.lnf.beautyeye.widget.N9ComponentFactory; | |||
| 
 | |||
| /** | |||
|  * A generic SwingSet2 demo module. | |||
|  * | |||
|  * @author Jeff Dinkins | |||
|  * @version 1.23 11/17/05 | |||
|  */ | |||
| public class DemoModule extends JApplet { | |||
| 
 | |||
|     /** | |||
|      * The PREFERRE d_ width. | |||
|      */ | |||
|     private int PREFERRED_WIDTH = 680; | |||
| 
 | |||
|     /** | |||
|      * The PREFERRE d_ height. | |||
|      */ | |||
|     private int PREFERRED_HEIGHT = 600; | |||
| 
 | |||
|     /** | |||
|      * The lowered border. | |||
|      */ | |||
|     Border loweredBorder = new EmptyBorder(15, 10, 5, 10); | |||
| 
 | |||
|     /** | |||
|      * The HGA p2. | |||
|      */ | |||
|     public static Dimension HGAP2 = new Dimension(2, 1); | |||
| 
 | |||
|     /** | |||
|      * The VGA p2. | |||
|      */ | |||
|     public static Dimension VGAP2 = new Dimension(1, 2); | |||
| 
 | |||
|     /** | |||
|      * The HGA p5. | |||
|      */ | |||
|     public static Dimension HGAP5 = new Dimension(5, 1); | |||
| 
 | |||
|     /** | |||
|      * The VGA p5. | |||
|      */ | |||
|     public static Dimension VGAP5 = new Dimension(1, 5); | |||
| 
 | |||
|     /** | |||
|      * The HGA p10. | |||
|      */ | |||
|     public static Dimension HGAP10 = new Dimension(10, 1); | |||
| 
 | |||
|     /** | |||
|      * The VGA p10. | |||
|      */ | |||
|     public static Dimension VGAP10 = new Dimension(1, 10); | |||
| 
 | |||
|     /** | |||
|      * The HGA p15. | |||
|      */ | |||
|     public static Dimension HGAP15 = new Dimension(15, 1); | |||
| 
 | |||
|     /** | |||
|      * The VGA p15. | |||
|      */ | |||
|     public static Dimension VGAP15 = new Dimension(1, 15); | |||
| 
 | |||
|     /** | |||
|      * The HGA p20. | |||
|      */ | |||
|     public static Dimension HGAP20 = new Dimension(20, 1); | |||
| 
 | |||
|     /** | |||
|      * The VGA p20. | |||
|      */ | |||
|     public static Dimension VGAP20 = new Dimension(1, 20); | |||
| 
 | |||
|     /** | |||
|      * The HGA p25. | |||
|      */ | |||
|     public static Dimension HGAP25 = new Dimension(25, 1); | |||
| 
 | |||
|     /** | |||
|      * The VGA p25. | |||
|      */ | |||
|     public static Dimension VGAP25 = new Dimension(1, 25); | |||
| 
 | |||
|     /** | |||
|      * The HGA p30. | |||
|      */ | |||
|     public static Dimension HGAP30 = new Dimension(30, 1); | |||
| 
 | |||
|     /** | |||
|      * The VGA p30. | |||
|      */ | |||
|     public static Dimension VGAP30 = new Dimension(1, 30); | |||
| 
 | |||
|     /** | |||
|      * The swingset. | |||
|      */ | |||
|     private SwingSet2 swingset = null; | |||
| 
 | |||
|     /** | |||
|      * The panel. | |||
|      */ | |||
|     private JPanel panel = null; | |||
| 
 | |||
|     /** | |||
|      * The resource name. | |||
|      */ | |||
|     private String resourceName = null; | |||
| 
 | |||
|     /** | |||
|      * The icon path. | |||
|      */ | |||
|     private String iconPath = null; | |||
| 
 | |||
|     /** | |||
|      * The source code. | |||
|      */ | |||
|     private String sourceCode = null; | |||
| 
 | |||
|     // Resource bundle for internationalized and accessible text
 | |||
|     /** | |||
|      * The bundle. | |||
|      */ | |||
|     private ResourceBundle bundle = null; | |||
| 
 | |||
|     /** | |||
|      * Instantiates a new demo module. | |||
|      * | |||
|      * @param swingset the swingset | |||
|      */ | |||
|     public DemoModule(SwingSet2 swingset) { | |||
|         this(swingset, null, null); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Instantiates a new demo module. | |||
|      * | |||
|      * @param swingset     the swingset | |||
|      * @param resourceName the resource name | |||
|      * @param iconPath     the icon path | |||
|      */ | |||
|     public DemoModule(SwingSet2 swingset, String resourceName, String iconPath) { | |||
|         UIManager.put("swing.boldMetal", Boolean.FALSE); | |||
|         panel = new JPanel(); | |||
| 
 | |||
|         panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5)); | |||
|         panel.setLayout(new BorderLayout()); | |||
| 
 | |||
|         this.resourceName = resourceName; | |||
|         this.iconPath = iconPath; | |||
|         this.swingset = swingset; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Gets the resource name. | |||
|      * | |||
|      * @return the resource name | |||
|      */ | |||
|     public String getResourceName() { | |||
|         return resourceName; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Gets the demo panel. | |||
|      * | |||
|      * @return the demo panel | |||
|      */ | |||
|     public JPanel getDemoPanel() { | |||
|         return panel; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Gets the swing set2. | |||
|      * | |||
|      * @return the swing set2 | |||
|      */ | |||
|     public SwingSet2 getSwingSet2() { | |||
|         return swingset; | |||
|     } | |||
| 
 | |||
| 
 | |||
|     /** | |||
|      * Gets the string. | |||
|      * | |||
|      * @param key the key | |||
|      * @return the string | |||
|      */ | |||
|     public String getString(String key) { | |||
|         String value = "nada"; | |||
|         if (bundle == null) { | |||
|             if (getSwingSet2() != null) { | |||
|                 bundle = getSwingSet2().getResourceBundle(); | |||
|             } else { | |||
|                 bundle = ResourceBundle.getBundle("language.swingset"); | |||
|             } | |||
|         } | |||
|         try { | |||
|             value = bundle.getString(key); | |||
|         } catch (MissingResourceException e) { | |||
|             System.out.println("java.util.MissingResourceException: Couldn't find value for: " + key); | |||
|         } | |||
|         return value; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Gets the mnemonic. | |||
|      * | |||
|      * @param key the key | |||
|      * @return the mnemonic | |||
|      */ | |||
|     public char getMnemonic(String key) { | |||
|         return (getString(key)).charAt(0); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Creates the image icon. | |||
|      * | |||
|      * @param filename    the filename | |||
|      * @param description the description | |||
|      * @return the image icon | |||
|      */ | |||
|     public ImageIcon createImageIcon(String filename, String description) { | |||
|         if (getSwingSet2() != null) { | |||
|             return getSwingSet2().createImageIcon(filename, description); | |||
|         } else { | |||
|             String path = "/static/images/" + filename; | |||
|             return new ImageIcon(getClass().getResource(path), description); | |||
|         } | |||
|     } | |||
| 
 | |||
| 
 | |||
|     /** | |||
|      * Gets the source code. | |||
|      * | |||
|      * @return the source code | |||
|      */ | |||
|     public String getSourceCode() { | |||
|         return sourceCode; | |||
|     } | |||
| 
 | |||
|     /* (non-Javadoc) | |||
|      * @see java.awt.Component#getName() | |||
|      */ | |||
|     @Override | |||
|     public String getName() { | |||
|         return getString(getResourceName() + ".name"); | |||
|     } | |||
| 
 | |||
|     ; | |||
| 
 | |||
|     /** | |||
|      * Gets the icon. | |||
|      * | |||
|      * @return the icon | |||
|      */ | |||
|     public Icon getIcon() { | |||
|         return createImageIcon(iconPath, getResourceName() + ".name"); | |||
|     } | |||
| 
 | |||
|     ; | |||
| 
 | |||
|     /** | |||
|      * Gets the tool tip. | |||
|      * | |||
|      * @return the tool tip | |||
|      */ | |||
|     public String getToolTip() { | |||
|         return getString(getResourceName() + ".tooltip"); | |||
|     } | |||
| 
 | |||
|     ; | |||
| 
 | |||
|     /** | |||
|      * Main impl. | |||
|      */ | |||
|     public void mainImpl() { | |||
|         JFrame frame = new JFrame(getName()); | |||
|         frame.getContentPane().setLayout(new BorderLayout()); | |||
|         frame.getContentPane().add(getDemoPanel(), BorderLayout.CENTER); | |||
|         getDemoPanel().setPreferredSize(new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT)); | |||
|         frame.pack(); | |||
|         frame.show(); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Creates the horizontal panel. | |||
|      * | |||
|      * @param threeD the three d | |||
|      * @return the j panel | |||
|      */ | |||
|     public JPanel createHorizontalPanel(boolean threeD) { | |||
|         JPanel p = N9ComponentFactory.createPanel_style1(null).setDrawBg(threeD);//modified by jb2011
 | |||
|         p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); | |||
|         p.setAlignmentY(TOP_ALIGNMENT); | |||
|         p.setAlignmentX(LEFT_ALIGNMENT); | |||
|         if (threeD) { | |||
|             p.setBorder(loweredBorder); | |||
|         } | |||
|         //因背景是白色N9图,这里设置它不填充默认背景好看一点,要不然灰色背景出来就不好看了
 | |||
|         p.setOpaque(false);//add by jb2011 2012-08-24
 | |||
|         return p; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Creates the vertical panel. | |||
|      * | |||
|      * @param threeD the three d | |||
|      * @return the j panel | |||
|      */ | |||
|     public JPanel createVerticalPanel(boolean threeD) { | |||
|         JPanel p = N9ComponentFactory.createPanel_style1(null).setDrawBg(threeD);//modified by jb2011
 | |||
|         p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); | |||
|         p.setAlignmentY(TOP_ALIGNMENT); | |||
|         p.setAlignmentX(LEFT_ALIGNMENT); | |||
|         if (threeD) { | |||
|             p.setBorder(loweredBorder); | |||
|         } | |||
|         return p; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * The main method. | |||
|      * | |||
|      * @param args the arguments | |||
|      */ | |||
|     public static void main(String[] args) { | |||
|         DemoModule demo = new DemoModule(null); | |||
|         demo.mainImpl(); | |||
|     } | |||
| 
 | |||
|     /* (non-Javadoc) | |||
|      * @see java.applet.Applet#init() | |||
|      */ | |||
|     @Override | |||
|     public void init() { | |||
|         getContentPane().setLayout(new BorderLayout()); | |||
|         getContentPane().add(getDemoPanel(), BorderLayout.CENTER); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Update drag enabled. | |||
|      * | |||
|      * @param dragEnabled the drag enabled | |||
|      */ | |||
|     void updateDragEnabled(boolean dragEnabled) { | |||
|     } | |||
| 
 | |||
| 
 | |||
| } | |||
| 
 | |||
								
									
										File diff suppressed because it is too large
									
								
							
						
					| @ -1,47 +0,0 @@ | |||
| /* | |||
|  * Copyright (C) 2015 Jack Jiang(cngeeker.com) The BeautyEye Project.  | |||
|  * All rights reserved. | |||
|  * Project URL:https://github.com/JackJiang2011/beautyeye
 | |||
|  * Version 3.6 | |||
|  *  | |||
|  * Jack Jiang PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. | |||
|  *  | |||
|  * SwingSet2Applet.java at 2015-2-1 20:25:39, original version by Jack Jiang. | |||
|  * You can contact author with jb2011@163.com. | |||
|  */ | |||
| 
 | |||
| /* | |||
|  * @(#)SwingSet2Applet.java	1.10 05/11/17 | |||
|  */ | |||
| 
 | |||
| package com.insigma.demos; | |||
| 
 | |||
| import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper; | |||
| 
 | |||
| import javax.swing.*; | |||
| import java.awt.*; | |||
| import java.net.URL; | |||
| 
 | |||
| // TODO: Auto-generated Javadoc
 | |||
| 
 | |||
| /** | |||
|  * The Class SwingSet2Applet. | |||
|  * | |||
|  * @version 1.10 11/17/05 | |||
|  * @author Jeff Dinkins | |||
|  */ | |||
| 
 | |||
| public class SwingSet2Applet extends JApplet { | |||
| 
 | |||
|     @Override | |||
|     public void init() { | |||
|     	try { | |||
|     		BeautyEyeLNFHelper.launchBeautyEyeLNF(); | |||
| 		} catch (Exception e) { | |||
| 			System.err.println("BeautyEyeLNF运行失败,原因是:"+e.getMessage()); | |||
| 		} | |||
|     	 | |||
|         getContentPane().setLayout(new BorderLayout()); | |||
|         getContentPane().add(new SwingSet2(this), BorderLayout.CENTER); | |||
|     } | |||
| } | |||
| @ -1,187 +0,0 @@ | |||
| package com.insigma.demos; | |||
| 
 | |||
| import javax.accessibility.AccessibleContext; | |||
| import javax.swing.*; | |||
| import java.awt.*; | |||
| import java.awt.event.ActionEvent; | |||
| 
 | |||
| public class TextAreaDemo extends DemoModule { | |||
| 
 | |||
|     /** | |||
|      * main method allows us to run as a standalone demo. | |||
|      * | |||
|      * @param args the arguments | |||
|      */ | |||
|     public static void main(String[] args) { | |||
|     //初始化样式
 | |||
| 	SwingSet2.initBeautyStyle(); | |||
| 
 | |||
| 	TextAreaDemo demo = new TextAreaDemo(null); | |||
| 	demo.mainImpl(); | |||
|     } | |||
| 
 | |||
|     /* (non-Javadoc) | |||
|      * @see DemoModule#getName() | |||
|      */ | |||
|     @Override public String getName() { | |||
|     	return "文本域"; | |||
|     }; | |||
| 
 | |||
|     /** | |||
|      * ProgressBarDemo Constructor. | |||
|      * | |||
|      * @param swingset the swingset | |||
|      */ | |||
|     public TextAreaDemo(SwingSet2 swingset) { | |||
| 	// Set the title for this demo, and an icon used to represent this
 | |||
| 	// demo inside the SwingSet2 app.
 | |||
| 	super(swingset, "TextAreaDemo" | |||
| 			, "toolbar/JProgressBar.gif"); | |||
| 
 | |||
| 		createProgressPanel(); | |||
|     } | |||
| 
 | |||
| 
 | |||
|     /** The load action. */ | |||
|     Action loadAction; | |||
|      | |||
|     /** The stop action. */ | |||
|     Action stopAction; | |||
|      | |||
|     /** The progress bar. */ | |||
|     JProgressBar progressBar; | |||
|      | |||
|     /** The progress text area. */ | |||
|     JTextArea progressTextArea; | |||
| 
 | |||
|     /* (non-Javadoc) | |||
|      * @see DemoModule#updateDragEnabled(boolean) | |||
|      */ | |||
| 	@Override | |||
| 	void updateDragEnabled(boolean dragEnabled) { | |||
|         progressTextArea.setDragEnabled(dragEnabled); | |||
|     } | |||
|      | |||
|     /** | |||
|      * Creates the progress panel. | |||
|      */ | |||
|     public void createProgressPanel() { | |||
| 	getDemoPanel().setLayout(new BorderLayout()); | |||
| 
 | |||
| 	JPanel textWrapper = new JPanel(new BorderLayout()); | |||
| //	textWrapper.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
 | |||
| 	textWrapper.setAlignmentX(LEFT_ALIGNMENT); | |||
| 	progressTextArea = new MyTextArea(); | |||
|          | |||
| 	progressTextArea.getAccessibleContext().setAccessibleName(getString("ProgressBarDemo.accessible_text_area_name")); | |||
| 	progressTextArea.getAccessibleContext().setAccessibleName(getString("ProgressBarDemo.accessible_text_area_description")); | |||
| 
 | |||
| 
 | |||
| 	textWrapper.add(new JScrollPane(progressTextArea), BorderLayout.CENTER); | |||
| 
 | |||
| 
 | |||
| 	getDemoPanel().add(textWrapper, BorderLayout.CENTER); | |||
| 
 | |||
| 	JPanel progressPanel = new JPanel(); | |||
| 	getDemoPanel().add(progressPanel, BorderLayout.SOUTH); | |||
| 
 | |||
| 
 | |||
| 		JPanel p1 = new JPanel(); | |||
| 		p1.add(createLoadButton()); | |||
| 		p1.add(createStopButton()); | |||
| 		 | |||
| 		progressPanel.add(p1); | |||
| 
 | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Creates the load button. | |||
|      * | |||
|      * @return the j button | |||
|      */ | |||
|     public JButton createLoadButton() { | |||
| 	loadAction = new AbstractAction(getString("ProgressBarDemo.start_button")) { | |||
| 	    @Override | |||
| 		public void actionPerformed(ActionEvent e) { | |||
| 			progressTextArea.append("开始"+getString("ProgressBarDemo.text")); | |||
| 
 | |||
| 	    } | |||
| 	}; | |||
| 	return createButton(loadAction); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Creates the stop button. | |||
|      * | |||
|      * @return the j button | |||
|      */ | |||
|     public JButton createStopButton() { | |||
| 	stopAction = new AbstractAction("开始解析") { | |||
| 	    @Override | |||
| 		public void actionPerformed(ActionEvent e) { | |||
| 			AccessibleContext accessibleContext = progressTextArea.getAccessibleContext(); | |||
| 			String tempStr = progressTextArea.getText(); | |||
| 
 | |||
| 
 | |||
| 			progressTextArea.setText(tempStr);	; | |||
| 			JOptionPane.showMessageDialog( | |||
| 					getDemoPanel(), | |||
| 					getString("OptionPaneDemo.warningtext"), | |||
| 					getString("OptionPaneDemo.warningtitle"), | |||
| 					JOptionPane.WARNING_MESSAGE | |||
| 			); | |||
| 	    } | |||
| 	}; | |||
| 	return createButton(stopAction); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Creates the button. | |||
|      * | |||
|      * @param a the a | |||
|      * @return the j button | |||
|      */ | |||
|     public JButton createButton(Action a) { | |||
| 	JButton b = new JButton(); | |||
| 	// setting the following client property informs the button to show
 | |||
| 	// the action text as it's name. The default is to not show the
 | |||
| 	// action text.
 | |||
| 	b.putClientProperty("displayActionText", Boolean.TRUE); | |||
| 	b.setAction(a); | |||
| 	return b; | |||
|     } | |||
| 
 | |||
| 
 | |||
|     /** | |||
|      * The Class MyTextArea. | |||
|      */ | |||
|     class MyTextArea extends JTextArea { | |||
|          | |||
|         /** | |||
|          * Instantiates a new my text area. | |||
|          */ | |||
|         public MyTextArea() { | |||
|             super(null, 0, 0); | |||
| //	    setEditable(false);
 | |||
| 	    setText(""); | |||
|         } | |||
| 
 | |||
|         /* (non-Javadoc) | |||
|          * @see javax.swing.JComponent#getAlignmentX() | |||
|          */ | |||
|         @Override | |||
| 		public float getAlignmentX () { | |||
|             return LEFT_ALIGNMENT; | |||
|         } | |||
|   | |||
|         /* (non-Javadoc) | |||
|          * @see javax.swing.JComponent#getAlignmentY() | |||
|          */ | |||
|         @Override | |||
| 		public float getAlignmentY () { | |||
|             return TOP_ALIGNMENT; | |||
|         } | |||
|     } | |||
| } | |||
| 
 | |||
| 
 | |||
| @ -1,155 +0,0 @@ | |||
| package com.insigma.demos;/* | |||
|  * Copyright (C) 2015 Jack Jiang(cngeeker.com) The BeautyEye Project. | |||
|  * All rights reserved. | |||
|  * Project URL:https://github.com/JackJiang2011/beautyeye
 | |||
|  * Version 3.6 | |||
|  * | |||
|  * Jack Jiang PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. | |||
|  * | |||
|  * TreeDemo.java at 2015-2-1 20:25:39, original version by Jack Jiang. | |||
|  * You can contact author with jb2011@163.com. | |||
|  */ | |||
| 
 | |||
| /* | |||
|  * @(#)TreeDemo.java	1.13 05/11/17 | |||
|  */ | |||
| 
 | |||
| 
 | |||
| import java.awt.BorderLayout; | |||
| import java.awt.Insets; | |||
| import java.io.BufferedReader; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.InputStreamReader; | |||
| import java.net.URL; | |||
| 
 | |||
| import javax.swing.JComponent; | |||
| import javax.swing.JScrollPane; | |||
| import javax.swing.JTree; | |||
| import javax.swing.tree.DefaultMutableTreeNode; | |||
| 
 | |||
| // TODO: Auto-generated Javadoc
 | |||
| 
 | |||
| /** | |||
|  * JTree Demo. | |||
|  * | |||
|  * @author Jeff Dinkins | |||
|  * @version 1.13 11/17/05 | |||
|  */ | |||
| public class TreeDemo extends DemoModule { | |||
| 
 | |||
|     /** | |||
|      * The tree. | |||
|      */ | |||
|     JTree tree; | |||
| 
 | |||
|     /** | |||
|      * main method allows us to run as a standalone demo. | |||
|      * | |||
|      * @param args the arguments | |||
|      */ | |||
|     public static void main(String[] args) { | |||
|     	SwingSet2.initBeautyStyle(); | |||
|         TreeDemo demo = new TreeDemo(null); | |||
|         demo.mainImpl(); | |||
|     } | |||
| 
 | |||
|     /* (non-Javadoc) | |||
|      * @see DemoModule#getName() | |||
|      */ | |||
|     @Override | |||
|     public String getName() { | |||
|         return "树"; | |||
|     } | |||
| 
 | |||
|     ; | |||
| 
 | |||
|     /** | |||
|      * TreeDemo Constructor. | |||
|      * | |||
|      * @param swingset the swingset | |||
|      */ | |||
|     public TreeDemo(SwingSet2 swingset) { | |||
|         // Set the title for this demo, and an icon used to represent this
 | |||
|         // demo inside the SwingSet2 app.
 | |||
|         super(swingset, "TreeDemo", "toolbar/JTree.gif"); | |||
| 
 | |||
|         getDemoPanel().add(createTree(), BorderLayout.CENTER); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * Creates the tree. | |||
|      * | |||
|      * @return the j component | |||
|      */ | |||
|     public JComponent createTree() { | |||
|         DefaultMutableTreeNode top = new DefaultMutableTreeNode(getString("TreeDemo.music")); | |||
|         DefaultMutableTreeNode catagory = null; | |||
|         DefaultMutableTreeNode artist = null; | |||
|         DefaultMutableTreeNode record = null; | |||
| 
 | |||
|         // open tree data
 | |||
|         URL url = getClass().getResource("/tree.txt"); | |||
| 
 | |||
|         try { | |||
|             // convert url to buffered string
 | |||
|             InputStream is = url.openStream(); | |||
|             InputStreamReader isr = new InputStreamReader(is, "UTF-8"); | |||
|             BufferedReader reader = new BufferedReader(isr); | |||
| 
 | |||
|             // read one line at a time, put into tree
 | |||
|             String line = reader.readLine(); | |||
|             while (line != null) { | |||
|                 // System.out.println("reading in: ->" + line + "<-");
 | |||
|                 char linetype = line.charAt(0); | |||
|                 switch (linetype) { | |||
|                     case 'C': | |||
|                         catagory = new DefaultMutableTreeNode(line.substring(2)); | |||
|                         top.add(catagory); | |||
|                         break; | |||
|                     case 'A': | |||
|                         if (catagory != null) { | |||
|                             catagory.add(artist = new DefaultMutableTreeNode(line.substring(2))); | |||
|                         } | |||
|                         break; | |||
|                     case 'R': | |||
|                         if (artist != null) { | |||
|                             artist.add(record = new DefaultMutableTreeNode(line.substring(2))); | |||
|                         } | |||
|                         break; | |||
|                     case 'S': | |||
|                         if (record != null) { | |||
|                             record.add(new DefaultMutableTreeNode(line.substring(2))); | |||
|                         } | |||
|                         break; | |||
|                     default: | |||
|                         break; | |||
|                 } | |||
|                 line = reader.readLine(); | |||
|             } | |||
|         } catch (IOException e) { | |||
|         } | |||
| 
 | |||
|         tree = new JTree(top) { | |||
|             @Override | |||
|             public Insets getInsets() { | |||
|                 return new Insets(5, 5, 5, 5); | |||
|             } | |||
|         }; | |||
| //	tree.setBackground(new Color(250,250,250));
 | |||
| 
 | |||
|         tree.setEditable(true); | |||
| 
 | |||
|         return new JScrollPane(tree); | |||
| //        return tree;
 | |||
|     } | |||
| 
 | |||
|     /* (non-Javadoc) | |||
|      * @see DemoModule#updateDragEnabled(boolean) | |||
|      */ | |||
|     @Override | |||
|     void updateDragEnabled(boolean dragEnabled) { | |||
|         tree.setDragEnabled(dragEnabled); | |||
|     } | |||
| 
 | |||
| } | |||
					Loading…
					
					
				
		Reference in new issue