package com.wgtgt.frame; import java.awt.Component; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import com.wgtgt.event.CalculatorEvent; import qq.qq757225051.CompMap; import qq.qq757225051.Controller; public class CalculatorFrame extends JFrame{ private static final long serialVersionUID = -7708488346250753415L; private CalculatorEvent event=new CalculatorEvent(); public CalculatorFrame(){ setTitle("计算器"); setLocation(400,300); setSize(400,300); add(createPanel()); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } private Component createPanel() { JPanel jp=new JPanel(); jp.setLayout(new GridLayout(4,1,5,5)); jp.add(createPanel_r1()); jp.add(createPanel_r2()); jp.add(createPanel_r3()); jp.add(createPanel_r4()); return jp; } private Component createPanel_r1() { JPanel jp=new JPanel(); JLabel jl=new JLabel("第一个数"); JTextField jt=new JTextField(10); CompMap.put("jt_one",jt);//将控件备份到公用区,以便在在其他地方调用。 jp.add(jl); jp.add(jt); return jp; } private Component createPanel_r2() { JPanel jp=new JPanel(); JLabel jl=new JLabel("第二个数"); JTextField jt=new JTextField(10); CompMap.put("jt_two",jt);//将控件备份到公用区,以便在在其他地方调用。 jp.add(jl); jp.add(jt); return jp; } private Component createPanel_r3() { JPanel jp=new JPanel(); JLabel jl=new JLabel("运算结果"); JTextField jt=new JTextField(10); CompMap.put("jt_result",jt);//将控件备份到公用区,以便在在其他地方调用。 jt.setEditable(false); jp.add(jl); jp.add(jt); return jp; } private Component createPanel_r4() { JPanel jp=new JPanel(); JButton jb1=new JButton("+"); JButton jb2=new JButton("-"); JButton jb3=new JButton("*"); JButton jb4=new JButton("/"); Controller.event(jb1, event, "plus");//事件代码 Controller.event(jb2, event, "minus");//事件代码 Controller.event(jb3, event, "multiply");//事件代码 Controller.event(jb4, event, "divide");//事件代码 jp.add(jb1); jp.add(jb2); jp.add(jb3); jp.add(jb4); return jp; } /** * @param args */ public static void main(String[] args) { new CalculatorFrame(); } }

fantaohaofan LV2
2022年6月23日
wyx065747 LV67
2022年3月9日
四喜美瞳 LV1
2021年5月20日
lizhenlinok LV10
2021年1月11日
ccqq123456 LV2
2020年11月1日
落寞烟草味 LV3
2020年9月9日
y6622576 LV9
2020年6月13日
yongzheng132 LV17
2019年6月24日
ljy LV2
2019年4月8日
xutpcb LV2
2018年11月1日

flygrass LV12
2023年12月7日
fantaohaofan LV2
2022年6月23日
w13314
2022年4月2日
暂无贡献等级
佩奇弯腰耍大刀 LV1
2021年10月13日
一个好人520 LV10
2021年9月29日
yiyi2000
2021年8月17日
暂无贡献等级
liuxuegong
2021年7月27日
暂无贡献等级
小林哥哥爱吃肉 LV1
2021年5月31日
四喜美瞳 LV1
2021年5月20日
lizhenlinok LV10
2021年1月11日