Saturday, June 12, 2021

Addition of Three Numbers Using Swing in Java

A simple graphical user interface that I wrote using netbeans and Java programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.






Program Listing

Main_Menu.java

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

package com.jakerpomperada.addition_three_numbers;

import javax.swing.*;  

import javax.swing.event.*;

import java.awt.*;



/**

 *

 * @author Jacob Samuel

 */

public class Main_Menu extends javax.swing.JFrame {


    /**

     * Creates new form Main_Menu

     */

    public Main_Menu() {

        initComponents();

        

    }


    /**

     * 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">                          

    private void initComponents() {


        jRadioButton1 = new javax.swing.JRadioButton();

        label1 = new java.awt.Label();

        label2 = new java.awt.Label();

        label3 = new java.awt.Label();

        label4 = new java.awt.Label();

        textField1 = new java.awt.TextField();

        textField2 = new java.awt.TextField();

        textField3 = new java.awt.TextField();

        textField4 = new java.awt.TextField();

        button1 = new java.awt.Button();

        button2 = new java.awt.Button();

        button3 = new java.awt.Button();

        button4 = new java.awt.Button();


        jRadioButton1.setText("jRadioButton1");


        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        setTitle("Addition of Three Numbers in Swing Java");


        label1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        label1.setName(""); // NOI18N

        label1.setText("Enter Second Value");


        label2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        label2.setName(""); // NOI18N

        label2.setText("Enter First Value");


        label3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        label3.setName(""); // NOI18N

        label3.setText("Enter Third Value");


        label4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        label4.setName(""); // NOI18N

        label4.setText("The Total Sum");


        textField1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N


        textField2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N


        textField3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N


        textField4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N


        button1.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N

        button1.setLabel("Solve");

        button1.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                button1ActionPerformed(evt);

            }

        });


        button2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N

        button2.setLabel("Clear");

        button2.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                button2ActionPerformed(evt);

            }

        });


        button3.setActionCommand("Quit");

        button3.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N

        button3.setLabel("Quit");

        button3.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                button3ActionPerformed(evt);

            }

        });


        button4.setActionCommand("Quit");

        button4.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N

        button4.setLabel("About");

        button4.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                button4ActionPerformed(evt);

            }

        });


        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(32, 32, 32)

                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

                    .addGroup(layout.createSequentialGroup()

                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                        .addGap(14, 14, 14)

                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

                            .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(textField2, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(textField3, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)))

                    .addGroup(layout.createSequentialGroup()

                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))

                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addGroup(layout.createSequentialGroup()

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                                .addComponent(textField4, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE))

                            .addGroup(layout.createSequentialGroup()

                                .addGap(52, 52, 52)

                                .addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)

                                .addGap(0, 0, Short.MAX_VALUE)))))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 80, Short.MAX_VALUE)

                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

                        .addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)

                        .addGap(39, 39, 39))

                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

                        .addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)

                        .addGap(31, 31, 31))))

        );

        layout.setVerticalGroup(

            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

                    .addGroup(layout.createSequentialGroup()

                        .addGap(23, 23, 23)

                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

                            .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                        .addGap(23, 23, 23)

                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(textField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                        .addGap(20, 20, 20)

                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(textField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                        .addGap(19, 19, 19)

                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(textField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51, Short.MAX_VALUE)

                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)))

                    .addGroup(layout.createSequentialGroup()

                        .addGap(73, 73, 73)

                        .addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)

                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                        .addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)))

                .addContainerGap())

        );


        label1.getAccessibleContext().setAccessibleName("");


        pack();

        setLocationRelativeTo(null);

    }// </editor-fold>                        


    private void button1ActionPerformed(java.awt.event.ActionEvent evt) {                                        

        // TODO add your handling code here:

                

        int a = Integer.parseInt(textField1.getText());

        int b = Integer.parseInt(textField2.getText());

        int c = Integer.parseInt(textField3.getText());

  

        if (evt.getSource().equals(button1)) {

           int sum = (a+b+c);

         

           textField4.setText(String.valueOf(sum));

           textField4.setEditable(false);

            

        }

    }                                       


    private void button2ActionPerformed(java.awt.event.ActionEvent evt) {                                        

        // TODO add your handling code here:

         if (evt.getSource().equals(button2)) {

           

             textField1.setText("");

             textField2.setText("");

             textField3.setText("");

             textField4.setText("");

             textField1.requestFocus();

        }

    }                                       


    private void button3ActionPerformed(java.awt.event.ActionEvent evt) {                                        

        // TODO add your handling code here:

        if (evt.getSource().equals(button3)) {

        

                     

    int confirmed = JOptionPane.showConfirmDialog(null, "Exit Program?","Quit Program",JOptionPane.YES_NO_OPTION);

    if(confirmed == JOptionPane.YES_OPTION)

    {

        dispose();

    }

} else {

            

     setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

       }

    }                                       


    private void button4ActionPerformed(java.awt.event.ActionEvent evt) {                                        

        // TODO add your handling code here:

        if (evt.getSource().equals(button4)) {

            

          String name = " Jake Rodriguez Pomperada, MAED-IT, MIT";

          String websites  = " www.jakerpomperada.com and www.jakerpomperada.blogspot.com";

          String email  = " jakerpomperada@gmail.com";

          String mobile = " +63 09173084360";

          String address = " Bacolod City, Negros Occidental Philippines";

          String lineSep = System.lineSeparator();

          

          StringBuilder result = new StringBuilder();

          result.append("About This Program ").append(lineSep).append(lineSep);

          result.append("Name       : ").append(name).append(lineSep);

          result.append("Websites   : ").append(websites).append(lineSep);

          result.append("Email        : ").append(email).append(lineSep);

          result.append("Mobile No. : ").append(mobile).append(lineSep);

          result.append("Address    : ").append(address);


          JOptionPane.showMessageDialog(null, result.toString());

                     

   

      } 

    }                                       


    /**

     * @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(Main_Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (InstantiationException ex) {

            java.util.logging.Logger.getLogger(Main_Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (IllegalAccessException ex) {

            java.util.logging.Logger.getLogger(Main_Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (javax.swing.UnsupportedLookAndFeelException ex) {

            java.util.logging.Logger.getLogger(Main_Menu.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 Main_Menu().setVisible(true);

            }

        });

    }


    // Variables declaration - do not modify                     

    private java.awt.Button button1;

    private java.awt.Button button2;

    private java.awt.Button button3;

    private java.awt.Button button4;

    private javax.swing.JRadioButton jRadioButton1;

    private java.awt.Label label1;

    private java.awt.Label label2;

    private java.awt.Label label3;

    private java.awt.Label label4;

    private java.awt.TextField textField1;

    private java.awt.TextField textField2;

    private java.awt.TextField textField3;

    private java.awt.TextField textField4;

    // End of variables declaration                   

}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jakerpomperada.addition_three_numbers;
import javax.swing.*;  
import javax.swing.event.*;
import java.awt.*;


/**
 *
 * @author Jacob Samuel
 */
public class Main_Menu extends javax.swing.JFrame {

