被禁言了可以解开吗

双匿 2017-11-03 10:31:13
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class JComplex extends JFrame implements ActionListener{

private JTextField text_a,text_b,text_c,text_d,text_e,text_f,text_g,text_h;


String a1[]={"+","-"};
JComboBox combox_a1=new JComboBox(a1);
String b1[]={"+","-"};
JComboBox combox_b1=new JComboBox(b1);


private JButton button_a;

public JComplex(){
super("复数表达式计算");
this.setBounds(300, 240, 800, 500);
this.setBackground(Color.lightGray);
this.setLayout(new GridLayout(4, 3, 3, 3));
this.add(new Label(" "));
text_a=new JTextField(10);
this.add(text_a);
this.add(new Label("+"));
text_b=new JTextField(10);
this.add(text_b);
this.add(new Label("i"));

this.add(combox_a1);
combox_a1.addActionListener(this);


text_c=new JTextField(10);
this.add(text_c);
this.add(new Label("+"));
text_d=new JTextField(10);
this.add(text_d);
this.add(new Label("i"));

this.add(combox_b1);
combox_b1.addActionListener(this);

text_e=new JTextField(10);
this.add(text_e);
this.add(new Label("+"));
text_f=new JTextField(10);
this.add(text_f);
this.add(new Label("i"));

button_a = new JButton("=");
this.add(button_a);
button_a.addActionListener(this);
text_g=new JTextField(10);
this.add(text_g);
this.add(new Label("+"));
text_h=new JTextField(10);
this.add(text_h);
this.add(new Label("i"));

this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}






public void actionPerformed(ActionEvent ev) {

int a=0;int b=0;
if(ev.getSource() ==combox_a1)
{
int i=this.combox_a1.getSelectedIndex();
if(i == 0)
{
String str=text_a.getText();
a=Integer.parseInt(str);

String str1=text_c.getText();
a=a+Integer.parseInt(str1);

String str3=text_b.getText();
b=Integer.parseInt(str3);
String str4=text_d.getText();
b=b+Integer.parseInt(str4);
}
else{
String str=text_a.getText();
a=Integer.parseInt(str);
String str1=text_c.getText();
a=a-Integer.parseInt(str1);

String str3=text_b.getText();
b=Integer.parseInt(str3);
String str4=text_d.getText();
b=b-Integer.parseInt(str4);
}

}
if(ev.getSource() ==combox_b1)
{
int i=this.combox_b1.getSelectedIndex();
if(i==0)
{
String str=text_e.getText();
a=a+Integer.parseInt(str);

String str1=text_f.getText();
b=b+Integer.parseInt(str1);
}
else{
String str=text_e.getText();
a=a-Integer.parseInt(str);

String str1=text_f.getText();
b=b-Integer.parseInt(str1);
}
}
if(ev.getSource() ==button_a)
{
text_g.setText(""+a);
text_h.setText(""+b);
}
}







public static void main(String arg[]) {
new JComplex();
}

}
运行出的结果最底下两个文本框都是0,为什么actionPerformed里a,b赋初值为0,最后结果还是0,还有为什么组合框选“-”减号的时候会有异常。

下午问了个问题不知道怎么就被禁言了,说有敏感词汇
...全文
483 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_43582773 2018-12-31
  • 打赏
  • 举报
回复
难道就不能解禁吗……

6,129

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 新技术前沿
社区管理员
  • 新技术前沿社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