用netbeans编的简易计算器

来源:互联网 发布:nginx 并发连接数设置 编辑:程序博客网 时间:2024/05/22 00:29
 

用netbeans编的简易计算器

分类: java 313人阅读 评论(0) 收藏 举报

这学期开的java课一节都没听过,半个月前ZZG说要用简易计算器,说只实现+的功能就行可以ida编,这就大大降低了难度=。=虽然java我一堂课都没听过,但是迫于ZZG的威胁我在寝室憋了3个小时搞出来了,顺便也把java简单的了解一下,毕竟还有期末考试呢不是。

我的计算器实现了加减乘除以及负数运算,多的运算也懒得敲代码了,都是那回事吧。

java新手,大牛勿喷。

[java] view plaincopyprint?
  1.   /* 
  2.  * To change this template, choose Tools | Templates 
  3.  * and open the template in the editor. 
  4.  */  
  5. package javaapplication3;  
  6.   
  7.   
  8. /** 
  9.  * 
  10.  * @author admin 
  11.  */  
  12. import javax.swing.*;  
  13. import java.util.*;  
  14. public class NewJFrame extends javax.swing.JFrame {  
  15.   
  16.   
  17.     /** 
  18.      * Creates new form NewJFrame 
  19.      */  
  20.     int t =0;  
  21.     double num1=0;  
  22.     public NewJFrame() {  
  23.         initComponents();    
  24.     }  
  25.   
  26.   
  27.     /** 
  28.      * This method is called from within the constructor to initialize the form. 
  29.      * WARNING: Do NOT modify this code. The content of this method is always 
  30.      * regenerated by the Form Editor. 
  31.      */  
  32.     @SuppressWarnings("unchecked")  
  33.     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents  
  34.     private void initComponents() {  
  35.   
  36.   
  37.         jPanel1 = new javax.swing.JPanel();  
  38.         jTextField1 = new javax.swing.JTextField();  
  39.         jButton1 = new javax.swing.JButton();  
  40.         jButton2 = new javax.swing.JButton();  
  41.         jButton3 = new javax.swing.JButton();  
  42.         jButton13 = new javax.swing.JButton();  
  43.         jButton4 = new javax.swing.JButton();  
  44.         jButton5 = new javax.swing.JButton();  
  45.         jButton6 = new javax.swing.JButton();  
  46.         jButton7 = new javax.swing.JButton();  
  47.         jButton8 = new javax.swing.JButton();  
  48.         jButton9 = new javax.swing.JButton();  
  49.         jButton10 = new javax.swing.JButton();  
  50.         jButton12 = new javax.swing.JButton();  
  51.         jButton11 = new javax.swing.JButton();  
  52.         jButton14 = new javax.swing.JButton();  
  53.         jButton15 = new javax.swing.JButton();  
  54.         jButton16 = new javax.swing.JButton();  
  55.         jButton17 = new javax.swing.JButton();  
  56.   
  57.   
  58.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);  
  59.   
  60.   
  61.         jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("计算器"));  
  62.   
  63.   
  64.         jTextField1.addActionListener(new java.awt.event.ActionListener() {  
  65.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  66.                 jTextField1ActionPerformed(evt);  
  67.             }  
  68.         });  
  69.   
  70.   
  71.         jButton1.setText("1");  
  72.         jButton1.addActionListener(new java.awt.event.ActionListener() {  
  73.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  74.                 jButton1ActionPerformed(evt);  
  75.             }  
  76.         });  
  77.   
  78.   
  79.         jButton2.setText("2");  
  80.         jButton2.addActionListener(new java.awt.event.ActionListener() {  
  81.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  82.                 jButton2ActionPerformed(evt);  
  83.             }  
  84.         });  
  85.   
  86.   
  87.         jButton3.setText("3");  
  88.         jButton3.addActionListener(new java.awt.event.ActionListener() {  
  89.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  90.                 jButton3ActionPerformed(evt);  
  91.             }  
  92.         });  
  93.   
  94.   
  95.         jButton13.setText("+");  
  96.         jButton13.addActionListener(new java.awt.event.ActionListener() {  
  97.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  98.                 jButton13ActionPerformed(evt);  
  99.             }  
  100.         });  
  101.   
  102.   
  103.         jButton4.setText("4");  
  104.         jButton4.addActionListener(new java.awt.event.ActionListener() {  
  105.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  106.                 jButton4ActionPerformed(evt);  
  107.             }  
  108.         });  
  109.   
  110.   
  111.         jButton5.setText("5");  
  112.         jButton5.addActionListener(new java.awt.event.ActionListener() {  
  113.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  114.                 jButton5ActionPerformed(evt);  
  115.             }  
  116.         });  
  117.   
  118.   
  119.         jButton6.setText("6");  
  120.         jButton6.addActionListener(new java.awt.event.ActionListener() {  
  121.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  122.                 jButton6ActionPerformed(evt);  
  123.             }  
  124.         });  
  125.   
  126.   
  127.         jButton7.setText("7");  
  128.         jButton7.addActionListener(new java.awt.event.ActionListener() {  
  129.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  130.                 jButton7ActionPerformed(evt);  
  131.             }  
  132.         });  
  133.   
  134.   
  135.         jButton8.setText("8");  
  136.         jButton8.addActionListener(new java.awt.event.ActionListener() {  
  137.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  138.                 jButton8ActionPerformed(evt);  
  139.             }  
  140.         });  
  141.   
  142.   
  143.         jButton9.setText("9");  
  144.         jButton9.addActionListener(new java.awt.event.ActionListener() {  
  145.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  146.                 jButton9ActionPerformed(evt);  
  147.             }  
  148.         });  
  149.   
  150.   
  151.         jButton10.setText("0");  
  152.         jButton10.addActionListener(new java.awt.event.ActionListener() {  
  153.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  154.                 jButton10ActionPerformed(evt);  
  155.             }  
  156.         });  
  157.   
  158.   
  159.         jButton12.setText(".");  
  160.         jButton12.addActionListener(new java.awt.event.ActionListener() {  
  161.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  162.                 jButton12ActionPerformed(evt);  
  163.             }  
  164.         });  
  165.   
  166.   
  167.         jButton11.setText("=");  
  168.         jButton11.addActionListener(new java.awt.event.ActionListener() {  
  169.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  170.                 jButton11ActionPerformed(evt);  
  171.             }  
  172.         });  
  173.   
  174.   
  175.         jButton14.setText("clear");  
  176.         jButton14.addActionListener(new java.awt.event.ActionListener() {  
  177.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  178.                 jButton14ActionPerformed(evt);  
  179.             }  
  180.         });  
  181.   
  182.   
  183.         jButton15.setText("-");  
  184.         jButton15.addActionListener(new java.awt.event.ActionListener() {  
  185.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  186.                 jButton15ActionPerformed(evt);  
  187.             }  
  188.         });  
  189.   
  190.   
  191.         jButton16.setText("*");  
  192.         jButton16.addActionListener(new java.awt.event.ActionListener() {  
  193.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  194.                 jButton16ActionPerformed(evt);  
  195.             }  
  196.         });  
  197.   
  198.   
  199.         jButton17.setText("/");  
  200.         jButton17.addActionListener(new java.awt.event.ActionListener() {  
  201.             public void actionPerformed(java.awt.event.ActionEvent evt) {  
  202.                 jButton17ActionPerformed(evt);  
  203.             }  
  204.         });  
  205.   
  206.   
  207.         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);  
  208.         jPanel1.setLayout(jPanel1Layout);  
  209.         jPanel1Layout.setHorizontalGroup(  
  210.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
  211.             .addGroup(jPanel1Layout.createSequentialGroup()  
  212.                 .addGap(151515)  
  213.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)  
  214.                     .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)  
  215.                         .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.TRAILING)  
  216.                         .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()  
  217.                             .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
  218.                                 .addGroup(jPanel1Layout.createSequentialGroup()  
  219.                                     .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)  
  220.                                     .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)  
  221.                                     .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)  
  222.                                     .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)  
  223.                                     .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)  
  224.                                     .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)  
  225.                                     .addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))  
  226.                                 .addGroup(jPanel1Layout.createSequentialGroup()  
  227.                                     .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)  
  228.                                         .addGroup(jPanel1Layout.createSequentialGroup()  
  229.                                             .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
  230.                                                 .addGroup(jPanel1Layout.createSequentialGroup()  
  231.                                                     .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)  
  232.                                                     .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)  
  233.                                                     .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))  
  234.                                                 .addGroup(jPanel1Layout.createSequentialGroup()  
  235.                                                     .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)  
  236.                                                     .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)  
  237.                                                     .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)))  
  238.                                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)  
  239.                                             .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)  
  240.                                                 .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)  
  241.                                                 .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))  
  242.                                         .addGroup(jPanel1Layout.createSequentialGroup()  
  243.                                             .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)  
  244.                                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)  
  245.                                             .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)  
  246.                                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)  
  247.                                             .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)  
  248.                                             .addGap(222)))  
  249.                                     .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)  
  250.                                     .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
  251.                                         .addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)  
  252.                                         .addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)  
  253.                                         .addComponent(jButton17, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))))  
  254.                             .addGap(444)))  
  255.                     .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))  
  256.                 .addContainerGap(68, Short.MAX_VALUE))  
  257.         );  
  258.         jPanel1Layout.setVerticalGroup(  
  259.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
  260.             .addGroup(jPanel1Layout.createSequentialGroup()  
  261.                 .addGap(303030)  
  262.                 .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
  263.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)  
  264.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
  265.                     .addComponent(jButton1)  
  266.                     .addComponent(jButton2)  
  267.                     .addComponent(jButton3)  
  268.                     .addComponent(jButton13))  
  269.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)  
  270.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
  271.                     .addComponent(jButton4)  
  272.                     .addComponent(jButton5)  
  273.                     .addComponent(jButton6)  
  274.                     .addComponent(jButton15))  
  275.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)  
  276.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
  277.                     .addComponent(jButton7)  
  278.                     .addComponent(jButton8)  
  279.                     .addComponent(jButton9)  
  280.                     .addComponent(jButton16))  
  281.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)  
  282.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
  283.                     .addComponent(jButton10)  
  284.                     .addComponent(jButton12)  
  285.                     .addComponent(jButton17)  
  286.                     .addComponent(jButton14))  
  287.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)  
  288.                 .addComponent(jButton11)  
  289.                 .addContainerGap(19, Short.MAX_VALUE))  
  290.         );  
  291.   
  292.   
  293.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());  
  294.         getContentPane().setLayout(layout);  
  295.         layout.setHorizontalGroup(  
  296.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
  297.             .addGroup(layout.createSequentialGroup()  
  298.                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
  299.                 .addGap(06, Short.MAX_VALUE))  
  300.         );  
  301.         layout.setVerticalGroup(  
  302.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
  303.             .addGroup(layout.createSequentialGroup()  
  304.                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
  305.                 .addGap(016, Short.MAX_VALUE))  
  306.         );  
  307.   
  308.   
  309.         pack();  
  310.     }// </editor-fold>//GEN-END:initComponents  
  311.   
  312.   
  313.     private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed  
  314.         // TODO add your handling code here:  
  315.     }//GEN-LAST:event_jTextField1ActionPerformed  
  316.   
  317.   
  318.     private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed  
  319.         // TODO add your handling code here:  
  320.         jTextField1.setText("");  
  321.           
  322.           
  323.     }//GEN-LAST:event_jButton14ActionPerformed  
  324.   
  325.   
  326.     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed  
  327.       jTextField1.setText(jTextField1.getText()+"1");        // TODO add your handling code here:  
  328.     }//GEN-LAST:event_jButton1ActionPerformed  
  329.   
  330.   
  331.     private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed  
  332.      jTextField1.setText(jTextField1.getText()+"2");   // TODO add your handling code here:  
  333.     }//GEN-LAST:event_jButton2ActionPerformed  
  334.   
  335.   
  336.     private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed  
  337.         jTextField1.setText(jTextField1.getText()+"3");// TODO add your handling code here:  
  338.     }//GEN-LAST:event_jButton3ActionPerformed  
  339.   
  340.   
  341.     private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed  
  342. jTextField1.setText(jTextField1.getText()+"4");        // TODO add your handling code here:  
  343.     }//GEN-LAST:event_jButton4ActionPerformed  
  344.   
  345.   
  346.     private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed  
  347. jTextField1.setText(jTextField1.getText()+"5");        // TODO add your handling code here:  
  348.     }//GEN-LAST:event_jButton5ActionPerformed  
  349.   
  350.   
  351.     private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed  
  352. jTextField1.setText(jTextField1.getText()+"6");        // TODO add your handling code here:  
  353.     }//GEN-LAST:event_jButton6ActionPerformed  
  354.   
  355.   
  356.     private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed  
  357. jTextField1.setText(jTextField1.getText()+"7");        // TODO add your handling code here:  
  358.     }//GEN-LAST:event_jButton7ActionPerformed  
  359.   
  360.   
  361.     private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed  
  362. jTextField1.setText(jTextField1.getText()+"8");        // TODO add your handling code here:  
  363.     }//GEN-LAST:event_jButton8ActionPerformed  
  364.   
  365.   
  366.     private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed  
  367. jTextField1.setText(jTextField1.getText()+"9");        // TODO add your handling code here:  
  368.     }//GEN-LAST:event_jButton9ActionPerformed  
  369.   
  370.   
  371.     private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed  
  372. jTextField1.setText(jTextField1.getText()+"0");        // TODO add your handling code here:  
  373.     }//GEN-LAST:event_jButton10ActionPerformed  
  374. //+  
  375.     private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed  
  376.    num1 = Double.parseDouble(jTextField1.getText().toString());      
  377.    t=1;  
  378.    jTextField1.setText("");// TODO add your handling code here:  
  379.     }//GEN-LAST:event_jButton13ActionPerformed  
  380. //=  
  381.     private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed  
  382.    double num2 =Double.parseDouble(jTextField1.getText().toString())  ;     
  383.    if(t==1)  
  384.        jTextField1.setText(String.valueOf(num1+num2));  
  385.    if(t==2)  
  386.        jTextField1.setText(String.valueOf(num1-num2));  
  387.    if(t==3)  
  388.        jTextField1.setText(String.valueOf(num1*num2));  
  389.    if(t==4)  
  390.    {  
  391.        if(num2==0)  
  392.             jTextField1.setText("error");  
  393.        else  
  394.        jTextField1.setText(String.valueOf(num1/num2));  
  395.    }  
  396.        // TODO add your handling code here:  
  397.     }//GEN-LAST:event_jButton11ActionPerformed  
  398. //.  
  399.     private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed  
  400.     jTextField1.setText(jTextField1.getText()+".");        // TODO add your handling code here:  
  401.     }//GEN-LAST:event_jButton12ActionPerformed  
  402. //-  
  403.     private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed  
  404.     String  str=jTextField1.getText().toString();  
  405.     if(str.equals("")){  
  406.     jTextField1.setText("-");  
  407.     }  
  408.     else{  
  409.         num1 = Double.parseDouble(jTextField1.getText().toString());  
  410.         t=2;  
  411.         jTextField1.setText("");  
  412.     }    
  413.    // TODO add your handling code here:  
  414.     }//GEN-LAST:event_jButton15ActionPerformed  
  415. //*  
  416.     private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed  
  417.    num1 = Double.parseDouble(jTextField1.getText().toString());      
  418.    t=3;  
  419.    jTextField1.setText("");        // TODO add your handling code here:  
  420.     }//GEN-LAST:event_jButton16ActionPerformed  
  421. ///  
  422.     private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed  
  423.    num1 = Double.parseDouble(jTextField1.getText().toString());      
  424.    t=4;  
  425.    jTextField1.setText("");        // TODO add your handling code here:  
  426.     }//GEN-LAST:event_jButton17ActionPerformed  
  427.    
  428.     /**  
  429.      * @param args the command line arguments  
  430.      */  
  431.     public static void main(String args[]) {  
  432.         /* Set the Nimbus look and feel */  
  433.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">  
  434.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 
  435.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html  
  436.          */  
  437.         try {  
  438.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {  
  439.                 if ("Nimbus".equals(info.getName())) {  
  440.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());  
  441.                     break;  
  442.                 }  
  443.             }  
  444.         } catch (ClassNotFoundException ex) {  
  445.             java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
  446.         } catch (InstantiationException ex) {  
  447.             java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
  448.         } catch (IllegalAccessException ex) {  
  449.             java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
  450.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {  
  451.             java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
  452.         }  
  453.         //</editor-fold>  
  454.   
  455.   
  456.         /* Create and display the form */  
  457.         java.awt.EventQueue.invokeLater(new Runnable() {  
  458.             public void run() {  
  459.                 new NewJFrame().setVisible(true);  
  460.             }  
  461.         });  
  462.     }  
  463.     // Variables declaration - do not modify//GEN-BEGIN:variables  
  464.     private javax.swing.JButton jButton1;  
  465.     private javax.swing.JButton jButton10;  
  466.     private javax.swing.JButton jButton11;  
  467.     private javax.swing.JButton jButton12;  
  468.     private javax.swing.JButton jButton13;  
  469.     private javax.swing.JButton jButton14;  
  470.     private javax.swing.JButton jButton15;  
  471.     private javax.swing.JButton jButton16;  
  472.     private javax.swing.JButton jButton17;  
  473.     private javax.swing.JButton jButton2;  
  474.     private javax.swing.JButton jButton3;  
  475.     private javax.swing.JButton jButton4;  
  476.     private javax.swing.JButton jButton5;  
  477.     private javax.swing.JButton jButton6;  
  478.     private javax.swing.JButton jButton7;  
  479.     private javax.swing.JButton jButton8;  
  480.     private javax.swing.JButton jButton9;  
  481.     private javax.swing.JPanel jPanel1;  
  482.     private javax.swing.JTextField jTextField1;  
  483.     // End of variables declaration//GEN-END:variables  
  484. }  

不得不说netbeans是个神奇的东西,那么简单的代码居然能写出这么多行也是醉了=。=
0 0
原创粉丝点击