图形用户界面(GUI)简单编程
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.lovo.control.MainControl;
import com.lovo.ui.LovoTree;
import com.lovo.view.dep.DepartmentShow;
import com.lovo.view.employee.EmployeeMainView;
import com.lovo.view.job.JobShowView;
/**
*Copyright (C), 2012-2014,ChengDu Lovo info. Co., Ltd.
*FileName MainView.java
*主界面
*@author 周龙 (H2)
*Date 2014-4-24 上午11:08:29
*vesion 1.0
*/
public class MainView extends JFrame{
private JPanel leftPanel,rightPanel;
private EmployeeMainView employeeMain=new EmployeeMainView();
private DepartmentShow departmentShow=new DepartmentShow();
private JobShowView jobShow=new JobShowView();
private CardLayout cardLayout=new CardLayout();
//树形结构
private LovoTree tree;
public JPanel getRightPanel() {
return rightPanel;
}
public CardLayout getCardLayout() {
return cardLayout;
}
public MainView(){
//绝对 定位--布局方式
this.setLayout(null);
//划分窗体
leftPanel=new JPanel();
leftPanel.setLayout(new BorderLayout());
leftPanel.setBounds(0, 0,200, 600);
leftPanel.setBackground(Color.GRAY);
rightPanel=new JPanel();
rightPanel.setBounds(200, 0,800, 600);
rightPanel.setBackground(Color.red);
//将轮换的区域面板设置成卡片布局
rightPanel.setLayout(cardLayout);
//树形
tree=new LovoTree(new String[]{
"1,-1,四川网脉CRM系统"
,"2,1,资料管理"
,"3,2,员工管理"
,"4,2,部门管理"
,"5,2,职位管理"
,"6,1,学校管理"
,"7,6,学校活动"
,"8,6,学校管理"
,"9,1,用户管理"
,"10,9,学生管理"
,"11,9,班级管理"
});
tree.addSelectListener(new MainControl(this));
leftPanel.add(tree);
//将三按钮的主界面添加到右边窗体
rightPanel.add(employeeMain,"员工管理");
rightPanel.add(departmentShow,"部门管理");
rightPanel.add(jobShow,"职位管理");
//添加到主容器
this.add(leftPanel);
this.add(rightPanel);
//窗口标题
this.setTitle("四川网脉CRM系统");
//窗口大小
this.setSize(1000, 600);
//窗体居中
this.setLocationRelativeTo(null);
//关闭策略
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//窗口可见
this.setVisible(true);
}
public static void main(String[] args) {
new MainView();
}
}
浙公网安备 33010602011771号