• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

作業部屋の使い方を試しています。


Commit MetaInfo

Revision5 (tree)
Time2014-05-29 15:38:35
Authortuna_p

Log Message

(empty log message)

Change Summary

Incremental Difference

--- NumberAddition/src/my/numberaddition/NumberAdditionUI.java (revision 4)
+++ NumberAddition/src/my/numberaddition/NumberAdditionUI.java (revision 5)
@@ -50,8 +50,18 @@
5050 jLabel3.setText("Result");
5151
5252 jButton1.setText("Clear");
53+ jButton1.addActionListener(new java.awt.event.ActionListener() {
54+ public void actionPerformed(java.awt.event.ActionEvent evt) {
55+ jButton1ActionPerformed(evt);
56+ }
57+ });
5358
5459 jButton2.setText("Add");
60+ jButton2.addActionListener(new java.awt.event.ActionListener() {
61+ public void actionPerformed(java.awt.event.ActionEvent evt) {
62+ jButton2ActionPerformed(evt);
63+ }
64+ });
5565
5666 javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
5767 jPanel1.setLayout(jPanel1Layout);
@@ -102,6 +112,11 @@
102112 );
103113
104114 jButton3.setText("Exit");
115+ jButton3.addActionListener(new java.awt.event.ActionListener() {
116+ public void actionPerformed(java.awt.event.ActionEvent evt) {
117+ jButton3ActionPerformed(evt);
118+ }
119+ });
105120
106121 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
107122 getContentPane().setLayout(layout);
@@ -122,6 +137,30 @@
122137 pack();
123138 }// </editor-fold>//GEN-END:initComponents
124139
140+ private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
141+ System.exit(0);
142+ }//GEN-LAST:event_jButton3ActionPerformed
143+
144+ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
145+ jTextField1.setText("");
146+ jTextField2.setText("");
147+ jTextField3.setText("");
148+ }//GEN-LAST:event_jButton1ActionPerformed
149+
150+ private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
151+ // First we define float variables.
152+ float num1, num2, result;
153+ // We have to parse the text to a type float.
154+ num1 = Float.parseFloat(jTextField1.getText());
155+ num2 = Float.parseFloat(jTextField2.getText());
156+ // Now we can perform the addition.
157+ result = num1+num2;
158+ // We will now pass the value of result to jTextField3.
159+ // At the same time, we are going to
160+ // change the value of result from a float to a string.
161+ jTextField3.setText(String.valueOf(result));
162+ }//GEN-LAST:event_jButton2ActionPerformed
163+
125164 /**
126165 * @param args the command line arguments
127166 */