帮忙看看 谢谢了
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.*;public class Set implements ActionListener { public static void main(String[] args) {
new Tree();
}
}
class Tree implements TreeSelectionListener {
JEditorPane editorpane;
public Tree() {
JFrame f = new JFrame("系统设置");
Container contentPane = f.getContentPane();
DefaultMutableTreeNode root1 = new DefaultMutableTreeNode("系统设置");
DefaultMutableTreeNode note1 = new DefaultMutableTreeNode("修改密码");
root1.add(note1);
JTree tree = new JTree(root1);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addTreeSelectionListener(this);
JScrollPane scrollpane1 = new JScrollPane(tree);
JScrollPane scrollpane2 = new JScrollPane(editorpane);
JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,scrollpane1,scrollpane2);
contentPane.add(splitpane);
f.setBounds(400, 400, 450, 420);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void valueChanged(TreeSelectionEvent e) {
JTree tree = (JTree) e.getSource();
DefaultMutableTreeNode selectionNode = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
String cmd = selectionNode.toString();
if (selectionNode.isLeaf()) {
if (cmd.equals("修改密码")) { //我想在这显示一个修改密码的界面 JPanel password = new JPanel(new GridLayout(2,2));
password.add(new JLabel("输入原来密码:"));
JPasswordField opwd = new JPasswordField();
password.add(opwd);
password.add(new JLabel("输入新密码:"));
JPasswordField npwd1 = new JPasswordField();
password.add(npwd1);
password.add(new JLabel("新密码确认:"));
JPasswordField npwd2 = new JPasswordField();
password.add(npwd2);
}
}
}
}
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.*;public class Set implements ActionListener { public static void main(String[] args) {
new Tree();
}
}
class Tree implements TreeSelectionListener {
JEditorPane editorpane;
public Tree() {
JFrame f = new JFrame("系统设置");
Container contentPane = f.getContentPane();
DefaultMutableTreeNode root1 = new DefaultMutableTreeNode("系统设置");
DefaultMutableTreeNode note1 = new DefaultMutableTreeNode("修改密码");
root1.add(note1);
JTree tree = new JTree(root1);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addTreeSelectionListener(this);
JScrollPane scrollpane1 = new JScrollPane(tree);
JScrollPane scrollpane2 = new JScrollPane(editorpane);
JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,scrollpane1,scrollpane2);
contentPane.add(splitpane);
f.setBounds(400, 400, 450, 420);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void valueChanged(TreeSelectionEvent e) {
JTree tree = (JTree) e.getSource();
DefaultMutableTreeNode selectionNode = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
String cmd = selectionNode.toString();
if (selectionNode.isLeaf()) {
if (cmd.equals("修改密码")) { //我想在这显示一个修改密码的界面 JPanel password = new JPanel(new GridLayout(2,2));
password.add(new JLabel("输入原来密码:"));
JPasswordField opwd = new JPasswordField();
password.add(opwd);
password.add(new JLabel("输入新密码:"));
JPasswordField npwd1 = new JPasswordField();
password.add(npwd1);
password.add(new JLabel("新密码确认:"));
JPasswordField npwd2 = new JPasswordField();
password.add(npwd2);
}
}
}
}
解决方案 »
- 如何理解Runtime这个类运行时
- 关于线程的学习
- 应用 Spring JtaTransactionManager 时总出现 连接关闭,不知道怎么回事??
- 为什么我打包进字节流..里面每个数据之间会有"0"隔开,也就是null
- 如何识别由于歧义名字而产生错误的代码?
- 请教一个关于对象定义和引用的问题,谢谢。。。。。。。。。。。。。。。
- 做象QQ那样的程序应该用java的什么啊????
- 再提一个问题,Java如何实现10进制转16进制
- APPLET可否传对象回SERVLET
- 如何用java实现对远程系统的UDP端口的扫描。
- Applet小程序中的一个最基本的问题!!!!!!!!!!!!!!!!
- 提取系统时间??
呵呵 那是一个 panel 在右侧
怎么无法对原帖进行修改呢?
这种地方最好是用JDialog比较好