📄 f.java
字号:
/*
*
* GUI 显示界面
* author Amadan
* 2008/10/27
*
*/
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import javax.swing.*;
//顶层界面,production management system,给用户提供选择界面
public class f implements ActionListener{
static JFrame f=null;//类属性
public f(){//构造方法
f=new JFrame("**production management system**");//创建顶层容器
Container contentPane=f.getContentPane();//获得其内容面板
JPanel buttonPanel=new JPanel();//创建中间容器
buttonPanel.setBorder(BorderFactory.createLineBorder(Color.blue,2));
buttonPanel.setLayout(new GridLayout(8,2));
JButton a1=new JButton("add production");//创建原子组件
a1.addActionListener(this);//为按钮增加监听对象
buttonPanel.add(a1);
a1=new JButton("display production");
a1.addActionListener(this);
buttonPanel.add(a1);
a1=new JButton("search a production");
a1.addActionListener(this);
buttonPanel.add(a1);
a1=new JButton("remove a production");
a1.addActionListener(this);
buttonPanel.add(a1);
a1=new JButton("show the adds");
a1.addActionListener(this);
buttonPanel.add(a1);
a1=new JButton("Sale Plan");
a1.addActionListener(this);
buttonPanel.add(a1);
a1=new JButton("add to files");
a1.addActionListener(this);
buttonPanel.add(a1);
a1=new JButton("Quit");
a1.addActionListener(this);
buttonPanel.add(a1);
contentPane.add(buttonPanel);//将中间容器添加到内容面板
f.pack();
f.setVisible(true);
f.addWindowListener(new WindowAdapter(){//为窗口增加监听器
public void windowClosing(WindowEvent e){//
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e){//实现ActionListener接口的唯一方法
String cmd=e.getActionCommand();//从事件获得相关名称
if(cmd.equals("add production")){//根据名称选择相应事件
new addpro(f); //显示下一层对话窗口add production
}
else if(cmd.equals("display production")){//显示下一个对话窗口display production
try {
new display(f);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
else if(cmd.equals("search a production")){//显示下一个对话窗口search a production
new searchpro(f);
}
else if(cmd.equals("remove a production")){//显示下一个对话窗口remove a production
new remove(f);
}
else if(cmd.equals("show the adds")){//显示下一个对话窗口show the adds
new showadds(f);
}
else if(cmd.equals("Sale Plan")){//显示下一个对话窗口show the adds
new sale(f);
}
else if(cmd.equals("add to files")){//显示下一个对话窗口show the adds
new Addtofiles();
}
else if(cmd.equals("Quit")){//显示下一个对话窗口Quit
System.exit(0);
}
}
public static void main(String[]args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
new f();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -