• 大小: 8KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-23
  • 语言: Java
  • 标签: Java  小学数学  

资源简介

本资源是利用Java语言编写,实现了基本的加减运算。可以选择每次做的题目的个数。

资源截图

代码片段和文件信息

package mathAddSub;

import javax.swing.*;

import java.awt.*;
import java.awt.event.*;

public class MathAddSub {
public static void main(String[] args) {

ChoseType ct = new ChoseType();
ct.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
ct.show();
}

}

//界面布局
class ChoseType extends Jframe implements KeyListener ActionListener {
public Timer timer;

public static final int width = 550;

public static final int height = 360;

public int num1 num2 resultnum;

public String getint str1;

private JLabel result num type;

private JLabel timu tishi term jieguo;

private JPanel select combox boot siti p1 p2p3;

private ButtonGroup group;

private JButton show;

public JComboBox box;

private String Buttontext = ““;

public JRadioButton jrb1 jrb2;

public JTextField text;;

public Container con;

public ChoseType() {
//timer = new Timer(3000 this);
settitle(“小学生数学测试题!“);
con = getContentPane();
setSize(width height);
timu = new JLabel(“练习题“ JLabel.CENTER);
timu.setFont(new Font(“宋体“ Font.BOLD 16));
timu.setForeground(Color.blue);

con.add(timu BorderLayout.NORTH);
boot = new JPanel();
select = new JPanel();
type = new JLabel(“请选择题型:“);
type.setFont(new Font(“宋体“ Font.BOLD 14));
type.setForeground(Color.red);
select.add(type);
// select.setSize(400300);
group = new ButtonGroup();

boot.add(select BorderLayout.NORTH);
// con.add(selectBorderLayout.CENTER);

combox = new JPanel();
box = new JComboBox();
box.setEditable(true);
box.addItem(“5“);
box.addItem(“10“);
box.addItem(“15“);
box.addItem(“20“);
box.addItem(“25“);
box.addItem(“30“);
box.addItem(“35“);
box.addItem(“40“);

num = new JLabel(“题目个数:“);
num.setFont(new Font(“宋体“ Font.BOLD 14));
num.setForeground(Color.red);
// combox.setLayout(new GridLayout(14));
combox.add(num);
combox.add(box);
show = new JButton(“开始答题“);
combox.add(show BorderLayout.EAST);
// 控件注册监听器

// con.add(comboxBorderLayout.SOUTH);

boot.add(combox BorderLayout.CENTER);

// 显示试题

siti = new JPanel();
siti.setVisible(false);
tishi = new JLabel(“输入答案后按回车键判断是否正确!“);
// tishi.show(false);
tishi.setForeground(Color.white);
tishi.setFont(new Font(“宋体“ Font.BOLD 16));
siti.setLayout(new GridLayout(2 1));
siti.add(tishi BorderLayout.NORTH);
p2 = new JPanel();

p2.setLayout(new BorderLayout());
term = new JLabel();
term.setSize(150 20);
        p3=new JPanel();
      
text = new JTextField(““);
text.setLayout(new FlowLayout());
text.setBounds(150100 20 10);
// text.setLayout(new BorderLayout());
text.setFont(new Font(“Arial“ Font.BOLD 20));
text.setForeground(Color.black);
text.setVisible(true);
text.addKeyListener(this);
        //p3.add(text);
// text.setLocation(185150);
p2.add(term BorderLayout.WEST);
p2.add(text 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        380  2010-08-30 10:19  Math\.project

     文件        226  2010-08-30 10:19  Math\.classpath

     文件       6896  2010-08-31 15:37  Math\mathAddSub\MathAddSub.java

     文件        556  2010-09-02 21:42  Math\mathAddSub\MathAddSub.class

     文件       7551  2010-09-02 21:42  Math\mathAddSub\ChoseType.class

     文件       1844  2010-09-02 21:42  Math\mathAddSub\ChoseType$jobslistener.class

     目录          0  2010-09-01 13:12  Math\mathAddSub

     目录          0  2010-09-01 13:12  Math

----------- ---------  ---------- -----  ----

                17453                    8


评论

共有 条评论