📄 mainframe.java
字号:
/**********************************
* FileName:MainFrame.java
* Function:功能主界面
* Time:2005 1.8
*********************************/
import java.awt.*;
import java.awt.event.*;
public class MainFrame extends Frame implements ActionListener
{
Button butQuery = new Button("图书查询");
Button butBorrow = new Button("图书借阅");
Button butReturn = new Button("图书归还");
Button butInform =new Button("读者资料查询");
Button butHelp = new Button("帮助");
Button butExit = new Button("退出");
MainFrame()
{
setTitle("图书管理系统");
GridBagLayout gbLayout = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints ();
setLayout(gbLayout);
gbc.gridx=2;gbc.gridy =2;
gbc.gridwidth =1;gbc.gridheight =1;
gbc.fill=GridBagConstraints.BOTH ;
gbc.anchor =GridBagConstraints.WEST;
gbc.weightx = 1; gbc.weighty = 1;
gbc.insets = new Insets (2,5,1,5);
gbLayout.setConstraints (butQuery,gbc);
butQuery.addActionListener(this);
gbc.gridx=6;gbc.gridy =2;
gbc.gridwidth =1;gbc.gridheight =1;
gbc.fill=GridBagConstraints.BOTH ;
gbc.anchor =GridBagConstraints.WEST ;
gbc.weightx = 1; gbc.weighty = 1;
gbc.insets = new Insets (2,5,1,5);
gbLayout.setConstraints (butBorrow,gbc);
butBorrow.addActionListener(this);
gbc.gridx=2;gbc.gridy =17;
gbc.gridwidth =1;gbc.gridheight =1;
gbc.fill=GridBagConstraints.BOTH ;
gbc.anchor =GridBagConstraints.WEST;
gbc.weightx = 1; gbc.weighty = 1;
gbc.insets = new Insets (2,5,1,5);
gbLayout.setConstraints (butReturn,gbc);
butReturn.addActionListener(this);
gbc.gridx=6;gbc.gridy =17;
gbc.gridwidth =1;gbc.gridheight =1;
gbc.fill=GridBagConstraints.BOTH ;
gbc.anchor =GridBagConstraints.WEST;
gbc.weightx = 1; gbc.weighty = 1;
gbc.insets = new Insets (2,5,1,5);
gbLayout.setConstraints (butInform,gbc);
butInform.addActionListener(this);
gbc.gridx=2;gbc.gridy =32;
gbc.gridwidth =1;gbc.gridheight =1;
gbc.fill=GridBagConstraints.BOTH ;
gbc.anchor =GridBagConstraints.WEST;
gbc.weightx = 1; gbc.weighty = 1;
gbc.insets = new Insets (2,5,1,5);
gbLayout.setConstraints (butHelp,gbc);
butHelp.addActionListener(this);
gbc.gridx=6;gbc.gridy =32;
gbc.gridwidth =1;gbc.gridheight =1;
gbc.fill=GridBagConstraints.BOTH ;
gbc.anchor =GridBagConstraints.WEST;
gbc.weightx = 1; gbc.weighty = 1;
gbc.insets = new Insets (2,5,1,5);
gbLayout.setConstraints (butExit,gbc);
butExit.addActionListener(this);
add(butQuery);
add(butBorrow);
add(butReturn);
add(butInform);
add(butHelp);
add(butExit);
setSize(400,500);
setResizable(false);
setVisible(true);
setLocation (350,150);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand () == "图书查询")
{
BookQueryFrame bqFrame = new BookQueryFrame ();
bqFrame.show ();
}
if(e.getActionCommand () == "图书借阅")
{
BookBorrowFrame bbFrame = new BookBorrowFrame ();
bbFrame.show ();
}
if(e.getActionCommand () == "图书归还")
{
BookReturnFrame brFrame = new BookReturnFrame ();
brFrame.show();
}
if(e.getActionCommand () == "读者资料查询")
{
UserQueryFrame uqFrame = new UserQueryFrame ();
uqFrame.show ();
}
if(e.getActionCommand ()== "帮助")
{
HelpFrame hFrame = new HelpFrame ();
hFrame.show ();
hFrame.txtDisplay();
}
if(e.getActionCommand () =="退出")
dispose();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -