java鼠标点没用_java编译无错,但鼠标点击无反应

import t.event.*;import javax.swing.*;public class calculator extends JFrame implements ActionListener{ JTextField txt0; JButton

import t.event.*;import javax.swing.*;public class calculator extends JFrame implements ActionListener{ JTextField txt0; JButton a1,a2,a3,a4,a5,a6,a7,a8,a9,a0,b0,b1,b2,b3,b4,b5; int n1=0,n2=0; int flag=0; public static void main (String[] args) { calculator JFrame = new calculator(); tBounds(100, 100, 222, 294); tTitle("计算器"); } public calculator() { // TODO Auto-generated method stub getContentPane().setLayout(null); setResizable(false); JTextField txt0= new JTextField("0"); tHorizontalAlignment(SwingConstants.RIGHT); JButton b0 = new JButton("清空");JButton b1 = new JButton("+"); JButton a3 = new JButton("3");JButton a2 = new JButton("2"); JButton a1 = new JButton("1");JButton a4 = new JButton("4"); JButton a5 = new JButton("5");JButton a6 = new JButton("6"); JButton b2 = new JButton("-");JButton b3 = new JButton("*"); JButton a9 = new JButton("9");JButton a7 = new JButton("7"); JButton a8 = new JButton("8");JButton a0 = new JButton("0"); JButton b4 = new JButton("/");JButton b5 = new JButton("="); getContentPane().add(txt0); getContentPane().add(b0);getContentPane().add(b1);getContentPane().add(a3);getContentPane().add(a2); getContentPane().add(a1);getContentPane().add(a4);getContentPane().add(a5);getContentPane().add(a6); getContentPane().add(b2);getContentPane().add(b3);getContentPane().add(a9);getContentPane().add(a7); getContentPane().add(a8);getContentPane().add(a0);getContentPane().add(b4);getContentPane().add(b5); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); tBounds(10, 11, 129, 21); tBounds(149, 10, 65, 21); tBounds(163, 42, 42, 21); tBounds(111, 42, 42, 21); tBounds(59, 42, 42, 21); tBounds(10, 42, 42, 21); tBounds(10, 88, 42, 21); tBounds(59, 88, 42, 21); tBounds(111, 88, 42, 21); tBounds(163, 88, 42, 21); tBounds(163, 134, 42, 21); tBounds(111, 134, 42, 21); tBounds(10, 134, 42, 21); tBounds(59, 134, 42, 21); tBounds(10, 182, 143, 21); tBounds(163, 182, 42, 21); tBounds(10, 230, 195, 21); validate(); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if( tSource()==a1) { tText( tText()+"1"); } else if( tSource()==a2) { tText( tText()+"2"); } else if( tSource()==a3) { tText( tText()+"3"); } else if( tSource()==a4) { tText( tText()+"4"); } else if( tSource()==a5) { tText( tText()+"5"); } else if( tSource()==a6) { tText( tText()+"6"); } else if( tSource()==a7) { tText( tText()+"7"); } else if( tSource()==a8) { tText( tText()+"8"); } else if( tSource()==a9) { tText( tText()+"9"); } else if( tSource()==a0) { tText( tText()+"0"); } else if( tSource()==b1) { n1= rseInt( tText()); tText("+"); flag=1; } else if( tSource()==b2) { n1= rseInt( tText()); tText("-"); flag=2; } else if( tSource()==b3) { n1= rseInt( tText()); tText("*"); flag=3; } else if( tSource()==b4) { n1= rseInt( tText()); tText("/"); flag=4; } else if( tSource()==b5) { n2= rseInt( tText()); tText(null); switch(flag) { case 1: tText( lueOf(n1+n2));break; case 2: tText( lueOf(n1-n2));break; case 3: tText( lueOf(n1*n2));break; case 4: tText( lueOf(n1/n2));break; } } else if( tSource()==b0) { tText("0"); } } }

展开

全部

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值