Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java GUI not working

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java GUI not working

    I am doing a project for my CSC class and I am having an issue with it.

    The program is suppsoed to accept inputs for cost of an item, 2 different down payments, interest rate, and amount of years for a loan.
    I created to program successfully without a GUI, but I am creating a GUI for it for bonus.

    I am using Netbeans form creator.

    I am unsure of how I am supposed to get the inputs to calculate and display in the correct fields.

    Here is what I have so far.

    PHP Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package midterm;

    /**
     *
     * @author Owner
     */
    public class GUI1 extends javax.swing.JFrame {

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

                
                
    long   downPayment1downPayment2pricefixedPrice1fixedPrice2;
                
    int    rateType;
                
    double timemonths;
                
    double totalPrice1totalPrice2monthlyPayment1monthlyPayment2
                
    double interest1interest2,  numTimeinterestRatenumberCompounded;
                

                
                
        
    /**
         * 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.
         */
     
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        
    private void initComponents() {

            
    jPanel1 = new javax.swing.JPanel();
            
    jLabel1 = new javax.swing.JLabel();
            
    jLabel3 = new javax.swing.JLabel();
            
    jTextField4 = new javax.swing.JTextField();
            
    jTextField5 = new javax.swing.JTextField();
            
    jLabel6 = new javax.swing.JLabel();
            
    jLabel7 = new javax.swing.JLabel();
            
    jLabel8 = new javax.swing.JLabel();
            
    jLabel9 = new javax.swing.JLabel();
            
    jTextField6 = new javax.swing.JTextField();
            
    jLabel10 = new javax.swing.JLabel();
            
    jLabel11 = new javax.swing.JLabel();
            
    jTextField7 = new javax.swing.JTextField();
            
    jLabel12 = new javax.swing.JLabel();
            
    jLabel13 = new javax.swing.JLabel();
            
    jTextField8 = new javax.swing.JTextField();
            
    jTextField9 = new javax.swing.JTextField();
            
    jLabel14 = new javax.swing.JLabel();
            
    jLabel15 = new javax.swing.JLabel();
            
    jLabel16 = new javax.swing.JLabel();
            
    jLabel17 = new javax.swing.JLabel();
            
    jLabel18 = new javax.swing.JLabel();
            
    jLabel19 = new javax.swing.JLabel();
            
    jLabel20 = new javax.swing.JLabel();
            
    jLabel21 = new javax.swing.JLabel();
            
    jLabel22 = new javax.swing.JLabel();
            
    jTextField10 = new javax.swing.JTextField();
            
    jTextField11 = new javax.swing.JTextField();
            
    jLabel23 = new javax.swing.JLabel();
            
    jLabel24 = new javax.swing.JLabel();
            
    jLabel25 = new javax.swing.JLabel();
            
    jLabel26 = new javax.swing.JLabel();
            
    jLabel27 = new javax.swing.JLabel();
            
    jLabel28 = new javax.swing.JLabel();
            
    jTextField12 = new javax.swing.JTextField();
            
    jButton1 = new javax.swing.JButton();
            
    jButton2 = new javax.swing.JButton();
            
    jTextField13 = new javax.swing.JTextField();
            
    jLabel29 = new javax.swing.JLabel();
            
    jLabel30 = new javax.swing.JLabel();
            
    jLabel31 = new javax.swing.JLabel();

            
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

            
    jLabel1.setText("What is the cost of your purchase?");

            
    jLabel3.setText("What is your first possible down payment?");

            
    jTextField4.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jTextField4ActionPerformed(evt);
                }
            });

            
    jTextField5.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jTextField5ActionPerformed(evt);
                }
            });

            
    jLabel6.setText("%");

            
    jLabel7.setText("What is your second possible down payment?");

            
    jLabel8.setText("What is your interest rate?");

            
    jLabel9.setText("How long is the term for the loan?");

            
    jTextField6.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jTextField6ActionPerformed(evt);
                }
            });

            
    jLabel10.setText("years");

            
    jLabel11.setText("                                               Choose your interest type.");

            
    jTextField7.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jTextField7ActionPerformed(evt);
                }
            });

            
    jLabel12.setText("Your monthly payment ");

            
    jLabel13.setText("The total price of your loan after interest");

            
    jTextField8.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jTextField8ActionPerformed(evt);
                }
            });

            
    jTextField9.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jTextField9ActionPerformed(evt);
                }
            });

            
    jLabel14.setText("The number of years to pay off your loan ");

            
    jLabel15.setText("years");

            
    jLabel16.setText("        =");

            
    jLabel17.setText("       =");

            
    jLabel18.setText("  $");

            
    jLabel19.setText("       =");

            
    jLabel20.setText("  $");

            
    jLabel21.setText("Your monthly payment ");

            
    jLabel22.setText("The total price of your loan after interest");

            
    jTextField10.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jTextField10ActionPerformed(evt);
                }
            });

            
    jTextField11.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jTextField11ActionPerformed(evt);
                }
            });

            
    jLabel23.setText("  $");

            
    jLabel24.setText("  $");

            
    jLabel25.setText("       =");

            
    jLabel26.setText("       =");

            
    jLabel27.setText("                                                           First down payment");

            
    jLabel28.setText("                                                      Second down payment");

            
    jTextField12.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jTextField12ActionPerformed(evt);
                }
            });

            
    jButton1.setText("Calculate Simple Interest ");
            
    jButton1.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jButton1ActionPerformed(evt);
                }
            });

            
    jButton2.setText("Calculate Compound Interest ");
            
    jButton2.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jButton2ActionPerformed(evt);
                }
            });

            
    jTextField13.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    jTextField13ActionPerformed(evt);
                }
            });

            
    jLabel29.setText("        $");

            
    jLabel30.setText("        $");

            
    jLabel31.setText("        $");

            
    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            
    jPanel1.setLayout(jPanel1Layout);
            
    jPanel1Layout.setHorizontalGroup(
                
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .
    addGroup(jPanel1Layout.createSequentialGroup()
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .
    addComponent(jLabel27javax.swing.GroupLayout.Alignment.TRAILINGjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                        .
    addGroup(jPanel1Layout.createSequentialGroup()
                            .
    addContainerGap()
                            .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .
    addGroup(jPanel1Layout.createSequentialGroup()
                                    .
    addComponent(jLabel9)
                                    .
    addGap(00Short.MAX_VALUE))
                                .
    addComponent(jLabel11javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                .
    addGroup(jPanel1Layout.createSequentialGroup()
                                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADINGfalse)
                                        .
    addComponent(jLabel3javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                        .
    addComponent(jLabel1javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE))
                                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATEDjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .
    addGroup(javax.swing.GroupLayout.Alignment.TRAILINGjPanel1Layout.createSequentialGroup()
                                            .
    addComponent(jLabel31)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .
    addComponent(jTextField12javax.swing.GroupLayout.PREFERRED_SIZE136javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .
    addGroup(javax.swing.GroupLayout.Alignment.TRAILINGjPanel1Layout.createSequentialGroup()
                                            .
    addComponent(jLabel30)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .
    addComponent(jTextField13javax.swing.GroupLayout.PREFERRED_SIZE136javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .
    addGroup(javax.swing.GroupLayout.Alignment.TRAILINGjPanel1Layout.createSequentialGroup()
                                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .
    addGroup(jPanel1Layout.createSequentialGroup()
                                            .
    addComponent(jLabel7javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                            .
    addGap(323232)
                                            .
    addComponent(jLabel29)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                        .
    addGroup(jPanel1Layout.createSequentialGroup()
                                            .
    addComponent(jLabel8javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                            .
    addGap(505050)))
                                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADINGfalse)
                                        .
    addGroup(jPanel1Layout.createSequentialGroup()
                                            .
    addComponent(jTextField6javax.swing.GroupLayout.PREFERRED_SIZE59javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .
    addComponent(jLabel10javax.swing.GroupLayout.PREFERRED_SIZE52javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .
    addGroup(jPanel1Layout.createSequentialGroup()
                                            .
    addComponent(jTextField5javax.swing.GroupLayout.PREFERRED_SIZE59javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .
    addComponent(jLabel6javax.swing.GroupLayout.PREFERRED_SIZE52javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .
    addComponent(jTextField4javax.swing.GroupLayout.PREFERRED_SIZE136javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .
    addGroup(jPanel1Layout.createSequentialGroup()
                                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .
    addComponent(jLabel22javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                        .
    addComponent(jLabel21javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE))
                                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADINGfalse)
                                        .
    addGroup(jPanel1Layout.createSequentialGroup()
                                            .
    addComponent(jLabel25)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATEDjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                            .
    addComponent(jLabel24javax.swing.GroupLayout.PREFERRED_SIZE13javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .
    addComponent(jTextField10javax.swing.GroupLayout.PREFERRED_SIZE136javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .
    addGroup(jPanel1Layout.createSequentialGroup()
                                            .
    addComponent(jLabel26)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATEDjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                            .
    addComponent(jLabel23javax.swing.GroupLayout.PREFERRED_SIZE13javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .
    addComponent(jTextField11javax.swing.GroupLayout.PREFERRED_SIZE136javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .
    addGroup(jPanel1Layout.createSequentialGroup()
                                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .
    addComponent(jLabel13javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                        .
    addComponent(jLabel12javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE))
                                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADINGfalse)
                                        .
    addGroup(jPanel1Layout.createSequentialGroup()
                                            .
    addComponent(jLabel17)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATEDjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                            .
    addComponent(jLabel18javax.swing.GroupLayout.PREFERRED_SIZE13javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .
    addComponent(jTextField8javax.swing.GroupLayout.PREFERRED_SIZE136javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .
    addGroup(jPanel1Layout.createSequentialGroup()
                                            .
    addComponent(jLabel19)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATEDjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                            .
    addComponent(jLabel20javax.swing.GroupLayout.PREFERRED_SIZE13javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .
    addComponent(jTextField7javax.swing.GroupLayout.PREFERRED_SIZE136javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .
    addGroup(javax.swing.GroupLayout.Alignment.TRAILINGjPanel1Layout.createSequentialGroup()
                                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .
    addGroup(jPanel1Layout.createSequentialGroup()
                                            .
    addGap(00Short.MAX_VALUE)
                                            .
    addComponent(jButton1)
                                            .
    addGap(515151)
                                            .
    addComponent(jButton2))
                                        .
    addGroup(jPanel1Layout.createSequentialGroup()
                                            .
    addComponent(jLabel14javax.swing.GroupLayout.PREFERRED_SIZE252javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATEDjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                            .
    addComponent(jLabel16javax.swing.GroupLayout.PREFERRED_SIZE52javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .
    addComponent(jTextField9javax.swing.GroupLayout.PREFERRED_SIZE59javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .
    addComponent(jLabel15javax.swing.GroupLayout.PREFERRED_SIZE52javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .
    addGap(212121))
                                .
    addComponent(jLabel28javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE))))
                    .
    addContainerGap())
            );
            
    jPanel1Layout.setVerticalGroup(
                
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .
    addGroup(jPanel1Layout.createSequentialGroup()
                    .
    addContainerGap()
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .
    addComponent(jLabel1javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jTextField12javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel31javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE))
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .
    addComponent(jLabel3javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jTextField13javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel30javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE))
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .
    addComponent(jTextField4javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel7javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel29javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE))
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .
    addComponent(jLabel6javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel8javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jTextField5javax.swing.GroupLayout.PREFERRED_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.PREFERRED_SIZE))
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .
    addComponent(jLabel10javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addGroup(javax.swing.GroupLayout.Alignment.LEADINGjPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .
    addComponent(jTextField6javax.swing.GroupLayout.PREFERRED_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.PREFERRED_SIZE)
                            .
    addComponent(jLabel9)))
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .
    addComponent(jLabel11)
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .
    addComponent(jButton1)
                        .
    addComponent(jButton2))
                    .
    addGap(404040)
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .
    addComponent(jLabel14javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jTextField9javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel15javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel16javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE))
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .
    addComponent(jLabel27javax.swing.GroupLayout.DEFAULT_SIZE19Short.MAX_VALUE)
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .
    addComponent(jLabel13javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jTextField8javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel17javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel18javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE))
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .
    addComponent(jTextField7javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel12javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel19javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel20javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE))
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .
    addComponent(jLabel28javax.swing.GroupLayout.DEFAULT_SIZE20Short.MAX_VALUE)
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .
    addComponent(jLabel22javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jTextField10javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel25javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel24javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE))
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .
    addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .
    addComponent(jTextField11javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel21javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel26javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addComponent(jLabel23javax.swing.GroupLayout.PREFERRED_SIZE25javax.swing.GroupLayout.PREFERRED_SIZE))
                    .
    addGap(164164164))
            );

            
    numberCompounded =  time 12;              //converts years into months
            
    numTime =  (numberCompounded time);       //number of times compounded per year
            
    months time 12;                         //un needed expression - FIX

            
    fixedPrice1 price downPayment1;         //calculates total after down payment 1
            
    fixedPrice2 price downPayment2;         //calculates total after down payment 2

            //explained       (A)     =     (P)     *          1 +        (r             /         n)       ^ (n * t)
            
    totalPrice1 fixedPrice1 Math.pow(+ ((interestRate 100) / numberCompounded), numTime); //the next two lines calculate compound interest. compounds 12 times per year
            
    totalPrice2 fixedPrice2 Math.pow(+ ((interestRate 100) / numberCompounded), numTime); //the first line is for the first down payment, the second for the second

            
    monthlyPayment1 totalPrice1 months;     //calculates monthly payment after total1 is found
            
    monthlyPayment2 totalPrice2 months;     //calculates monthly payment after total2 is found

            
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            
    getContentPane().setLayout(layout);
            
    layout.setHorizontalGroup(
                
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .
    addGroup(javax.swing.GroupLayout.Alignment.TRAILINGlayout.createSequentialGroup()
                    .
    addGap(00Short.MAX_VALUE)
                    .
    addComponent(jPanel1javax.swing.GroupLayout.PREFERRED_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.PREFERRED_SIZE))
            );
            
    layout.setVerticalGroup(
                
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .
    addGroup(javax.swing.GroupLayout.Alignment.TRAILINGlayout.createSequentialGroup()
                    .
    addGap(00Short.MAX_VALUE)
                    .
    addComponent(jPanel1javax.swing.GroupLayout.PREFERRED_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.PREFERRED_SIZE))
            );

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

        
    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
        
    }

        private 
    void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
        
    }

        private 
    void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
        
    }

        private 
    void jTextField7ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
            
    jTextField7.setText(String.valueOf(monthlyPayment1));
        }

        private 
    void jTextField8ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
            
    jTextField8.setText(String.valueOf(totalPrice1));
        }

        private 
    void jTextField9ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
            
    jTextField9.setText(String.valueOf(time));
        }

        private 
    void jTextField10ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
             
    jTextField10.setText(String.valueOf(totalPrice2));
        }

        private 
    void jTextField11ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
             
    jTextField11.setText(String.valueOf(monthlyPayment2));
        }

        private 
    void jTextField12ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
        
    }

        private 
    void jTextField13ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
        
    }

        private 
    void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
            
                    
    months time 12;                                       //converts years into months. easy.
                    
                    
    fixedPrice1 price downPayment1;                       //calculates price after down payment 1
                    
    fixedPrice2 price downPayment2;                       //calculates price after down payment 2
                    
                    
    interest1 fixedPrice1 * (interestRate 100) * time;    //calculates interest using simple interest formula 
                    
    interest2 fixedPrice2 * (interestRate 100) * time;    //calculates interest using simple interest formula 
                    
                    
    totalPrice1 fixedPrice1 interest1;                    //after interest is found, we must add it to the price
                    
    totalPrice2 fixedPrice2 interest2;                    //these lines do that
                    
                    
    monthlyPayment1 totalPrice1 months;                   //these lines calculate the monthly 
                    
    monthlyPayment2 totalPrice2 months;                   //payment on the simple interest loan

        
    }

        private 
    void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
            
    // TODO add your handling code here:
            
                    
    numberCompounded =  time 12;              //converts years into months  
                    
    numTime =  (numberCompounded time);       //number of times compounded per year
                    
    months time 12;                         //un needed expression - FIX
                                    
                    
    fixedPrice1 price downPayment1;         //calculates total after down payment 1
                    
    fixedPrice2 price downPayment2;         //calculates total after down payment 2

      //explained       (A)     =     (P)     *          1 +        (r             /         n)       ^ (n * t)
                    
    totalPrice1 fixedPrice1 Math.pow(+ ((interestRate 100) / numberCompounded), numTime); //the next two lines calculate compound interest. compounds 12 times per year
                    
    totalPrice2 fixedPrice2 Math.pow(+ ((interestRate 100) / numberCompounded), numTime); //the first line is for the first down payment, the second for the second

                    
    monthlyPayment1 totalPrice1 months;     //calculates monthly payment after total1 is found          
                    
    monthlyPayment2 totalPrice2 months;     //calculates monthly payment after total2 is found

        
    }

        
    /**
         * @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(GUI1.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            } catch (
    InstantiationException ex) {
                
    java.util.logging.Logger.getLogger(GUI1.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            } catch (
    IllegalAccessException ex) {
                
    java.util.logging.Logger.getLogger(GUI1.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            } catch (
    javax.swing.UnsupportedLookAndFeelException ex) {
                
    java.util.logging.Logger.getLogger(GUI1.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            }
            
    //</editor-fold>

            /*
             * Create and display the form
             */
            
    java.awt.EventQueue.invokeLater(new Runnable() {

                
                @
    Override
                
    public void run() {
                    new 
    GUI1().setVisible(true);
                }
            });
        }
        
    // Variables declaration - do not modify
        
    private javax.swing.JButton jButton1;
        private 
    javax.swing.JButton jButton2;
        private 
    javax.swing.JLabel jLabel1;
        private 
    javax.swing.JLabel jLabel10;
        private 
    javax.swing.JLabel jLabel11;
        private 
    javax.swing.JLabel jLabel12;
        private 
    javax.swing.JLabel jLabel13;
        private 
    javax.swing.JLabel jLabel14;
        private 
    javax.swing.JLabel jLabel15;
        private 
    javax.swing.JLabel jLabel16;
        private 
    javax.swing.JLabel jLabel17;
        private 
    javax.swing.JLabel jLabel18;
        private 
    javax.swing.JLabel jLabel19;
        private 
    javax.swing.JLabel jLabel20;
        private 
    javax.swing.JLabel jLabel21;
        private 
    javax.swing.JLabel jLabel22;
        private 
    javax.swing.JLabel jLabel23;
        private 
    javax.swing.JLabel jLabel24;
        private 
    javax.swing.JLabel jLabel25;
        private 
    javax.swing.JLabel jLabel26;
        private 
    javax.swing.JLabel jLabel27;
        private 
    javax.swing.JLabel jLabel28;
        private 
    javax.swing.JLabel jLabel29;
        private 
    javax.swing.JLabel jLabel3;
        private 
    javax.swing.JLabel jLabel30;
        private 
    javax.swing.JLabel jLabel31;
        private 
    javax.swing.JLabel jLabel6;
        private 
    javax.swing.JLabel jLabel7;
        private 
    javax.swing.JLabel jLabel8;
        private 
    javax.swing.JLabel jLabel9;
        private 
    javax.swing.JPanel jPanel1;
        private 
    javax.swing.JTextField jTextField10;
        private 
    javax.swing.JTextField jTextField11;
        private 
    javax.swing.JTextField jTextField12;
        private 
    javax.swing.JTextField jTextField13;
        private 
    javax.swing.JTextField jTextField4;
        private 
    javax.swing.JTextField jTextField5;
        private 
    javax.swing.JTextField jTextField6;
        private 
    javax.swing.JTextField jTextField7;
        private 
    javax.swing.JTextField jTextField8;
        private 
    javax.swing.JTextField jTextField9;
        
    // End of variables declaration



  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Java GUI not working

    If you want to create GUI, Netbeans provide you with the drag and drop objects facility. Otherwise, read through Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)

Similar Threads

  1. HELP! Java not working at all on my computer
    By Vikkan in forum Java SE APIs
    Replies: 2
    Last Post: March 6th, 2012, 01:04 PM
  2. How to get Present working Directory(Exact path) in java..?
    By smilyface in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 8th, 2012, 03:42 PM
  3. java web start still not working
    By gib65 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 15th, 2011, 11:25 AM
  4. java web start not working
    By gib65 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 13th, 2011, 01:16 PM
  5. Replies: 4
    Last Post: January 27th, 2009, 12:03 AM