java监视器不好使_给跪了·=· 实在不知道为啥了 求解救监视器

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

package javaSwing;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import javax.swing.*;

class exx3_1 extends JFrame implements ActionListener{

Box v1;

JTextField input1, input2, input3;

ActionListener listener;

public exx3_1() {

// TODO Auto-generated constructor stub

setBounds(600,150,300,400);//默认本容器对象的

init();

input3.setEditable(false);

setVisible(true);

setResizable(false);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

void init() {

setTitle("三条腿的青蛙");//默认是此Jframe 底层容器

input1 = new JTextField();

input2 = new JTextField();

input3 = new JTextField();

v1=Box.createVerticalBox();

v1.add(new JLabel("哈哈 算数开始啦"));

v1.add(Box.createVerticalStrut(50));

v1.add(input1);

v1.add(Box.createVerticalStrut(50));

v1.add(input2);

v1.add(Box.createVerticalStrut(50));

v1.add(input3);

v1.add(new JLabel("翻滚吧 牛宝宝"));//为啥jlabel不回收啊 明明是临时创建的啊

add(v1);

input3.addActionListener(listener);//加上监听器

input1.addActionListener(listener);

}

@Override

public void actionPerformed(ActionEvent e) {

// TODO 自动生成的方法存根

if(e.getSource()==input1){

int h=Integer.parseInt(input1.getText());

if (100<=h||h<=200){

}

else {

JOptionPane.showMessageDialog(v1,"请输入100-200之内的数字","消息对话框",JOptionPane.WARNING_MESSAGE);

}

}

else if(e.getSource()==input3){

input3.setText(String.valueOf(Integer.parseInt(input1.getText())+Integer.parseInt(input2.getText())));

}

}

}

public class EX3_1 {

public static void main(String[] args) {

// TODO Auto-generated method stub

exx3_1 hehe;

hehe = new exx3_1();

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值