📄 printscore.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class PrintScore extends JFrame implements ActionListener{
protected JButton jok3=new JButton("打印");
protected String elesson[]=new String[200];
protected int x;
protected int y;
protected JButton cancle=new JButton("返回");
protected String eclass[]={"网络工程","计算机技术",
"软件工程","信管","金融","英语","电子商务","国际经济与贸易"
};
protected JComboBox clesson;
protected JComboBox cclass;
protected JPanel checkpanel=new JPanel();
public PrintScore(){
checkpanel.setBackground(Color.pink);
access aso=new access();
int n=aso.requir("lessonname","lesson",elesson);
clesson=new JComboBox(elesson);
cclass=new JComboBox(eclass);
aso.close();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(new JLabel("打印成绩",SwingConstants.CENTER),
BorderLayout.NORTH);
JPanel checkpanel2=new JPanel();
JPanel jokpanel=new JPanel();
checkpanel2.setBackground(Color.pink);
jokpanel.setBackground(Color.pink);
jokpanel.add(jok3);
jokpanel.add(cancle);
checkpanel.setLayout(new GridLayout(0,1));
checkpanel.add(new JLabel("请输入查询的课程"));
checkpanel.add(clesson);
checkpanel.add(new JLabel("请输入要查询的专业"));
checkpanel.add(cclass);
checkpanel2.setLayout(new BorderLayout());
checkpanel2.add(checkpanel,BorderLayout.NORTH);
getContentPane().add(checkpanel2,BorderLayout.CENTER);
getContentPane().add(jokpanel,BorderLayout.SOUTH);
this.setBackground(Color.pink);
jok3.addActionListener(this);
clesson.addActionListener(this);
cclass.addActionListener(this);
cancle.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(jok3==e.getSource()){
Print p=new Print(elesson[clesson.getSelectedIndex()],
eclass[cclass.getSelectedIndex()]);
p.setSize(350,400);
p.setTitle(elesson[clesson.getSelectedIndex()]+"成绩单");
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth=screenSize.width;
int screenHeight=screenSize.height;
x=(screenWidth-p.getWidth())/2;
y=(screenHeight-p.getWidth())/2;
p.setLocation(x,y);
p.setVisible(true);
}
else if(cancle==e.getSource()){
this.dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -