牧场java源代码 牧场玩法( 五 )


case 3: temp=temp1*temp2;break;
case 4: temp=temp1/temp2;break;
}
result=Double.valueOf(temp).toString();
value1=result;
value2="";
flag=1;
text.setText(result);
}
});
final JButton buttonpoint=new JButton(".");
c.add(buttonpoint);
buttonpoint.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{if(flagsum==0)
{
String temp;
if(flag==0 )
{
value1=value1+".";
temp=value1;
}
else
{
value2=value2+".";
temp=value2;
}
flagsum=1;
text.setText(temp);
}
}
});
JButton buttonz=new JButton("Start");
c.add(buttonz);
buttonz.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{if(sum%2==1)
{
happy=true;
text.setText("0.");
flag=0;
}
else
{
happy=false;
value1="";
value2="";
text.setText("");
}
text.setEnabled(happy);
button1.setEnabled(happy);
button2.setEnabled(happy);
button3.setEnabled(happy);
button4.setEnabled(happy);
button5.setEnabled(happy);
button6.setEnabled(happy);
button7.setEnabled(happy);
button8.setEnabled(happy);
button9.setEnabled(happy);
button0.setEnabled(happy);
buttonx.setEnabled(happy);
buttony.setEnabled(happy);
buttonadd.setEnabled(happy);
buttonsubtract.setEnabled(happy);
buttonpoint.setEnabled(happy);
buttonequal.setEnabled(happy);
buttoncheng.setEnabled(happy);
buttonchu.setEnabled(happy);
sum++;
}
});
button1.setEnabled(false);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);
button5.setEnabled(false);
button6.setEnabled(false);
button7.setEnabled(false);
button8.setEnabled(false);
button9.setEnabled(false);
button0.setEnabled(false);
buttonx.setEnabled(false);
buttony.setEnabled(false);
buttonadd.setEnabled(false);
buttonsubtract.setEnabled(false);
buttonpoint.setEnabled(false);
buttonequal.setEnabled(false);
buttoncheng.setEnabled(false);
buttonchu.setEnabled(false);
text.setEnabled(false);
text.setBounds(20, 20, 200, 40);
buttonx.setBounds(20, 60,100, 40);
buttony.setBounds(140, 60,100, 40);
buttonz.setBounds(260, 60,80, 40);
button1.setBounds(20, 120,60, 40);
button2.setBounds(100, 120,60, 40);
button3.setBounds(180, 120,60, 40);
buttonadd.setBounds(260, 120,60, 40);
button4.setBounds(20, 180,60, 40);
button5.setBounds(100, 180,60, 40);
button6.setBounds(180, 180,60, 40);
buttonsubtract.setBounds(260, 180,60, 40);
button7.setBounds(20, 240,60, 40);
button8.setBounds(100, 240,60, 40);
button9.setBounds(180, 240,60, 40);
buttoncheng.setBounds(260,240,60,40);
button0.setBounds(20, 300,60, 40);
buttonpoint.setBounds(100, 300, 60, 40);
buttonequal.setBounds(180,300,60, 40);
buttonchu.setBounds(260, 300,60, 40);
setVisible(true);
}
class MYMouseEvent extends MouseAdapter
{
public void mousePressed(MouseEvent e)
{
value1=e.toString();
text.setText(value1);
}
}
}
class Calutator
{
public static void main(String[] args)
{
newConstructFrame();
}
}
牧场java源代码你自己慢慢牧场java源代码的看吧牧场java源代码!
java课程设计源代码(急?。。。。?/h2>import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

推荐阅读