java一个编写简单的计算器的一个程序问题 得按要求做呜呜呜
界面我已经编程好了得用trycatch,然后如果输入的不是数字要弹出警告的对话框拜托拜托求好心人帮忙importjava.awt.*;importjavax.swing....
界面我已经编程好了 得用try catch,然后如果输入的不是数字要弹出警告的对话框 拜托拜托求好心人帮忙
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Haha extends JFrame {
JTextField jtf = new JTextField(10);
JButton add = new JButton("+");
JTextField jttf = new JTextField(10);
JButton equal = new JButton("=");
JTextField jtttf = new JTextField(10);
FlowLayout layout = new FlowLayout();
public static void main(String args[]){
Haha ha = new Haha("Calculate");
}
public Haha(String title){
super(title);
Container ct = getContentPane();
ct.setLayout(layout);
ct.add(jtf);
ct.add(add);
ct.add(jttf);
ct.add(equal);
ct.add(jtttf);
this.setSize(490,80);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
} 展开
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Haha extends JFrame {
JTextField jtf = new JTextField(10);
JButton add = new JButton("+");
JTextField jttf = new JTextField(10);
JButton equal = new JButton("=");
JTextField jtttf = new JTextField(10);
FlowLayout layout = new FlowLayout();
public static void main(String args[]){
Haha ha = new Haha("Calculate");
}
public Haha(String title){
super(title);
Container ct = getContentPane();
ct.setLayout(layout);
ct.add(jtf);
ct.add(add);
ct.add(jttf);
ct.add(equal);
ct.add(jtttf);
this.setSize(490,80);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询