📄 appgdzcmain.java~1~
字号:
package appgdzc.view;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import appgdzc.tools.MenuBarEvent;
import appgdzc.tools.InitContext;
public class AppGdzcMain extends JFrame {
JPanel contentPane;
public static JDesktopPane desktop = new JDesktopPane();
BorderLayout borderLayout1 = new BorderLayout();
//自定义事件类处理
MenuBarEvent _MenuBarEvent = new MenuBarEvent();
//Construct the frame
JMenuBar jMenuBarMain = new JMenuBar();
JToolBar jToolBarMain = new JToolBar();
Border border1;
JLabel jLabel1 = new JLabel();
Border border2;
public AppGdzcMain() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
//根据两个方法buildMenu()和buildToolBar()建立菜单和工具栏
BuildMenuBar();
BuildToolBar();
jbInit();
loadBackgroundImage();
}
catch(Exception e) {
e.printStackTrace();
}
}
protected void loadBackgroundImage(){
ImageIcon icon = new ImageIcon(".\\images\\main.jpg");
//ImageIcon icon = new ImageIcon(JF_main.class.getResource("main_bg.jpg"));
JLabel jl = new JLabel(icon);
jl.setBounds(0,0,icon.getIconWidth(),icon.getIconHeight());
desktop.add(jl,new Integer(Integer.MIN_VALUE));
//desktop.add(jl,BorderLayout.CENTER);
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
border1 = new EtchedBorder(EtchedBorder.RAISED,Color.white,Color.red);
border2 = BorderFactory.createLineBorder(new Color(255, 55, 166),1);
contentPane.setLayout(borderLayout1);
jMenuBarMain.setFont(new Font("宋体", 0, 12));
jLabel1.setFont(new java.awt.Font("新宋体", 0, 12));
jLabel1.setForeground(new Color(255, 104, 69));
jLabel1.setBorder(border2);
// jLabel1.setText("系统当前时间是:");
_MenuBarEvent.setDeskTop(this.desktop);
jToolBarMain.setBorder(border1);
this.setJMenuBar(jMenuBarMain);
this.setResizable(false);
jToolBarMain.setFloatable(false);
desktop.setBackground(SystemColor.desktop);
contentPane.add(jToolBarMain, BorderLayout.NORTH);
contentPane.add(desktop,BorderLayout.CENTER);
contentPane.add(jLabel1, BorderLayout.SOUTH);
// Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
setVisible(true);
this.setSize(new Dimension(860, 680));
this.setTitle("通用固定资产及设备管理系统");
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
private void BuildMenuBar(){
//JMenu[] _jMenu = {new JMenu("【用户管理】"),new JMenu("【系统维护】"),new JMenu("【辅助功能】"),new JMenu("【退出系统】")};
JMenu[] _jMenu = {new JMenu("【设备管理】"), new JMenu("【查询管理】"),new JMenu("【用户管理】"),new JMenu("【系统管理】")};
/*设置菜单相目JMenuItem元素*/
JMenuItem[] _jMenuItem0 = {new JMenuItem("【设备添加管理】"),new JMenuItem("【资产设备维护】"),new JMenuItem("【借出归还管理】"),new JMenuItem("【设备维修管理】"), new JMenuItem("【设备折旧管理】")};
String[] _jMenuItem0Name = {"JB_ZCXX_ADD","JB_ZCXX_XG","JB_ZCXX_INOUT","JB_ZCXX_ZCWX","JB_ZCXX_ZCZJ"};
//JMenuItem[] _jMenuItem1 = {new JMenuItem("用户注册"),new JMenuItem("用户删除"), new JMenuItem("修改密码")};
//String[] _jMenuItem1Name = {"user_regist","user_delete","user_pass"};
JMenuItem[] _jMenuItem1 = {new JMenuItem("【设备信息查询】"),new JMenuItem("【借出归还查询】"), new JMenuItem("【设备维修查询】"),new JMenuItem("【设备折旧查询】")};
String[] _jMenuItem1Name = {"JF_ZCGL_Query_zcxx","JF_ZCGL_Query_inout","JF_ZCGL_Query_zcwx","JF_ZCGL_Query_zczj"};
JMenuItem[] _jMenuItem2 = {new JMenuItem("【增加用户】"),new JMenuItem("【用户维护】")};
String[] _jMenuItem2Name = {"sys_user_add","sys_user_modify"};
JMenuItem[] _jMenuItem3 = {new JMenuItem("【系统退出】")};
String[] _jMenuItem3Name = {"JB_EXIT"};
/*JMenuItem[] _jMenuItem4 = {new JMenuItem("重新登陆"),new JMenuItem("系统退出")};
String[] _jMenuItem4Name = {"sysout_login","sysout_leave"};*/
/*设置菜单、菜单项字体风格*/
Font _MenuItemFont = new Font("宋体", 0, 12);
for (int i = 0 ; i < _jMenu.length; i++){
_jMenu[i].setFont(_MenuItemFont);
jMenuBarMain.add(_jMenu[i]);
}
for (int j = 0; j < _jMenuItem0.length; j++){
_jMenuItem0[j].setFont(_MenuItemFont);
final String EventName1 = _jMenuItem0Name[j];
_jMenuItem0[j].addActionListener(_MenuBarEvent);
_jMenuItem0[j].addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
_MenuBarEvent.setEventName(EventName1);
}
});
_jMenu[0].add(_jMenuItem0[j]);
if (j == 1){
_jMenu[0].addSeparator();
}
}
for (int j = 0; j < _jMenuItem1.length; j++){
_jMenuItem1[j].setFont(_MenuItemFont);
final String EventName1 = _jMenuItem1Name[j];
_jMenuItem1[j].addActionListener(_MenuBarEvent);
_jMenuItem1[j].addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
_MenuBarEvent.setEventName(EventName1);
}
});
_jMenu[1].add(_jMenuItem1[j]);
if (j == 1){
_jMenu[1].addSeparator();
}
}
for(int j = 0 ; j <_jMenuItem2.length; j++){
_jMenuItem2[j].setFont(_MenuItemFont);
final String EventName2 = _jMenuItem2Name[j];
_jMenuItem2[j].addActionListener(_MenuBarEvent);
_jMenuItem2[j].addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
_MenuBarEvent.setEventName(EventName2);
// _MenuBarEvent.getName();
}
});
_jMenu[2].add(_jMenuItem2[j]);
if (j == 0){
_jMenu[2].addSeparator();
}
}
for(int j = 0 ; j <_jMenuItem3.length; j++){
_jMenuItem3[j].setFont(_MenuItemFont);
final String EventName3 = _jMenuItem3Name[j];
_jMenuItem3[j].addActionListener(_MenuBarEvent);
_jMenuItem3[j].addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
_MenuBarEvent.setEventName(EventName3);
// _MenuBarEvent.getName();
}
});
_jMenu[3].add(_jMenuItem3[j]);
}
}
private void BuildToolBar(){
JToolBar toolbar = new JToolBar();
//String ImageName[] = {"借出管理.gif","移动管理.gif","维修管理.gif","折旧管理.gif","报表管理.gif","增加.gif","删除.gif","修改.gif","打印.gif","查询.gif","刷新.gif","退出.gif"};
String ImageName[] = {"增加资产.gif","资产维护.gif","借出管理.gif","资产维修.gif","资产折旧.gif","退出.gif"};
String TipString[] = {"增加资产","资产维护","借出管理","资产维修","资产折旧","系统退出"};
String ComandString[] = {"JB_ZCXX_ADD","JB_ZCXX_XG","JB_ZCXX_INOUT","JB_ZCXX_ZCWX","JB_ZCXX_ZCZJ","JB_EXIT"};
for(int i = 0 ; i < ComandString.length; i++){
JButton jb = new JButton();
//ImageIcon image = new ImageIcon(AppGdzcMain.class.getResource(ImageName[i]));
ImageIcon image = new ImageIcon(".\\Images\\"+ImageName[i]);
jb.setIcon(image);
jb.setToolTipText(TipString[i]);
jb.setActionCommand(ComandString[i]);
jb.addActionListener(_MenuBarEvent);
jToolBarMain.add(jb);
}
}
private JMenuBar buildmenu(){
JMenuBar jMenuBar = new JMenuBar();
Font _menuFont = new Font("宋体", 0, 12);
JMenu jMenu = new JMenu("参数设置") ;
jMenuBar.add(jMenu);
return jMenuBar;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -