📄 mainframe.java
字号:
package library;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class MainFrame extends JFrame { private JPanel contentPane; private ImageIcon image1; private ImageIcon image2; private ImageIcon image3; private JToolBar jToolBar1 = new JToolBar(); private JButton jButton_User = new JButton(); private JButton jButton_Borrow = new JButton(); private JButton jButton_Return = new JButton(); private JButton jButton_NewBook = new JButton(); private JButton jButton_NewReader = new JButton(); private JButton jButton6 = new JButton(); private JPanel jPanel1 = new JPanel(); private JLabel jLabel1 = new JLabel(); BorderLayout borderLayout1 = new BorderLayout(); XYLayout xYLayout1 = new XYLayout(); JButton jButton7 = new JButton(); //Construct the frame public MainFrame() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { image1 = new ImageIcon(library.MainFrame.class.getResource("openFile.gif")); image2 = new ImageIcon(library.MainFrame.class.getResource("closeFile.gif")); image3 = new ImageIcon(library.MainFrame.class.getResource("help.gif")); //setIconImage(Toolkit.getDefaultToolkit().createImage(MainFrame.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(borderLayout1); this.setResizable(false); this.setSize(new Dimension(616, 444)); this.setTitle("Library"); jButton_User.setFont(new java.awt.Font("DialogInput", 0, 12)); jButton_User.setMaximumSize(new Dimension(79, 39)); jButton_User.setMinimumSize(new Dimension(79, 39)); jButton_User.setPreferredSize(new Dimension(79, 39)); jButton_User.setMnemonic('0'); jButton_User.setText("注册"); jButton_User.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton_User_actionPerformed(e); } }); jButton_Borrow.setFont(new java.awt.Font("DialogInput", 0, 12)); jButton_Borrow.setMaximumSize(new Dimension(79, 39)); jButton_Borrow.setMinimumSize(new Dimension(79, 39)); jButton_Borrow.setPreferredSize(new Dimension(79, 39)); jButton_Borrow.setText("借书"); jButton_Borrow.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton_Borrow_actionPerformed(e); } }); jButton_Return.setFont(new java.awt.Font("DialogInput", 0, 12)); jButton_Return.setMaximumSize(new Dimension(79, 39)); jButton_Return.setMinimumSize(new Dimension(79, 39)); jButton_Return.setPreferredSize(new Dimension(79, 39)); jButton_Return.setText("还书"); jButton_Return.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton_Return_actionPerformed(e); } }); jButton_NewBook.setText("书库管理"); jButton_NewBook.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton_NewBook_actionPerformed(e); } }); jButton_NewBook.setMnemonic('0'); jButton_NewBook.setPreferredSize(new Dimension(79, 39)); jButton_NewBook.setMinimumSize(new Dimension(79, 39)); jButton_NewBook.setFont(new java.awt.Font("DialogInput", 0, 12)); jButton_NewBook.setMaximumSize(new Dimension(79, 39)); jButton_NewReader.setText("读者管理"); jButton_NewReader.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton_NewReader_actionPerformed(e); } }); jButton_NewReader.setPreferredSize(new Dimension(79, 39)); jButton_NewReader.setMinimumSize(new Dimension(79, 39)); jButton_NewReader.setFont(new java.awt.Font("DialogInput", 0, 12)); jButton_NewReader.setMaximumSize(new Dimension(79, 39)); jButton6.setText("关于"); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton6_actionPerformed(e); } }); jButton6.setPreferredSize(new Dimension(79, 39)); jButton6.setMinimumSize(new Dimension(79, 39)); jButton6.setMaximumSize(new Dimension(79, 39)); jButton6.setFont(new java.awt.Font("DialogInput", 0, 12)); jLabel1.setBackground(SystemColor.inactiveCaption); jLabel1.setFont(new java.awt.Font("Dialog", 1, 48)); jLabel1.setForeground(Color.yellow); jLabel1.setText("XXX图书管理系统"); contentPane.setBackground(SystemColor.textHighlight); jPanel1.setLayout(xYLayout1); jPanel1.setBackground(SystemColor.inactiveCaption); jButton7.setFont(new java.awt.Font("DialogInput", 0, 12)); jButton7.setMaximumSize(new Dimension(79, 39)); jButton7.setMinimumSize(new Dimension(79, 39)); jButton7.setPreferredSize(new Dimension(79, 39)); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton7_actionPerformed(e); } }); jButton7.setText("退出系统"); contentPane.add(jToolBar1, BorderLayout.NORTH); jToolBar1.add(jButton_User, null); jToolBar1.add(jButton_Borrow, null); jToolBar1.add(jButton_Return, null); jToolBar1.add(jButton_NewBook, null); jToolBar1.add(jButton_NewReader, null); jToolBar1.add(jButton6, null); jToolBar1.add(jButton7, null); contentPane.add(jPanel1, BorderLayout.CENTER); jPanel1.add(jLabel1, new XYConstraints(110, 139, 445, -1)); } //File | Exit action performed public void jMenuFileExit_actionPerformed(ActionEvent e) { System.exit(0); } //Help | About action performed public void jMenuHelpAbout_actionPerformed(ActionEvent e) { MainFrame_AboutBox dlg = new MainFrame_AboutBox(this); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } //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); } } void jButton_User_actionPerformed(ActionEvent e) { UserManager_Dialog dlg = new UserManager_Dialog(); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } void jButton_Borrow_actionPerformed(ActionEvent e) { Borrow_Dialog dlg = new Borrow_Dialog(); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } void jButton_Return_actionPerformed(ActionEvent e) { Return_Dialog dlg = new Return_Dialog(); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } void jButton6_actionPerformed(ActionEvent e) { MainFrame_AboutBox dlg = new MainFrame_AboutBox(this); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } void jButton_NewBook_actionPerformed(ActionEvent e) { NewBook_Dialog dlg = new NewBook_Dialog(); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } void jButton_NewReader_actionPerformed(ActionEvent e) { Reader_Dialog dlg = new Reader_Dialog(); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } void jButton7_actionPerformed(ActionEvent e) { System.exit(0); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -