代码大吗 为什么不发在论坛上大家看看 呵呵 怕盗版?
不是的拉 是应为还没写完 怕拿出来丢人 等完后 我会把它上传来的
冰封:
受教了 经你这一说 的确是的 象你说的
而用一个继承自JPanel的面板放在主窗口里面,交替显示。 这样想想确实比弹出那么多的窗口好看些 而且不乱
谢谢你的建议!!!!
子非鱼,安知鱼之江湖?子非我,安知我之功夫 http://20681.
水影月圆 看了你写的 我有的想法
1。主窗体那显示为白色 是不是有点太刺眼了 我觉的改暗点比较好
2。象千里冰封说的 把所有的都显示在主窗体里 是不是有的太单一了?
3。上面的话 我也没看明白 继承 如果父类里有的 子类里才能继承下来 但是JPanel可以继承吗?
它既不是类 又不是成员 怎么继承啊?我现在才上到这,下面有没有介绍我不是很清楚,所以我现在也很想知道可不可以继承 JPanel
4。还没想到 呵呵:)
看了你的代码 对我这个初学者而言 实在是太有帮助了 让我有了学习JAVA的动力 谢谢了
没怎么改
可没有点击事件
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import java.sql.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Frame2 extends JFrame {
JSplitPane jSplitPane1 = new JSplitPane();
JScrollPane jScrollPane1 = new JScrollPane();
WelcomePane welcomePane1=new WelcomePane();
XYLayout xYLayout1 = new XYLayout();
DefaultMutableTreeNode rootNode=new DefaultMutableTreeNode("人事档案资源管理系统");
JTree jTree1=new JTree(rootNode);
AddManagers AM=new AddManagers();
public Frame2() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
// this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setTitle("人事档案资源管理系统");
this.setBounds(100,50,800,600);
this.getContentPane().setLayout(null);
jSplitPane1.setFont(new java.awt.Font("Dialog", 0, 12));
jSplitPane1.setBounds(new Rectangle(-1, 0, 800, 600));
jScrollPane1.setFont(new java.awt.Font("Dialog", 0, 12));
this.getContentPane().add(jSplitPane1, null);
jSplitPane1.add(jScrollPane1, JSplitPane.LEFT);
jSplitPane1.add(welcomePane1, JSplitPane.RIGHT);
jScrollPane1.getViewport().setView(jTree1);
jScrollPane1.show();
jTree1.setFont(new java.awt.Font("Dialog", 0, 12));
initTree(); //初始化jTree节点
jTree1.expandRow(0); //展开根节电
jTree1.expandRow(1);
jTree1.expandRow(6);
jTree1.expandRow(12);
jTree1.expandRow(16);
}
//添加管理员(AddManagers(简称AM))
class AddManagers extends JPanel// implements ActionListener
{
JLabel jLabel8 = new JLabel();
XYLayout xYLayout3 = new XYLayout();
JButton jButton4 = new JButton();
JLabel jLabel12 = new JLabel();
JButton jButton5 = new JButton();
JLabel jLabel11 = new JLabel();
JPasswordField jPasswordField5 = new JPasswordField();
JPasswordField jPasswordField4 = new JPasswordField();
JTextField jTextField1 = new JTextField();
JButton jButton3 = new JButton();
JLabel jLabel9 = new JLabel();
JLabel jLabel10 = new JLabel();
AddManagers()
{
setLayout(xYLayout3);
jLabel8.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel8.setText("管理员");
jButton4.setBackground(Color.yellow);
jButton4.setFont(new java.awt.Font("Dialog", 0, 12));
jButton4.setText("重置");
jLabel12.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel12.setForeground(Color.red);
jLabel12.setText("口令不一致");
jLabel12.setVisible(false);
jButton5.setBackground(Color.red);
jButton5.setFont(new java.awt.Font("Dialog", 0, 12));
jButton5.setText("取消");
jLabel11.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel11.setForeground(Color.red);
jLabel11.setToolTipText("");
jLabel11.setText("已存在该管理员");
jLabel11.setVisible(false);
jPasswordField5.setText("");
jPasswordField4.setText("");
jTextField1.setText("");
jButton3.setBackground(Color.green);
jButton3.setFont(new java.awt.Font("Dialog", 0, 12));
jButton3.setText("确定");
jLabel9.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel9.setText("口令");
jLabel10.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel10.setText("重复口令");
add(jTextField1, new XYConstraints(113, 22, 110, -1));
add(jLabel8, new XYConstraints(48, 26, -1, -1));
add(jPasswordField4, new XYConstraints(113, 54, 111, -1));
add(jLabel10, new XYConstraints(49, 82, -1, -1));
add(jPasswordField5, new XYConstraints(112, 84, 111, -1));
add(jLabel11, new XYConstraints(50, 118, 99, 25));
add(jLabel12, new XYConstraints(179, 120, -1, -1));
add(jLabel9, new XYConstraints(50, 51, -1, -1));
add(jButton5, new XYConstraints(211, 153, -1, -1));
add(jButton3, new XYConstraints(31, 152, -1, -1));
add(jButton4, new XYConstraints(113, 151, -1, 26));
// jButton1.addActionListener(new actionAdapter(this));
}
}
class WelcomePane extends JPanel
{
JLabel jLabel1=new JLabel("欢迎使用人事资源管理系统--Welcome!");
WelcomePane()
{
jLabel1.setFont(new java.awt.Font("Dialog", 3, 30));
jLabel1.setForeground(Color.magenta);
add(jLabel1);
}
}
public void initTree()
{
DefaultMutableTreeNode childNode1=new DefaultMutableTreeNode("系统");
rootNode.add(childNode1);
DefaultMutableTreeNode childNode2=new DefaultMutableTreeNode("人事管理");
rootNode.add(childNode2);
DefaultMutableTreeNode childNode3=new DefaultMutableTreeNode("工资管理");
rootNode.add(childNode3);
DefaultMutableTreeNode childNode4=new DefaultMutableTreeNode("帮助");
rootNode.add(childNode4);
DefaultMutableTreeNode childNode5=new DefaultMutableTreeNode("添加管理员");
childNode1.add(childNode5);
childNode5=new DefaultMutableTreeNode("删除管理员");
childNode1.add(childNode5);
childNode5=new DefaultMutableTreeNode("修改密码");
childNode1.add(childNode5);
childNode5=new DefaultMutableTreeNode("设置权限");
childNode1.add(childNode5);
DefaultMutableTreeNode childNode6=new DefaultMutableTreeNode("员工信息管理");
childNode2.add(childNode6);
childNode6=new DefaultMutableTreeNode("员工培训管理");
childNode2.add(childNode6);
childNode6=new DefaultMutableTreeNode("员工奖罚管理");
childNode2.add(childNode6);
childNode6=new DefaultMutableTreeNode("员工调动管理");
childNode2.add(childNode6);
childNode6=new DefaultMutableTreeNode("综合查询");
childNode2.add(childNode6);
DefaultMutableTreeNode childNode7=new DefaultMutableTreeNode("工资表管理");
childNode3.add(childNode7);
childNode7=new DefaultMutableTreeNode("工资表修改");
childNode3.add(childNode7);
childNode7=new DefaultMutableTreeNode("工资表查询");
childNode3.add(childNode7);
DefaultMutableTreeNode childNode8=new DefaultMutableTreeNode("技术支持");
childNode4.add(childNode8);
childNode8=new DefaultMutableTreeNode("关于");
childNode4.add(childNode8);
}
//单击JTree控件后的事件处理
public void valueChanged(TreeSelectionEvent e)
{
DefaultMutableTreeNode selectedNode=
(DefaultMutableTreeNode)jTree1.getLastSelectedPathComponent();
if(selectedNode.toString().equals("添加管理员"))
{
jSplitPane1.add(AM, JSplitPane.RIGHT);
}
else if(selectedNode.toString()=="删除管理员")
{
}
else if(selectedNode.toString()=="修改密码")
{
}
else if(selectedNode.toString()=="设置权限")
{
}
else if(selectedNode.toString()=="员工信息管理")
{
}
}
}