用java写一个学生成绩管理系统程序,且有增加,查询,修改,删除,要求在控制台显示

2024-12-25 16:27:12
推荐回答(1个)
回答1:

我这边有个可视化编程的 当初的上机实验 可采纳
import java.awt.*;
import java.awt.event.*;
public class Test extends Frame implements TextListener,ItemListener,ActionListener,WindowListener
{

static TextArea ta1=new TextArea(" ",10,1,TextArea.SCROLLBARS_NONE);
static TextArea ta2=new TextArea(" ",10,1,TextArea.SCROLLBARS_NONE);
static Checkbox chk_g1=new Checkbox("男");
static Checkbox chk_g2=new Checkbox("女");
static Checkbox g=new Checkbox();
static Choice cho1=new Choice();
static Choice cho2=new Choice();
static Button bun1=new Button("增加");
static Button bun2=new Button("删除");
static List lst=new List();
static Test frm=new Test();
public static void main(String[] args)
{
Test frm=new Test();
CheckboxGroup grp=new CheckboxGroup();
frm.setLayout(null);
frm.setTitle("学生信息输入窗口");
frm.setBounds(100,100,400,400);
lst.setBounds(10,50,180,300);
ta1.setBounds(210,50,180,20);
ta2.setBounds(210,100,180,20);
chk_g1.setBounds(210,150,80,40);
chk_g2.setBounds(300,150,80,40);
cho1.setBounds(210,200,180,40);
cho2.setBounds(210,250,180,40);
bun1.setBounds(210,300,80,40);
bun2.setBounds(300,300,80,40);
chk_g1.setCheckboxGroup(grp);
chk_g2.setCheckboxGroup(grp);
cho1.add("计算机科学与技术");
cho1.add("金融系");
cho2.add("金融理财");
cho2.add("软件工程");
cho2.add("网络技术");
frm.setBackground(Color.lightGray);
ta1.setBackground(Color.lightGray);
ta2.setBackground(Color.lightGray);
lst.setBackground(Color.lightGray);
chk_g1.setBackground(Color.lightGray);
chk_g2.setBackground(Color.lightGray);
cho1.setBackground(Color.lightGray);
cho2.setBackground(Color.lightGray);
bun1.setBackground(Color.lightGray);
bun2.setBackground(Color.lightGray);
frm.add(ta1);
frm.add(ta2);
frm.add(chk_g1);
frm.add(chk_g2);
frm.add(cho1);
frm.add(cho2);
frm.add(bun1);
frm.add(bun2);
frm.add(lst);
ta1.addTextListener(frm);
ta2.addTextListener(frm);
chk_g1.addItemListener(frm);
chk_g2.addItemListener(frm);
cho1.addItemListener(frm);
cho2.addItemListener(frm);
bun1.addActionListener(frm);
bun2.addActionListener(frm);
lst.addItemListener(frm);
frm.addWindowListener(frm);
frm.setVisible(true);

}
public void windowOpened(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowClosing(WindowEvent e)
{
frm.dispose();
System.exit(0);
}
public void windowDeactivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void textValueChanged(TextEvent e)
{
}
public void itemStateChanged(ItemEvent e)
{
}
public void actionPerformed(ActionEvent e)
{
Button but=(Button)e.getSource();
if(but==bun1)
{
String text1=ta1.getText();
String text2=ta2.getText();
String c1=cho1.getSelectedItem();
String c2=cho2.getSelectedItem();
if(chk_g1.getState())
{
lst.add(text1+" "+text2+" "+chk_g1.getLabel()+" "+c1+" "+c2);
}
else if(chk_g2.getState())
{
lst.add(text1+" "+text2+" "+chk_g2.getLabel()+" "+c1+" "+c2);
}
}
else if(but==bun2)
{
String B=lst.getSelectedItem();
lst.remove(B);
}
}
}