📄 photo.java
字号:
//图形统计框架
//package grade;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Photo {
/**
* @param args
*/
//定义科目
public static String sub = "网络工程";
//定义主框架
private JFrame frame = new JFrame("分数段图形统计");
//定义标签
private JLabel JLcourse = new JLabel("科目");
private JLabel JLnum = new JLabel("人数");
// private JLabel JL1 = new JLabel();
// private JLabel JL2 = new JLabel();
// private JLabel JL3 = new JLabel();
// private JLabel JL4 = new JLabel();
// private JLabel JL5 = new JLabel();
//定义下拉列表
private String course[] = {"网络工程","操作系统","编译原理","软件工程","专业英语"};
private JComboBox JCBsubject = new JComboBox(course);
//定义面板
private Container con = frame.getContentPane();
private JPanel panel = new JPanel();
// private JPanel panelph = new JPanel();
// private panelGraphics panelph = new panelGraphics();
private Pane panelph = new Pane();
// 定义数据库操作对象
private DataManager manager = new DataManager();
//构造函数
public Photo(){
//框架大小
frame.setSize(400, 400);
frame.setLocation(200,200);
frame.setVisible(true);
frame.setDefaultCloseOperation(frame.DISPOSE_ON_CLOSE);
//把下拉列表加入面板
panel.setLayout(new FlowLayout());
panel.add(JLcourse);
panel.add(JCBsubject);
//设置显示图形的面板
panelph.setSize(300, 300);
//设置主面板
con.setLayout(new BorderLayout());
con.add(panel,BorderLayout.NORTH);
con.add(panelph,BorderLayout.CENTER);
//增加监听器
JCBsubject.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO 自动生成方法存根
sub = (String)JCBsubject.getSelectedItem();
panelph.repaint();
}});
}
//}
public static void main(String[] args) {
// TODO 自动生成方法存根
Photo a = new Photo();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -