用J2ME编写的手机计算器中如何增加MS,MR,MC以及M+功能呀,用RMS如何才能实现,求具体代码…
1个回答
展开全部
我写的 MS,MR,MC以及M+功能,自己改改吧
private JButton getJButton24() {
if (jButton24 == null) {
jButton24 = new JButton();
jButton24.setFocusable(false);
jButton24.setBounds(new Rectangle(3, 156, 46, 35));
jButton24.setMargin(new Insets(0, 0, 0, 0));
jButton24.setText("MR");
jButton24.setForeground(new Color(51, 51, 252));
jButton24.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
str=String.valueOf(m);
jTextField1.setText(str+".");
}
});
}
return jButton24;
}
/**
* This method initializes jButton25
*
* @return javax.swing.JButton
*/
private JButton getJButton25() {
if (jButton25 == null) {
jButton25 = new JButton();
jButton25.setFocusable(false);
jButton25.setBounds(new Rectangle(3, 114, 46, 35));
jButton25.setMargin(new Insets(0, 0, 0, 0));
jButton25.setText("MC");
jButton25.setForeground(new Color(51, 51, 252));
jButton25.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
m=0;
jToggleButton1.setText("");
}
});
}
return jButton25;
}
/**
* This method initializes jButton26
*
* @return javax.swing.JButton
*/
private JButton getJButton26() {
if (jButton26 == null) {
jButton26 = new JButton();
jButton26.setFocusable(false);
jButton26.setBounds(new Rectangle(3, 197, 46, 35));
jButton26.setMargin(new Insets(0, 0, 0, 0));
jButton26.setText("MS");
jButton26.setForeground(new Color(51, 51, 252));
jButton26.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
m=Double.parseDouble(jTextField1.getText());
jToggleButton1.setText("M");
}
});
}
return jButton26;
}
/**
* This method initializes jButton27
*
* @return javax.swing.JButton
*/
private JButton getJButton27() {
if (jButton27 == null) {
jButton27 = new JButton();
jButton27.setFocusable(false);
jButton27.setBounds(new Rectangle(4, 238, 46, 35));
jButton27.setMargin(new Insets(0, 0, 0, 0));
jButton27.setText("M+");
jButton27.setForeground(new Color(51, 51, 252));
jButton27.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
m+=(double)Double.valueOf(jTextField1.getText());
}
});
}
return jButton27;
}
private JButton getJButton24() {
if (jButton24 == null) {
jButton24 = new JButton();
jButton24.setFocusable(false);
jButton24.setBounds(new Rectangle(3, 156, 46, 35));
jButton24.setMargin(new Insets(0, 0, 0, 0));
jButton24.setText("MR");
jButton24.setForeground(new Color(51, 51, 252));
jButton24.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
str=String.valueOf(m);
jTextField1.setText(str+".");
}
});
}
return jButton24;
}
/**
* This method initializes jButton25
*
* @return javax.swing.JButton
*/
private JButton getJButton25() {
if (jButton25 == null) {
jButton25 = new JButton();
jButton25.setFocusable(false);
jButton25.setBounds(new Rectangle(3, 114, 46, 35));
jButton25.setMargin(new Insets(0, 0, 0, 0));
jButton25.setText("MC");
jButton25.setForeground(new Color(51, 51, 252));
jButton25.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
m=0;
jToggleButton1.setText("");
}
});
}
return jButton25;
}
/**
* This method initializes jButton26
*
* @return javax.swing.JButton
*/
private JButton getJButton26() {
if (jButton26 == null) {
jButton26 = new JButton();
jButton26.setFocusable(false);
jButton26.setBounds(new Rectangle(3, 197, 46, 35));
jButton26.setMargin(new Insets(0, 0, 0, 0));
jButton26.setText("MS");
jButton26.setForeground(new Color(51, 51, 252));
jButton26.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
m=Double.parseDouble(jTextField1.getText());
jToggleButton1.setText("M");
}
});
}
return jButton26;
}
/**
* This method initializes jButton27
*
* @return javax.swing.JButton
*/
private JButton getJButton27() {
if (jButton27 == null) {
jButton27 = new JButton();
jButton27.setFocusable(false);
jButton27.setBounds(new Rectangle(4, 238, 46, 35));
jButton27.setMargin(new Insets(0, 0, 0, 0));
jButton27.setText("M+");
jButton27.setForeground(new Color(51, 51, 252));
jButton27.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
m+=(double)Double.valueOf(jTextField1.getText());
}
});
}
return jButton27;
}
更多追问追答
追问
不用RMS吗?那记忆功能是如何实现的呀
追答
MS是将当前屏幕上的文字存取,MC是将存取的数删除,MR是提取存取的数到屏幕,M+是将当前屏幕的文字与存取的数相加,并存到缓冲区
富港检测东莞有限公司
2024-12-25 广告
2024-12-25 广告
ISTA3L是一个基于研究、数据驱动的测试协议,它模拟了由零售公司完成的产品订单被直接运送给消费者时所经历的危险,它允许用户评估包装产品的能力,以承受运输和处理包装产品时所经历的供应链危险,从接收到任何电子商务零售商履行操作,直到最终消费者...
点击进入详情页
本回答由富港检测东莞有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询