这是我写的一个图形界面,事件响应还没写,一个空壳子,你看看把
package indexFrame;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.text.DateFormat;
import java.util.*;
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import java.awt.event.*;
public class IndexFrameOfSystem extends JFrame implements ActionListener {
public void launchFrame()
{
setFrameImage();
setFrameJMenu();
setFrameWindow();
this.setTitle("Student's call System");
this.setSize(450,600);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public void setFrameImage()
{
ImageIcon icon =new ImageIcon("src/image/Title.jpg");//换左上角图标
this.setIconImage(icon.getImage());
}
public void setFrameJMenu()
{
mb.add(menuFile);
mb.add(menuWindow); //各自添加组件
mb.add(menuHelp);
menuFile.add(menuItemImport);
menuFile.add(menuItemExit);
menuWindow.add(menuItemshowclassInformation);
menuHelp.add(menuItemabout);
this.setJMenuBar(mb);
}
JMenuBar mb=new JMenuBar(); //菜单项的创建
JMenu menuFile=new JMenu("文件");
JMenuItem menuItemImport=new JMenuItem("导入名单");
JMenuItem menuItemExit=new JMenuItem("退出");
JMenu menuWindow =new JMenu("窗口");
JMenuItem menuItemshowclassInformation=new JMenuItem("显示班级信息");
JMenu menuHelp=new JMenu("帮助");
JMenuItem menuItemabout=new JMenuItem("关于");
public void setFrameWindow()
{
this.setLayout(null);
title.setBounds(0,0,450,20);
this.add(title);
classdianmingButton.setBounds(40,40,100,50);
this.add(classdianmingButton);
classtiwenButton.setBounds(280,40,100,50);
this.add(classtiwenButton);
txTextArea.setEditable(false);//不能在上面打字
txTextArea.setBounds(40,120,280,150);
this.add(txTextArea);
xiyiweiButton.setBounds(330,130,80,50);
this.add(xiyiweiButton);
zhantingButton.setBounds(330,210,80,50);
this.add(zhantingButton);
quexiButton.setBounds(40,280,80,30);
bGroup.add(quexiButton);
qingjiaButton.setBounds(150,280,80,30);
bGroup.add(qingjiaButton);
zaotuiButton.setBounds(260,280,80,30);
bGroup.add(zaotuiButton);
this.add(quexiButton);
this.add(qingjiaButton);
this.add(zaotuiButton);
txtArea.setEditable(false);
txtField.setBounds(40,320,280,150);//注意添加坐标的是滚动面板,而不是JTextArea
this.add( txtField);
baochunJButton.setBounds(330,480,100,40);
this.add(baochunJButton);
menuItemImport.addActionListener(this);//监听器
classdianmingButton.addActionListener(this);
classtiwenButton.addActionListener(this);
xiyiweiButton.addActionListener(this);
zhantingButton.addActionListener(this);
quexiButton.addActionListener(this);
qingjiaButton.addActionListener(this);
zaotuiButton.addActionListener(this);
menuItemExit.addActionListener(this);
baochunJButton.addActionListener(this);
menuItemshowclassInformation.addActionListener(this);
menuItemabout.addActionListener(this);
}
JLabel title=new JLabel(" 江西农业大学点名系统");
private JButton classdianmingButton=new JButton("课堂点名");
private JButton classtiwenButton=new JButton("课堂提问");
private JTextField txTextArea=new JTextField();
private JButton xiyiweiButton=new JButton("下一位");
private JButton zhantingButton=new JButton("停止");
private JRadioButton quexiButton=new JRadioButton("缺席");
private JRadioButton qingjiaButton=new JRadioButton("请假");
private JRadioButton zaotuiButton=new JRadioButton("早退");
private ButtonGroup bGroup=new ButtonGroup();
private JTextArea txtArea=new JTextArea();
private JScrollPane txtField=new JScrollPane(txtArea);
private JButton baochunJButton=new JButton("保存名单");
public static void main(String[] args) {
// TODO Auto-generated method stub
IndexFrameOfSystem ui= new IndexFrameOfSystem();
ui.launchFrame();
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
温馨提示:答案为网友推荐,仅供参考