I have done a mortgage calculator program. it builds and run but I think tje GUI must be wrong because
I cannot see it. I am very new to this and I am so lost. I do not know if this is the
right forum.

import javax.swing.*;
import java.awt.*;
import java.text.NumberFormat;
import javax.swing.JOptionPane;
import java.awt.event.*;
import java.io.*;
import java.math.*;
import java.text.*;
import javax.swing.JLabel;


public class Main extends JFrame {



    /**
     * @param args the command line arguments
     */



public class McBrideMortgageGUI {
}
   
{
}
public static void main (String[] args)
{
    
   
    
        //decarng content
class mcbridemortgagegui extends JFrame implements ActionListener
{
    private  mcbridemortgagegui mcbridemortgagegui;
    
       //adding initial selection options for RadioButtons
   JPanel row_aa = new JPanel();
   JRadioButton opt1 = new JRadioButton("Manual Input",true);
   JRadioButton opt2 = new JRadioButton("Manuel Selections",false);

        // content Buttons, Panels, Labels, and TextFields
   JPanel row_a = new JPanel();
   JLabel amountLabel = new JLabel();

   JTextField loanField = new JTextField();
   JLabel loan2Label = new JLabel();
   JPanel row_b = new JPanel();

   JPanel row_b1 = new JPanel();
   JLabel termLabel = new JLabel(); //term
   JTextField termField = new JTextField(4);

   JPanel row_b2 = new JPanel();
   JLabel int_entryLabel = new JLabel();  //interest
   JTextField int_entryField = new JTextField(3);

   JComboBox options = new JComboBox();
   JLabel optionsLabel = new JLabel();

   JPanel row_c = new JPanel();
   JButton calButton = new JButton();
   JButton resetButton = new JButton();
   JButton endButton = new JButton();

   JPanel row_d = new JPanel();
   JLabel paymentLabel = new JLabel();
   JTextField paymentField = new JTextField();

   JPanel row_e = new JPanel();
   JLabel outputLabel = new JLabel();

   JPanel row_f = new JPanel();
   JTextArea opField = new JTextArea(5, 55);

   JScrollPane scrollPane = new JScrollPane(opField, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
           ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

   ButtonGroup radioSelect = new ButtonGroup();

        private String i;

                  //setting format of GUI layout

        public mcbridemortgagegui()
        {
        }  
         {
            //main GUI Dimensions super("mcbridemortgage- Loan Calculator with Preselected or Customized Values");
            setSize(900,265);
            new GridLayout(6, 4, 10, 10);
            FlowLayout flowCenter = new FlowLayout(FlowLayout.CENTER);
            FlowLayout flow = new FlowLayout(FlowLayout.LEFT);

            Container pane = getContentPane();
            pane.setLayout(flow);

            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            setVisible(true);

            //setting actionListener for Fields and Buttons
            loanField.addActionListener(this);
            termField.addActionListener(this);
            int_entryField.addActionListener(this);
            options.addActionListener(this);
            calButton.addActionListener(this);
            resetButton.addActionListener(this);
            endButton.addActionListener(this);
            opt1.addActionListener(this);
            opt2.addActionListener(this);
            
            //layout for mortgage amount entry
            row_a.setLayout(flow);
            amountLabel.setText("Please Enter Loan Amount without Commas:");
            row_a.add(amountLabel);
            row_a.add(loanField);
            radioSelect.add(opt1);
            radioSelect.add(opt2);
            pane.add(row_a);
            
            //layout for options
            options.addItem("7 years at 5.35%");
            options.addItem("15 years at 5.5%");
            options.addItem("30 years at 5.75%");
            options.setEnabled(false);
            
            row_b.setLayout(flow);
            row_b.add(options);
            pane.add(row_b);
            
            row_b1.setLayout(flow);
            termLabel.setText("Term in Years");
            row_b1.add(termLabel);
            row_b1.add(termField);
            pane.add(row_b1);
            
            row_b2.setLayout(flow);
            int_entryLabel.setText("Interest %");
            row_b2.add(int_entryLabel);
            row_b2.add(int_entryField);
            pane.add(row_b2);
            
            //layout for buttons to calculate, Reset and End
            row_c.setLayout(flow);
            calButton.setBackground(Color.orange);
            row_c.add(calButton);
            resetButton.setText("Reset");
            resetButton.setBackground(Color.PINK);row_c.add(endButton);
            pane.add(row_c);
            
            //layout for section that shows the monthly payment amount
            row_d.setLayout(flow);
            paymentLabel.setText("Monthly Payment Amount");
            row_d.add(paymentLabel);
            row_d.add(paymentField);
            pane.add(row_d);
            
            //layout for loan amoritzation table
            row_e.setLayout(flow);
            outputLabel.setText("Loan Amoritization Table");
            row_e.add(outputLabel);
            pane.add(row_e);
            
            row_f.setLayout(flowCenter);
            opField.setLineWrap(true);
            opField.setEditable(true);
            row_f.add(scrollPane);
            pane.add(row_f);
            
        }
        //adding actionEvents for Buttons
        public void actionPerformed(ActionEvent getevent)
           {
            Object source = getevent.getSource();
            if(source == calButton)
            {
                startCalculations();

            }
            if(source == resetButton)
            {
                reset();
              }
            if(source == endButton)
            {
                      
            }
            if(source==opt1)
            {
                options.setEnabled(false);
                termField.setEnabled(true);
                termField.setEditable(true);
                int_entryField.setEnabled(true);
                int_entryField.setEditable(true);
            }
            if(source==opt2)
            {
                options.setEnabled(true);
                termField.setEnabled(false);
                termField.setEditable(false);
                int_entryField.setEnabled(false);
                int_entryField.setEditable(false);
            }

            }
        //formulas for monthly payment
        void startCalculations() {
            Thread thisThread = Thread.currentThread();
            NumberFormat currency = NumberFormat.getCurrencyInstance();

            double amount = 0; //amount of loan
            double term = 0; //variable for term of loan
            double interest = 0; //variable for interest amount of loan
            double monthlyInterest = 0; //variable for monthly payment for formula
            double monthlyTerm = 0; //variable for monthly term for formula
            double principle = 0; //variable for principle
            double payment = 0; //variable for payment
            double newPrinciple = amount;
            boolean Exception = false;

            try
            {
                amount = Double.parseDouble(loanField.getText());
            }
            catch (NumberFormatException e) {
                JOptionPane.showMessageDialog(null, "Please Do Not Use Commas","Message Dialog",
                        JOptionPane.PLAIN_MESSAGE);
                loanField.setText(null);
            }
            if (opt2.isSelected())
            {
                if(options.getSelectedIndex() ==0)
                {
                    term =7;
                    interest =5.35;
                }
                else if (options.getSelectedIndex()==1)
                {
                    term =15;
                    interest =5.5;
                 }
                else
                {
                    term =30;
                    interest =5.75;
                }
            }else
                {
                    try
                    {
                        term = Double.parseDouble(termField.getText());
                    }
                    catch(NumberFormatException e){
                        JOptionPane.showMessageDialog(this,"Enter amount greater than zero","Please enter new amount",
                                JOptionPane.ERROR_MESSAGE);
                        Exception = true;
                        termField.setText(null);
                    }
                    try
                    {
                        interest = Double.parseDouble(int_entryField.getText());
                    }
                    catch(NumberFormatException e) {
                        JOptionPane.showMessageDialog(this,"Enter amount greater than zero and with no % sign",
                                "Please enter new amount",JOptionPane.ERROR_MESSAGE);
                        Exception = true;
                        int_entryField.setText(null);
                    }
                }
                //output for Loan Amoritzation Table
                if(amount>0&&interest>0)
                {
                    amount = Double.parseDouble(loanField.getText());
                    monthlyInterest = (interest/12)/100;
                    monthlyTerm = term*12;
                    payment = amount*(monthlyInterest/(1 -java.lang.Math.pow((1 + monthlyInterest),(-monthlyTerm))));
                    paymentField.setText("" + currency.format(payment));

                    opField.append("Payment#");
                    opField.append("   ");
                    opField.append("Payment Amount");
                    opField.append("   ");
                    opField.append("Interest");
                    opField.append("   ");
                    opField.append("Principle Balance");
                    opField.append("  ");
                    opField.append("Remaining Balance");
                    opField.append("  \n");

                    for (int i = 0; i <= monthlyTerm;i++)
                    {
                        double newInterest = monthlyInterest*newPrinciple;
                        double balance = payment-newInterest;
                        newPrinciple = newPrinciple-balance;

                        opField.append(" "+i);
                        opField.append("" + currency.format(payment));
                        opField.append("" + currency.format(newPrinciple));
                        opField.append("" + currency.format(balance));
                        opField.append("" + currency.format(newPrinciple +"\n"));

                    }
                    if ((amount <=0 || interest <=0)&&(Exception ==false))
                    {
                        JOptionPane.showMessageDialog(null,"Please Enter Positive Number Only.","Message Dialog",
                                JOptionPane.PLAIN_MESSAGE);
                        if(amount <=0)
                        {
                            loanField.setText(null);
                        }
                    }

                }

                //reset GUI for another calculation
        }void reset()
                {
                    loanField.setText(null);
                    paymentField.setText(null);
                }
            }

            }
{
}
}
            //End of program

Yeah, I'm a bit of a newbie to java myself. But I think that there is a method called setVisible() which allows for the GUI to be seen. This isn't automatic in java for some reason. Check out the API at

http://java.sun.com/javase/7/docs/api/

the container's are what I think you want to invoke it on.

Good luck!

Yeah, I'm a bit of a newbie to java myself. But I think that there is a method called setVisible() which allows for the GUI to be seen. This isn't automatic in java for some reason. Check out the API at

http://java.sun.com/javase/7/docs/api/

the container's are what I think you want to invoke it on.

Good luck!

I have that already set, must be missing something else

I need so help please I cannot find what I have do wrong.

Yeah, I see that you do have setVisible() in your code. But I think that the way you have it implemented is incorrect. I don't think that it is a static method, but an instance method. Therefore it should be invoked on a particular instance of a class.

(i.e.)

import javax.swing.*;  // This line of code imports all classes and methods in the javax.swing heiarchy.  

public class Example
{
  public static void main(String[] args) 
  {
    JFrame frame = new JFrame(); // Here I create the frame.
    frame.setVisible(true); // and here I invoke the object/instance method setVisible so that I will be able to see it.
    
    // There is a distinction between instance and static methods, you should familiarize yourself with it.
    
    /* There are many other methods that deal with the appearence of the frame.  And a few that tell the system what to do
    /  when the frame is exited. Like I mentioned before, you should really check the documentation at
    /
    /  http://java.sun.com/javase/7/docs/api/
    / 
    /  It's an extensive API on all of java SE classes and methods.
    */
  }
}

Yeah, I see that you do have setVisible() in your code. But I think that the way you have it implemented is incorrect. I don't think that it is a static method, but an instance method. Therefore it should be invoked on a particular instance of a class.

(i.e.)

import javax.swing.*;  // This line of code imports all classes and methods in the javax.swing heiarchy.  

public class Example
{
  public static void main(String[] args) 
  {
    JFrame frame = new JFrame(); // Here I create the frame.
    frame.setVisible(true); // and here I invoke the object/instance method setVisible so that I will be able to see it.
    
    // There is a distinction between instance and static methods, you should familiarize yourself with it.
    
    /* There are many other methods that deal with the appearence of the frame.  And a few that tell the system what to do
    /  when the frame is exited. Like I mentioned before, you should really check the documentation at
    /
    /  http://java.sun.com/javase/7/docs/api/
    / 
    /  It's an extensive API on all of java SE classes and methods.
    */
  }
}

Thanks I will try that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.