Advertisement
polpoteu

JAVA Okienka Kreator

Dec 20th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.75 KB | None | 0 0
  1. package e9Okienko;
  2.  
  3. public class OknoGlowne extends javax.swing.JFrame {
  4.  
  5. public OknoGlowne() {
  6. initComponents();
  7. }
  8.  
  9. @SuppressWarnings("unchecked")
  10. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  11. private void initComponents() {
  12.  
  13. liczba1 = new javax.swing.JTextField();
  14. liczba2 = new javax.swing.JTextField();
  15. dodawanie = new javax.swing.JButton();
  16. razy = new javax.swing.JButton();
  17. Wyjscie2 = new javax.swing.JLabel();
  18. Wyjscie1 = new javax.swing.JLabel();
  19. Minus = new javax.swing.JButton();
  20. Wyjscie3 = new javax.swing.JLabel();
  21.  
  22. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  23.  
  24. liczba1.setText("0");
  25.  
  26. liczba2.setText("0");
  27.  
  28. dodawanie.setText("Dodaj");
  29. dodawanie.addActionListener(new java.awt.event.ActionListener() {
  30. public void actionPerformed(java.awt.event.ActionEvent evt) {
  31. dodawanieActionPerformed(evt);
  32. }
  33. });
  34.  
  35. razy.setText("Razy");
  36. razy.addActionListener(new java.awt.event.ActionListener() {
  37. public void actionPerformed(java.awt.event.ActionEvent evt) {
  38. razyActionPerformed(evt);
  39. }
  40. });
  41.  
  42. Wyjscie2.setText("Wynik");
  43.  
  44. Wyjscie1.setText("Wynik");
  45.  
  46. Minus.setText("Odejmij");
  47. Minus.addActionListener(new java.awt.event.ActionListener() {
  48. public void actionPerformed(java.awt.event.ActionEvent evt) {
  49. MinusActionPerformed(evt);
  50. }
  51. });
  52.  
  53. Wyjscie3.setText("Wynik");
  54.  
  55. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  56. getContentPane().setLayout(layout);
  57. layout.setHorizontalGroup(
  58. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  59. .addGroup(layout.createSequentialGroup()
  60. .addGap(21, 21, 21)
  61. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  62. .addComponent(liczba2, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)
  63. .addComponent(liczba1))
  64. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  65. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  66. .addContainerGap(239, Short.MAX_VALUE)
  67. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
  68. .addComponent(Minus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  69. .addComponent(razy, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  70. .addComponent(dodawanie, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  71. .addGap(18, 18, 18)
  72. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  73. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  74. .addComponent(Wyjscie2, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
  75. .addComponent(Wyjscie1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
  76. .addComponent(Wyjscie3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
  77. .addContainerGap())
  78. );
  79. layout.setVerticalGroup(
  80. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  81. .addGroup(layout.createSequentialGroup()
  82. .addContainerGap()
  83. .addComponent(liczba1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  84. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  85. .addComponent(liczba2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  86. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 151, Short.MAX_VALUE)
  87. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  88. .addComponent(Minus)
  89. .addComponent(Wyjscie3, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
  90. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  91. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  92. .addComponent(razy)
  93. .addComponent(Wyjscie2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
  94. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  95. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  96. .addComponent(dodawanie)
  97. .addComponent(Wyjscie1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
  98. .addContainerGap())
  99. );
  100.  
  101. pack();
  102. }// </editor-fold>
  103.  
  104. private void dodawanieActionPerformed(java.awt.event.ActionEvent evt) {
  105. int a = Integer.parseInt(liczba1.getText());
  106. int b = Integer.parseInt(liczba2.getText());
  107. int wynik = a + b;
  108. Wyjscie1.setText(String.valueOf(wynik));
  109. Wyjscie1.setText(""+wynik);
  110. }
  111.  
  112. private void razyActionPerformed(java.awt.event.ActionEvent evt) {
  113. int a = Integer.parseInt(liczba1.getText());
  114. int b = Integer.parseInt(liczba2.getText());
  115. int wynik = a * b;
  116. Wyjscie2.setText(String.valueOf(wynik));
  117. Wyjscie2.setText(""+wynik);
  118. }
  119.  
  120. private void MinusActionPerformed(java.awt.event.ActionEvent evt) {
  121. int a = Integer.parseInt(liczba1.getText());
  122. int b = Integer.parseInt(liczba2.getText());
  123. int wynik = a - b;
  124. Wyjscie3.setText(String.valueOf(wynik));
  125. Wyjscie3.setText(""+wynik);
  126. }
  127.  
  128. public static void main(String args[]) {
  129. /* Set the Nimbus look and feel */
  130. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  131. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  132. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  133. */
  134. try {
  135. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  136. if ("Nimbus".equals(info.getName())) {
  137. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  138. break;
  139. }
  140. }
  141. } catch (ClassNotFoundException ex) {
  142. java.util.logging.Logger.getLogger(OknoGlowne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  143. } catch (InstantiationException ex) {
  144. java.util.logging.Logger.getLogger(OknoGlowne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  145. } catch (IllegalAccessException ex) {
  146. java.util.logging.Logger.getLogger(OknoGlowne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  147. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  148. java.util.logging.Logger.getLogger(OknoGlowne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  149. }
  150. //</editor-fold>
  151.  
  152. /* Create and display the form */
  153. java.awt.EventQueue.invokeLater(new Runnable() {
  154. public void run() {
  155. new OknoGlowne().setVisible(true);
  156. }
  157. });
  158. }
  159.  
  160. // Variables declaration - do not modify
  161. private javax.swing.JButton Minus;
  162. private javax.swing.JLabel Wyjscie1;
  163. private javax.swing.JLabel Wyjscie2;
  164. private javax.swing.JLabel Wyjscie3;
  165. private javax.swing.JButton dodawanie;
  166. private javax.swing.JTextField liczba1;
  167. private javax.swing.JTextField liczba2;
  168. private javax.swing.JButton razy;
  169. // End of variables declaration
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement