《Java2图形设计卷II:Swing》配套光盘源码

源代码在线查看: test.java

软件大小: 4504 K
上传用户: guigong
关键词: Java2 Swing 图形 光盘
下载地址: 免注册下载 普通下载 VIP

相关代码

				import javax.swing.*;
				import javax.swing.event.*;
				import javax.swing.tree.*;
				import java.awt.*;
				import java.awt.event.*;
				import java.util.*;
				
				public class Test extends JApplet {
					public void init() {
						JTree tree = new JTree();
				
						getContentPane().add(tree, BorderLayout.CENTER);
				
						// must invoke setEditable, or the call below to
						// getCellEditor() will return null.
				
						tree.setEditable(true);
				
						tree.getCellEditor().addCellEditorListener(
										new CellEditorListener() {
							public void editingCanceled(ChangeEvent e) {
								CellEditor editor = (CellEditor)e.getSource();
								String s = (String)editor.getCellEditorValue();
				
								showStatus("editing cancelled: " + s);
							}
							public void editingStopped(ChangeEvent e) {
								CellEditor editor = (CellEditor)e.getSource();
								String s = (String)editor.getCellEditorValue();
				
								showStatus("editing stopped: " + s);
							}
						});
					}
				}
							

相关资源