189 8069 5689

java实现计算器-创新互联

import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextField;

成都创新互联始终坚持【策划先行,效果至上】的经营理念,通过多达10年累计超上千家客户的网站建设总结了一套系统有效的营销推广解决方案,现已广泛运用于各行各业的客户,其中包括:成都食品包装袋等企业,备受客户赞美。

public class Myclass  extends JFrame {
private JPanel jp1,jp2;
private JButton jb;
private JTextField display1, display2, display3;
private JMenuBar jmb;
private JMenu jm;
private JMenuItem jmi;
private final String[] firstmenu = { "查看(V)", "编辑(E)", "帮助(H)" };
private final String[][] secondMenu = {
{ "标准型", "科学型", "程序员", "统计信息", "历史信息", "数字分组", "基本", "单位转换",
"日期计算", "工作表" }, { "复制(C)", "粘贴(P)", "历史记录" },
{ "查看帮助(V)", "关于计算器(A)" } };
private final char[] Mnemonic = { 'V', 'E', 'H' };
private String buttonsName[]={"MC","MR","MS","M+","M-",
"←","CE","C","±","√",
"7","8","9","/","%",
"4","5","6","*","1/x",
"1","2","3","-","=",
"0",".","+"};

public Myclass(){
for (int i = 0; i < buttonsName.length; i++) {
jb = new JButton(buttonsName[i]);
if (i == 24) {
jb.setBounds(i % 5 (35 +7),65 + i /5 (29 + 7), 35, 65);
} else if (i ==25) {
jb.setBounds(i % 5 (35 +7),65 + i /5 (29 + 7), 77, 29);
} else if (i > 25) {
jb.setBounds(i % 5 (35 +7)+5+42,65 + i /5 (29 + 7), 35,29);
} else {
jb.setBounds(i % 5 (35 +7),65 + i /5 (29 + 7), 35, 29);//测量长宽和间距
}
jb.setMarigin(new java.awt.Insets(0,0,0,0) );
thsi.add(jb);
{

}{
}
}
this.setTitle("计算器");display2 = new JTextField("0");
display2.setBounds(12, 12, 190, 50);
display2.setFont(new Font("宋体", Font.BOLD, 26));
display2.setHorizontalAlignment(JLabel.RIGHT);
display2.setEnabled(false);
display2.setDisabledTextColor(Color.BLACK);
display2.setBackground(new Color(247, 250, 254));
this.add(display2);
this.setLayout(null);
this.setTitle("计算器");
this.setLocation(500, 200);
this.setSize(230, 320);
this.setBackground(new Color(217, 228, 241));
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}

public static void main(String[] args) {

new Myclass();

}

}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


新闻标题:java实现计算器-创新互联
地址分享:http://cdxtjz.cn/article/dgeged.html

其他资讯