zoukankan      html  css  js  c++  java
  • 成绩

    package j;

    import java.awt.Frame;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;

    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JTextField;

    public class j {

    public static void main(String[] args)
    {

    Frame f=new Frame();
    f.setLayout(null);//自由布局
    f.setTitle("成绩判定");//设置标题
    f.setSize(586, 540);//调整大小
    f.setLocation(100, 100);//设置窗口位置
    JLabel l1=new JLabel("成绩");
    l1.setBounds(200, 150, 50, 50);
    f.add(l1);
    JTextField t=new JTextField("请输入成绩");
    t.setBounds(300, 160, 100, 30);
    f.add(t);
    JButton b1=new JButton("确定");
    JButton b2=new JButton("取消");
    b1.setBounds(200,230,80,30);
    f.add(b1);
    b2.setBounds(320,230,80,30);
    f.add(b2);
    t.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    t.setText("");}
    });
    b1.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    {
    String s;
    s=t.getText();
    try
    {
    int a = 0;
    a= Integer.parseInt(s);
    if(a<60&&a>=0)
    {
    JOptionPane.showMessageDialog(null, "不及格");
    }
    else if(a<70&&a>=0)
    {
    JOptionPane.showMessageDialog(null, "及格");
    }
    else if(a<80&&a>=0)
    {
    JOptionPane.showMessageDialog(null, "中");
    }
    else if(a<90&&a>=0)
    {
    JOptionPane.showMessageDialog(null, "良");
    }
    else if(a<=100&&a>=0)
    {
    JOptionPane.showMessageDialog(null, "优");
    }
    else
    {
    JOptionPane.showMessageDialog(null, "输入错误");
    }
    }
    catch (NumberFormatException e1)
    {

    JOptionPane.showMessageDialog(null, "输入错误");
    }

    }
    });
    b2.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    {

    System.exit(0);
    }
    });
    f.addWindowListener
    (
    new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    }
    }
    );
    Icon i1 = new ImageIcon("2.jpg");

    JLabel bg=new JLabel(i1);
    bg.setBounds(0,0, 586,540);
    f.add(bg);
    f.setVisible(true);//显示窗口


    }
    }

  • 相关阅读:
    背水一战 Windows 10 (90)
    背水一战 Windows 10 (89)
    背水一战 Windows 10 (88)
    背水一战 Windows 10 (87)
    背水一战 Windows 10 (86)
    背水一战 Windows 10 (85)
    背水一战 Windows 10 (84)
    背水一战 Windows 10 (83)
    背水一战 Windows 10 (82)
    背水一战 Windows 10 (81)
  • 原文地址:https://www.cnblogs.com/love-xi/p/4967680.html
Copyright © 2011-2022 走看看