    /**
     * Creates new form Main_Menu
     */
    public Main_Menu() {
        initComponents();
        
    }

    /**
     * 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">                          
    private void initComponents() {

        jRadioButton1 = new javax.swing.JRadioButton();
        label1 = new java.awt.Label();
        label2 = new java.awt.Label();
        label3 = new java.awt.Label();
        label4 = new java.awt.Label();
        textField1 = new java.awt.TextField();
        textField2 = new java.awt.TextField();
        textField3 = new java.awt.TextField();
        textField4 = new java.awt.TextField();
        button1 = new java.awt.Button();
        button2 = new java.awt.Button();
        button3 = new java.awt.Button();
        button4 = new java.awt.Button();

        jRadioButton1.setText("jRadioButton1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Addition of Three Numbers in Swing Java");

        label1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        label1.setName(""); // NOI18N
        label1.setText("Enter Second Value");

        label2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        label2.setName(""); // NOI18N
        label2.setText("Enter First Value");

        label3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        label3.setName(""); // NOI18N
        label3.setText("Enter Third Value");

        label4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        label4.setName(""); // NOI18N
        label4.setText("The Total Sum");

        textField1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        textField2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        textField3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        textField4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        button1.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        button1.setLabel("Solve");
        button1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button1ActionPerformed(evt);
            }
        });

        button2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        button2.setLabel("Clear");
        button2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button2ActionPerformed(evt);
            }
        });

        button3.setActionCommand("Quit");
        button3.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        button3.setLabel("Quit");
        button3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button3ActionPerformed(evt);
            }
        });

        button4.setActionCommand("Quit");
        button4.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        button4.setLabel("About");
        button4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button4ActionPerformed(evt);
            }
        });

        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(32, 32, 32)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(14, 14, 14)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textField2, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textField3, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(textField4, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(52, 52, 52)
                                .addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 80, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(31, 31, 31))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(23, 23, 23)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(19, 19, 19)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(73, 73, 73)
                        .addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        label1.getAccessibleContext().setAccessibleName("");

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>                        

    private void button1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
                
        int a = Integer.parseInt(textField1.getText());
        int b = Integer.parseInt(textField2.getText());
        int c = Integer.parseInt(textField3.getText());
  
        if (evt.getSource().equals(button1)) {
           int sum = (a+b+c);
         
           textField4.setText(String.valueOf(sum));
           textField4.setEditable(false);
            
        }
    }                                       

    private void button2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
         if (evt.getSource().equals(button2)) {
           
             textField1.setText("");
             textField2.setText("");
             textField3.setText("");
             textField4.setText("");
             textField1.requestFocus();
        }
    }                                       

    private void button3ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        if (evt.getSource().equals(button3)) {
        
                     
    int confirmed = JOptionPane.showConfirmDialog(null, "Exit Program?","Quit Program",JOptionPane.YES_NO_OPTION);
    if(confirmed == JOptionPane.YES_OPTION)
    {
        dispose();
    }
} else {
            
     setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
       }
    }                                       

    private void button4ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        if (evt.getSource().equals(button4)) {
            
          String name = " Jake Rodriguez Pomperada, MAED-IT, MIT";
          String websites  = " www.jakerpomperada.com and www.jakerpomperada.blogspot.com";
          String email  = " jakerpomperada@gmail.com";
          String mobile = " +63 09173084360";
          String address = " Bacolod City, Negros Occidental Philippines";
          String lineSep = System.lineSeparator();
          
          StringBuilder result = new StringBuilder();
          result.append("About This Program ").append(lineSep).append(lineSep);
          result.append("Name       : ").append(name).append(lineSep);
          result.append("Websites   : ").append(websites).append(lineSep);
          result.append("Email        : ").append(email).append(lineSep);
          result.append("Mobile No. : ").append(mobile).append(lineSep);
          result.append("Address    : ").append(address);

          JOptionPane.showMessageDialog(null, result.toString());
                     
   
      } 
    }                                       

    /**
     * @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(Main_Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Main_Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Main_Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Main_Menu.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 Main_Menu().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private java.awt.Button button1;
    private java.awt.Button button2;
    private java.awt.Button button3;
    private java.awt.Button button4;
    private javax.swing.JRadioButton jRadioButton1;
    private java.awt.Label label1;
    private java.awt.Label label2;
    private java.awt.Label label3;
    private java.awt.Label label4;
    private java.awt.TextField textField1;
    private java.awt.TextField textField2;
    private java.awt.TextField textField3;
    private java.awt.TextField textField4;
    // End of variables declaration                   
}


pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.jakerpomperada</groupId>
    <artifactId>Addition_Three_Numbers</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.jakerpomperada.addition_three_numbers.Main_Menu</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>






Console Password in C++

Console Password in C++

 I simple console password in C++ language that I wrote which uses asterisk to hide the password. I hope you will like my work.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Program Listing

password.cpp

// password.cpp

// Jake Rodriguez Pomperada, MAED-IT, MIT

// www.jakerpomperada.com and www.jakerpomperada.blogspot.com

// jakerpomperada@gmail.com

// Bacolod City, Negros Occidental Philippines


#include <iostream>

#include <string>

#include <cstdio>

#include <conio.h>


int main()

{

  back:

     const std::string password("admin");

     std::string input;

     char c;


     std::cout << "\n==============================";

     std::cout << "\nConsole Password in C++";

     std::cout << "\n==============================";

     std::cout << "\n\n";


     std::cout << "Give Your Password: ";

     do

     {

         c = _getch();

         if( isprint(c) )

         {

             input += c;

             std::cout << '*';

         }

         else if( c == 8 && !input.empty())

         {

             input.pop_back();

             std::cout << "\b \b";

         }

     } while( c != 13 );

     std::cout <<"\n";

     if (input == password) {

         std::cout << "\nPassword is valid.\n";

         goto end;

        }

     else {

         std::cout << "\nInvalid password.\n";

        goto back;

     }

    end:

    std::cout <<"\n";

    std::cout <<"\tEnd of Program";

    std::cout <<"\n";

}