 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
JavaJunkie Guest
|
Posted: Fri Apr 02, 2004 4:37 am Post subject: Newbie to Java really needs help |
|
|
Hello all, I am taking my second java class and I am tried everything to get my program to compile correctly and keep getting error messages. The program is supposed to display a GUI mortgage where the user can input a principal amount, an interest rate, and hit the calculate button to display the monthly payment. Please help me.. I keep getting the same error over and over(in 6 line of code).. Any help or advice and feedback would be appreciated. Thanks.
Here is what I have so far.
/*
* Written By:
* Date:3/31/2004
* Description: Mortgage Calculator program
* Filename: Mortgage.java
PDL
//* Class: Mortgage
//* Parent: Mortgage Class
//* Attributes: A, I, R, T, P
//* Methods:
//* Design
//* This program will calculates and return a monthly mortgage payment based on user input of
//* principal amount, interest rate and term of loan.
//* The class also has public methods for calculating the amount,
//*
*/
/* establish links to java libraries*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import javax.swing.border.*;
public class Mortgage extends JFrame
{
// declare all the graphic objects
Font headfont = new Font("TimesRoman", Font.PLAIN, 2 ;
Font basefont = new Font("TimesRomain", Font.PLAIN, 16);
Font messagefont = new Font("TimesRoman", Font.BOLD, 20);
TextField textPrincipal = new TextField(10);
TextField textInterest = new TextField(10);
TextField textYears = new TextField(10);
TextField textPayment = new TextField(10);
CheckboxGroup groupInt = new CheckboxGroup();
Checkbox intmodeAnnual = new Checkbox("Annual Interest",groupInt,true);
Checkbox intmodeMonth = new Checkbox("Monthly Interest",groupInt,false);
// declare user buttons
JButton calcButton = new JButton("Calculate");
JButton exitButton = new JButton("Exit");
JButton resetbutton = new JButton("RESET");
JLabel info = new JLabel("Enter Principal, Interest, and Years.");
short modalDivisor = 12;
public Mortgage()
{
// declare JFrame size
setTitle("Mortgage Calculator Program");
setSize(680, 610);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container pane = getContentPane();
JPanel panel = new JPanel(new FlowLayout()); // determines the size and position of each component added to this panel//
panel.setFont(headfont);
pane.add(calcButton);
pane.add(exitButton);
pane.add(resetbutton);
JPanel p = new JPanel(new BorderLayout());
JPanel panelBody = new JPanel();
panelBody.setFont(basefont);
panelBody.setLayout( new GridLayout(5,2,10,10) );
panelBody.add( new Label("Principal") );
panelBody.add(textPrincipal);
panelBody.add( new Label("Modal Interest") );
panelBody.add(textInterest);
panelBody.add( new Label("Years") );
panelBody.add(textYears);
panelBody.add( new Label(" ") );
panelBody.add( new Label(" ") );
panelBody.add( new Label("Mortgage Payment") );
textPayment.setEditable( false );
panelBody.add(textPayment);
add(panelBody,BorderLayout.CENTER);
Panel panelRadio = new Panel();
panelRadio.setFont(basefont);
panelRadio.setLayout( new GridLayout(4,1,5,5) );
panelRadio.add(intmodeAnnual);
panelRadio.add(intmodeMonth);
panelRadio.add( new Label(" ") );
panelRadio.add( new Label(" ") );
add(panelRadio,BorderLayout.WEST);
Panel panelButtons = new Panel();
panelButtons.setFont(basefont);
panelButtons.setLayout( new GridLayout(4,1,10,20) );
panelButtons.add( new Label(" ") );
panelButtons.add(Calculate);
panelButtons.add(JbuttonExit);
panelButtons.add( new Label(" ") );
panelButtons.add(buttonReset);
add(panelButtons,BorderLayout.EAST);
Panel panelFooter = new Panel();
panelFooter.setFont(messagefont);
panelFooter.setForeground(Color.red);
panelFooter.setLayout( new FlowLayout(FlowLayout.CENTER,10,10) );
panelFooter.add(labelMessage);
add(panelFooter,BorderLayout.SOUTH);
// action listeners for buttons
mortgage.addActionListener(this);
reset.addActionListener(this);
}
}// EOF
Java
|
|
| Back to top |
|
 |
Christophe Vanfleteren Guest
|
Posted: Fri Apr 02, 2004 7:22 am Post subject: Re: Newbie to Java really needs help |
|
|
JavaJunkie wrote:
| Quote: | Hello all, I am taking my second java class and I am tried everything to
get my program to compile correctly and keep getting error messages. The
program is supposed to display a GUI mortgage where the user can input a
principal amount, an interest rate, and hit the calculate button to
display the monthly payment. Please help me.. I keep getting the same
error over and over(in 6 line of code).. Any help or advice and feedback
would be appreciated. Thanks.
snip code |
Please don't multipost, you've gotten an anwser in c.l.j.gui.
--
Kind regards,
Christophe Vanfleteren
|
|
| Back to top |
|
 |
Alex Hunsley Guest
|
Posted: Mon Apr 05, 2004 12:15 pm Post subject: Re: Newbie to Java really needs help |
|
|
JavaJunkie wrote:
| Quote: | Hello all, I am taking my second java class and I am tried everything to
get my program to compile correctly and keep getting error messages. The
[snip] |
Please don't post html, this is usenet, not a web page. Any decent posting
software will let you switch off html in message composition.
alex
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|