資源描述:
《java圖形界面編寫(xiě)計(jì)算器》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫(kù)。
1、packagecom.inspur.calculator;importjava.awt.BorderLayout;importjavax.swing.JDialog;importjavax.swing.JPanel;importjavax.swing.JFrame;importjavax.swing.JTextField;importjavax.swing.UIManager;importjavax.swing.UnsupportedLookAndFeelException;importjava.awt.Color;importjava.awt.Font;importjava.a
2、wt.Rectangle;importjava.awt.GridBagLayout;importjava.awt.Dimension;importjava.awt.Point;importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.JButton;importjavax.swing.plaf.FontUIResource;publicclassCalculatorextendsJFrame{privatestat
3、icfinallongserialVersionUID=1L;privateJPanelcp=null;JTextFieldtf=null;privateJPanelpn=null;privateJPanelpn1=null;privateJPanelpn2=null;privateJButtonbl=null;privateJButtonbo=null;privateJButtonb1=null;privateJButtonb09=null;privateJButtonbc=null;privateJButtonb31=null;privateJButtonb4=null;pr
4、ivateJButtonb8=null;privateJButtonb6=null;privateJButtonb7=null;privateJButtonb2=null;privateJButtonbb=null;privateJButtonb06=null;privateJButtonb04=null;privateJButtonbd=null;privateJButtonb05=null;privateJButtonb03=null;privateJButtonba=null;Monitor1m1=newMonitor1(this);/***Thisisthedefault
5、constructor*/publicCalculator(){super();initialize();}/***Thismethodinitializesthis**@returnvoid*/privatevoidinitialize(){this.setSize(300,200);this.setContentPane(getCp());this.setTitle("JFrame");this.setResizable(false);this.setVisible(true);}/***Thismethodinitializescp**@returnjavax.swing.
6、JPanel*/privateJPanelgetCp(){if(cp==null){cp=newJPanel();cp.setLayout(null);cp.add(getTf(),null);cp.add(getPn(),null);}returncp;}/***Thismethodinitializestf**@returnjavax.swing.JTextField*/privateJTextFieldgetTf(){if(tf==null){tf=newJTextField();tf.setLocation(newPoint(1,0));tf.setSize(newDim
7、ension(282,20));tf.setHorizontalAlignment(JTextField.RIGHT);}returntf;}/***Thismethodinitializespn**@returnjavax.swing.JPanel*/privateJPanelgetPn(){if(pn==null){pn=newJPanel();pn.setLayout(newBorderLayout());pn.setBounds(newRectangle(2,17,280