-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewJFrame.java
More file actions
521 lines (450 loc) · 25.8 KB
/
NewJFrame.java
File metadata and controls
521 lines (450 loc) · 25.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
import java.awt.Color;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
/**
*
* @author LENOVO
*/
import java.awt.*;
public class NewJFrame extends javax.swing.JFrame {
String operators = null;
double number1 = 0, number2 = 0;
/**
* Creates new form NewJFrame
*/
public NewJFrame() {
initComponents();
buans.setBackground(Color.green);
bu1.setBackground(Color.black);
bu1.setForeground(Color.white);
bu2.setBackground(Color.black);
bu2.setForeground(Color.white);
bu3.setBackground(Color.black);
bu3.setForeground(Color.white);
bu4.setBackground(Color.black);
bu4.setForeground(Color.white);
bu5.setBackground(Color.black);
bu5.setForeground(Color.white);
bu6.setBackground(Color.black);
bu6.setForeground(Color.white);
bu7.setBackground(Color.black);
bu7.setForeground(Color.white);
bu8.setBackground(Color.black);
bu8.setForeground(Color.white);
bu9.setBackground(Color.black);
bu9.setForeground(Color.white);
jButton12.setBackground(Color.black);
jButton12.setForeground(Color.white);
buadd.setBackground(Color.gray);
buadd.setForeground(Color.white);
busub.setBackground(Color.gray);
busub.setForeground(Color.white);
bumulti.setBackground(Color.gray);
bumulti.setForeground(Color.white);
budivi.setBackground(Color.gray);
budivi.setForeground(Color.white);
budel.setBackground(Color.darkGray);
budel.setForeground(Color.white);
buc.setBackground(Color.darkGray);
buc.setForeground(Color.white);
budot.setBackground(Color.orange);
budot.setForeground(Color.green);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
tf = new javax.swing.JTextField();
budel = new javax.swing.JButton();
bu9 = new javax.swing.JButton();
bu8 = new javax.swing.JButton();
buans = new javax.swing.JButton();
bu7 = new javax.swing.JButton();
bu6 = new javax.swing.JButton();
bu5 = new javax.swing.JButton();
bu4 = new javax.swing.JButton();
bu3 = new javax.swing.JButton();
bu2 = new javax.swing.JButton();
bu1 = new javax.swing.JButton();
jButton12 = new javax.swing.JButton();
budot = new javax.swing.JButton();
buadd = new javax.swing.JButton();
buc = new javax.swing.JButton();
busub = new javax.swing.JButton();
bumulti = new javax.swing.JButton();
budivi = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Segoe UI Black", 1, 18)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("CALCULATOR");
jLabel1.setPreferredSize(new java.awt.Dimension(84, 29));
tf.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
tf.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
tf.setBorder(null);
budel.setText("DEL");
budel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
budelActionPerformed(evt);
}
});
bu9.setText("9");
bu9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bu9ActionPerformed(evt);
}
});
bu8.setText("8");
bu8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bu8ActionPerformed(evt);
}
});
buans.setText("ANS");
buans.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buansActionPerformed(evt);
}
});
bu7.setText("7");
bu7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bu7ActionPerformed(evt);
}
});
bu6.setText("6");
bu6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bu6ActionPerformed(evt);
}
});
bu5.setText("5");
bu5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bu5ActionPerformed(evt);
}
});
bu4.setText("4");
bu4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bu4ActionPerformed(evt);
}
});
bu3.setText("3");
bu3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bu3ActionPerformed(evt);
}
});
bu2.setText("2");
bu2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bu2ActionPerformed(evt);
}
});
bu1.setText("1");
bu1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bu1ActionPerformed(evt);
}
});
jButton12.setText("0");
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});
budot.setText(".");
budot.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
budotActionPerformed(evt);
}
});
buadd.setText("+");
buadd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buaddActionPerformed(evt);
}
});
buc.setText("C");
buc.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bucActionPerformed(evt);
}
});
busub.setText("-");
busub.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
busubActionPerformed(evt);
}
});
bumulti.setText("*");
bumulti.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bumultiActionPerformed(evt);
}
});
budivi.setText("/");
budivi.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
budiviActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tf, javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(25, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(budel, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buc, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(budivi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(busub, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(bumulti, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(bu7, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(bu8, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(bu9, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(bu4, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(bu5, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(bu6, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buadd, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(bu1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(bu2, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(bu3, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(budot, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buans, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(2, 2, 2))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(tf, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bu9, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bu8, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bu7, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bu6, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bu5, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bu4, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(buadd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bu3, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bu2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bu1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(budot, javax.swing.GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE)
.addComponent(jButton12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buans, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(budel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(busub, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(bumulti, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(budivi, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void bu4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bu4ActionPerformed
tf.setText(tf.getText()+"4");
// TODO add your handling code here:
}//GEN-LAST:event_bu4ActionPerformed
private void buansActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buansActionPerformed
// TODO add your handling code here:
number2 = Double.parseDouble(tf.getText());
double result = 0;
if(operators=="+")
result=number1+number2;
else if(operators=="-")
result=number1-number2;
else if(operators=="*")
result=number1*number2;
else if(operators=="/")
result=number1/number2;
tf.setText(result+"");
operators=null;
}//GEN-LAST:event_buansActionPerformed
private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
tf.setText(tf.getText()+"0");
// TODO add your handling code here:
}//GEN-LAST:event_jButton12ActionPerformed
private void budotActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_budotActionPerformed
tf.setText(tf.getText()+".");
// TODO add your handling code here:
}//GEN-LAST:event_budotActionPerformed
private void bu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bu1ActionPerformed
// TODO add your handling code here:
tf.setText(tf.getText()+"1");
}//GEN-LAST:event_bu1ActionPerformed
private void buaddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buaddActionPerformed
// TODO add your handling code here:
number1 = Double.parseDouble(tf.getText());
tf.setText("");
operators = "+";
}//GEN-LAST:event_buaddActionPerformed
private void bu8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bu8ActionPerformed
tf.setText(tf.getText()+"8");
// TODO add your handling code here:
}//GEN-LAST:event_bu8ActionPerformed
private void budelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_budelActionPerformed
// TODO add your handling code here:
tf.setText("");
}//GEN-LAST:event_budelActionPerformed
private void bumultiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bumultiActionPerformed
// TODO add your handling code here:
number1 = Double.parseDouble(tf.getText());
tf.setText("");
operators = "*";
}//GEN-LAST:event_bumultiActionPerformed
private void budiviActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_budiviActionPerformed
// TODO add your handling code here:
number1 = Double.parseDouble(tf.getText());
tf.setText("");
operators = "/";
}//GEN-LAST:event_budiviActionPerformed
private void bu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bu2ActionPerformed
// TODO add your handling code here:
tf.setText(tf.getText()+"2");
}//GEN-LAST:event_bu2ActionPerformed
private void bu3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bu3ActionPerformed
tf.setText(tf.getText()+"3");
// TODO add your handling code here:
}//GEN-LAST:event_bu3ActionPerformed
private void bu5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bu5ActionPerformed
tf.setText(tf.getText()+"5");
// TODO add your handling code here:
}//GEN-LAST:event_bu5ActionPerformed
private void bu6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bu6ActionPerformed
tf.setText(tf.getText()+"6");
// TODO add your handling code here:
}//GEN-LAST:event_bu6ActionPerformed
private void bu7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bu7ActionPerformed
tf.setText(tf.getText()+"7");
// TODO add your handling code here:
}//GEN-LAST:event_bu7ActionPerformed
private void bu9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bu9ActionPerformed
tf.setText(tf.getText()+"9");
// TODO add your handling code here:
}//GEN-LAST:event_bu9ActionPerformed
private void busubActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_busubActionPerformed
// TODO add your handling code here:
number1 = Double.parseDouble(tf.getText());
tf.setText("");
operators = "-";
}//GEN-LAST:event_busubActionPerformed
private void bucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bucActionPerformed
// TODO add your handling code here:
String s = tf.getText();
tf.setText(s.substring(0,s.length()-1));
}//GEN-LAST:event_bucActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton bu1;
private javax.swing.JButton bu2;
private javax.swing.JButton bu3;
private javax.swing.JButton bu4;
private javax.swing.JButton bu5;
private javax.swing.JButton bu6;
private javax.swing.JButton bu7;
private javax.swing.JButton bu8;
private javax.swing.JButton bu9;
private javax.swing.JButton buadd;
private javax.swing.JButton buans;
private javax.swing.JButton buc;
private javax.swing.JButton budel;
private javax.swing.JButton budivi;
private javax.swing.JButton budot;
private javax.swing.JButton bumulti;
private javax.swing.JButton busub;
private javax.swing.JButton jButton12;
private javax.swing.JLabel jLabel1;
private javax.swing.JTextField tf;
// End of variables declaration//GEN-END:variables
}