一个小问题帮我看看该怎样写!!! http://expert.csdn.net/Expert/topic/864/864971.xml?temp=.1970941 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个问题的问题是这个问题跟java又什么关系吗? 我主要是没有学过java的语法,同学要我帮我呀!第二个问题答了后,一起给分! import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.applet.*;import java.sql.*;public class bean9 extends JFrame {JPanel contentPanel=(JPanel)this.getContentPane();JPanel jp=new JPanel(new GridLayout(4,1));JTextField jtf1=new JTextField(5);JTextField jtf2=new JTextField(5);ButtonGroup jbg=new ButtonGroup();JRadioButton jrb1=new JRadioButton("+");JRadioButton jrb2=new JRadioButton("-");JRadioButton jrb3=new JRadioButton("*");JRadioButton jrb4=new JRadioButton("/");JButton jb=new JButton("=");JLabel jl=new JLabel();public bean9() {this.setSize(400,300);this.setResizable(false);this.setLocation(this.getToolkit().getScreenSize().width/2-this.getWidth()/2,this.getToolkit().getScreenSize().height/2-this.getHeight()/2);this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);contentPanel.setLayout(new FlowLayout());contentPanel.add(jtf1);contentPanel.add(jp);jp.add(jrb1);jp.add(jrb2);jp.add(jrb3);jp.add(jrb4);jbg.add(jrb1);jbg.add(jrb2);jbg.add(jrb3);jbg.add(jrb4);jrb1.setSelected(true);contentPanel.add(jtf2);contentPanel.add(jb);contentPanel.add(jl);jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myDO(e); }});this.setVisible(true);}public void myDO(ActionEvent e) {double d1,d2;String d3="";java.text.DecimalFormat df=new java.text.DecimalFormat(".###");try { d1=Double.parseDouble(this.jtf1.getText()); d2=Double.parseDouble(this.jtf2.getText()); if(jrb1.isSelected()) d3=df.format(d1+d2); if(jrb2.isSelected()) d3=df.format(d1-d2); if(jrb3.isSelected()) d3=df.format(d1*d2); if(jrb4.isSelected()) d3=df.format(d1/d2); this.jl.setText(d3);}catch(Exception ex) { JOptionPane.showMessageDialog(this,"两个输入框必须输入数字!","ERROR",JOptionPane.ERROR_MESSAGE); return;}}public static void main(String args[]) {new bean9();}} java定时器产生的延迟问题 oracle ORA-00911: 无效字符 问题 JAVA乘法精度的问题 有关java的 来拿分了~~我想做个1到1000之间偶数的总和,奇数的总和,不知道该怎么做了。高手赐教 ftp下载问题---急用 一个illegal character in URL 的问题.大哥们帮帮忙吧! 关于Swing.border的问题 JBuilder安装问题??? 请问JAVA中的适配器模式和策略模式的区别在哪 请问:JWindow不支持键盘时间吗? 关于数组的问题。
第二个问题答了后,一起给分!
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.sql.*;public class bean9 extends JFrame {
JPanel contentPanel=(JPanel)this.getContentPane();
JPanel jp=new JPanel(new GridLayout(4,1));
JTextField jtf1=new JTextField(5);
JTextField jtf2=new JTextField(5);
ButtonGroup jbg=new ButtonGroup();
JRadioButton jrb1=new JRadioButton("+");
JRadioButton jrb2=new JRadioButton("-");
JRadioButton jrb3=new JRadioButton("*");
JRadioButton jrb4=new JRadioButton("/");
JButton jb=new JButton("=");
JLabel jl=new JLabel();
public bean9() {
this.setSize(400,300);
this.setResizable(false);
this.setLocation(this.getToolkit().getScreenSize().width/2-this.getWidth()/2,this.getToolkit().getScreenSize().height/2-this.getHeight()/2);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
contentPanel.setLayout(new FlowLayout());
contentPanel.add(jtf1);
contentPanel.add(jp);
jp.add(jrb1);
jp.add(jrb2);
jp.add(jrb3);
jp.add(jrb4);
jbg.add(jrb1);
jbg.add(jrb2);
jbg.add(jrb3);
jbg.add(jrb4);
jrb1.setSelected(true);
contentPanel.add(jtf2);
contentPanel.add(jb);
contentPanel.add(jl);
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myDO(e);
}
});
this.setVisible(true);
}public void myDO(ActionEvent e) {
double d1,d2;
String d3="";
java.text.DecimalFormat df=new java.text.DecimalFormat(".###");
try {
d1=Double.parseDouble(this.jtf1.getText());
d2=Double.parseDouble(this.jtf2.getText());
if(jrb1.isSelected())
d3=df.format(d1+d2);
if(jrb2.isSelected())
d3=df.format(d1-d2);
if(jrb3.isSelected())
d3=df.format(d1*d2);
if(jrb4.isSelected())
d3=df.format(d1/d2);
this.jl.setText(d3);
}catch(Exception ex) {
JOptionPane.showMessageDialog(this,"两个输入框必须输入数字!","ERROR",JOptionPane.ERROR_MESSAGE);
return;
}
}public static void main(String args[]) {
new bean9();
}
}