Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package e9Okienko;
- public class OknoGlowne extends javax.swing.JFrame {
- public OknoGlowne() {
- initComponents();
- }
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- liczba1 = new javax.swing.JTextField();
- liczba2 = new javax.swing.JTextField();
- dodawanie = new javax.swing.JButton();
- razy = new javax.swing.JButton();
- Wyjscie2 = new javax.swing.JLabel();
- Wyjscie1 = new javax.swing.JLabel();
- Minus = new javax.swing.JButton();
- Wyjscie3 = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- liczba1.setText("0");
- liczba2.setText("0");
- dodawanie.setText("Dodaj");
- dodawanie.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- dodawanieActionPerformed(evt);
- }
- });
- razy.setText("Razy");
- razy.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- razyActionPerformed(evt);
- }
- });
- Wyjscie2.setText("Wynik");
- Wyjscie1.setText("Wynik");
- Minus.setText("Odejmij");
- Minus.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- MinusActionPerformed(evt);
- }
- });
- Wyjscie3.setText("Wynik");
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(21, 21, 21)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(liczba2, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)
- .addComponent(liczba1))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap(239, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addComponent(Minus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(razy, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(dodawanie, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(Wyjscie2, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(Wyjscie1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(Wyjscie3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(liczba1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(liczba2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 151, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(Minus)
- .addComponent(Wyjscie3, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(razy)
- .addComponent(Wyjscie2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(dodawanie)
- .addComponent(Wyjscie1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap())
- );
- pack();
- }// </editor-fold>
- private void dodawanieActionPerformed(java.awt.event.ActionEvent evt) {
- int a = Integer.parseInt(liczba1.getText());
- int b = Integer.parseInt(liczba2.getText());
- int wynik = a + b;
- Wyjscie1.setText(String.valueOf(wynik));
- Wyjscie1.setText(""+wynik);
- }
- private void razyActionPerformed(java.awt.event.ActionEvent evt) {
- int a = Integer.parseInt(liczba1.getText());
- int b = Integer.parseInt(liczba2.getText());
- int wynik = a * b;
- Wyjscie2.setText(String.valueOf(wynik));
- Wyjscie2.setText(""+wynik);
- }
- private void MinusActionPerformed(java.awt.event.ActionEvent evt) {
- int a = Integer.parseInt(liczba1.getText());
- int b = Integer.parseInt(liczba2.getText());
- int wynik = a - b;
- Wyjscie3.setText(String.valueOf(wynik));
- Wyjscie3.setText(""+wynik);
- }
- 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(OknoGlowne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(OknoGlowne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(OknoGlowne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(OknoGlowne.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 OknoGlowne().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton Minus;
- private javax.swing.JLabel Wyjscie1;
- private javax.swing.JLabel Wyjscie2;
- private javax.swing.JLabel Wyjscie3;
- private javax.swing.JButton dodawanie;
- private javax.swing.JTextField liczba1;
- private javax.swing.JTextField liczba2;
- private javax.swing.JButton razy;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement