Results don't populate text field

The program compiles and runs but the results don't populate the screen please help. i know I did,t highlight the code but I'm heading out I'm late for work.
import javax.swing.*;
import java.awt.*;
import java.text.DecimalFormat;
import java.awt.event.*;
import java.text.NumberFormat;
class Mortgage extends JFrame implements ActionListener {
JTextField prinBal=new JTextField(10);
JComboBox cboRate = new JComboBox();
JButton send = new JButton("Calculate");
JTextArea message = new JTextArea(10, 50);
JScrollPane scroll = new JScrollPane(message,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
JPanel row2 = new JPanel();
FlowLayout flow = new FlowLayout(FlowLayout.LEFT);
JLabel toLabel = new JLabel("Mortgage amount:");
JPanel row3 = new JPanel();
JLabel messageLabel = new JLabel("Schedule:");
JPanel row4 = new JPanel();
/* set values */
int loanTermMonths = 0;
int monthlyPaymentInterest = 0;
int remainingLoanBalance = 0;
int interestRateMonthly = 0;
int monthlyPaymentPrincipal = 0;
int monthlyPayment = 0;
NumberFormat dec = NumberFormat.getInstance();
/*set values*/
Mortgage() {
super("Mortgage");
setSize(400, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container pane = getContentPane();
pane.setLayout(flow);
row2.add(toLabel);
// JTextField to = new JTextField(10);
row2.add(prinBal);
cboRate.addItem("5.5% 7 Years");
cboRate.addItem("5.5% 15 Years");
cboRate.addItem("5.75% 30 Years");
row2.add(cboRate);
pane.add(row2);
row3.add(messageLabel);
message.setLineWrap(true);
message.setWrapStyleWord(true);
row3.add(scroll);
pane.add(row3);
send.addActionListener(this);
row4.add(send);
pane.add(row4);
setContentPane(pane);
setVisible(true);
} //constructor close
public void actionPerformed(ActionEvent e){
double amount;
double rate;
int numPeriods;
String amort;
rate =0.0;
numPeriods = 0;
amount = 0.0;
Object source = e.getSource();
if (source == send) {
amount = Double.parseDouble(prinBal.getText());
if (cboRate.getSelectedItem() == "5.5% 7 Years") {
rate=5.5;
numPeriods = 7*12;
else if (cboRate.getSelectedItem() == "5.5% 15 Years") {
rate=5.5;
numPeriods = 15*12;
else if (cboRate.getSelectedItem() == "5.75% 30 Years") {
rate=5.75;
numPeriods = 30*12;
computePayment(amount, rate, numPeriods);
//Compute the monthly payment based on the loan amount,
//APR, and length of loan.
private void computePayment(double loanAmt, double rate, int numPeriods) {
double I, partial1, denominator, answer;
String localAmort;
localAmort = message.getText();
localAmort =("\nLoan\tMonthly\tInterest\tRemaining"); // format column headers for results to be displayed
//localAmort = localAmort + ("Months\tPayment\t\tPayment\t\tLoan");
//localAmort = localAmort + ("Remaining\tPrincipal\tMonthly\t\tBalance");
localAmort =localAmort +("-------------------------------------");
System.out.println(loanAmt + " : " + rate + " : " + numPeriods);
if (rate > 0.01) {
I = rate / 100.0 / 12.0; //get monthly rate from annual
partial1 = Math.pow((1 + I), (0.0 - numPeriods));
denominator = (1 - partial1) / I;
} else { //rate ~= 0
denominator = numPeriods;
answer = (-1 * loanAmt) / denominator;
localAmort = localAmort + "dd";
while (loanTermMonths > 0) // start while loop
monthlyPaymentInterest = (remainingLoanBalance * interestRateMonthly); // Calculate H = R x I
monthlyPaymentPrincipal = (monthlyPayment - monthlyPaymentInterest); // Calculate C = P - H
remainingLoanBalance = (remainingLoanBalance - monthlyPaymentPrincipal); // Calculate R = R - C
// H = monthlyPaymentInterest
// R = remainingLoanBalance
// C = monthlyPaymentPrincipal
// I = interestRateMonthly
int Months = loanTermMonths;
double Principal = monthlyPaymentPrincipal;
double Interest = monthlyPaymentInterest;
double Balance = remainingLoanBalance;
System.out.println(Months + " " + dec.format(Principal) + " " + dec.format(Interest) + " " + dec.format(Balance));
if(loanTermMonths % 10 == 0) // pause results after 10 lines
try {
System.out.println("\n\"Please press Enter to continue\"");
System.in.read();
catch(Exception e) {
// end if
loanTermMonths --;
} // end while
     public static void main(String[] arguments) {
          Mortgage mail = new Mortgage();
}

When posting code, use the code button to wrap your code in [code][[i]code] tags.
Also, rather than just cutting and pasting from your browser, repost the original code to preserve indentation, which makes the code easier to read.
� {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Auto populate text fields with a trigger such as entering text into input fields in ADF

    Hello all,
    I am not able to auto populate text fields with a trigger such as entering text into input fields in ADF.
    I tried AdfFacesContext.getCurrentInstance().addPartialTarget(val); in the back end using setter method of input text field.
    its not working ..
    is there any way to achieve it
    Regards,
    Shakir

    Hi,
    Always mention your JDev version.
    The valueChangeListener would fire only when you set the autoSubmit property of the field to true. Can you elaborate your requirement? What do you mean by related data? Are you performing some sort of search?
    If you want to get the value you entered on the field, just set autoSubmit to true and get the new value from the valueChangeListener. If your requirement is something like as and when you type, do something, you need to check out this approach :https://blogs.oracle.com/groundside/entry/auto_reduce_search_sample
    -Arun

  • How to populate text fields with data present in a table

    Hi,
    The page i'm building has got a select list for the primary key column and text fields corresponding to rest of the columns in the table.
    upon selecting some value from the list, the data corresponding to that row should get populated in the respective items. I don't want to add source in each item. can't i create a process or something else where this is done for each item.
    for eg there's a table with columns A(primary key) and B.
    there is a text fields on this page.
    this textfield should populate the data from the table whenever i submit the page such that teh value in B is select B from tablename where A = the selected value.
    Thanks
    Dhirendra

    So I assume page was not built using a wizard. Why on earth you would want to I dont know, but you could create an "After Header" pl/sql process to populate the relevant fields, assuming the id was know on entry to the page. If you want to select the id on the page and then populate the fields, guess you will need to use a "Text Field (always submits page when Enter pressed)" and then use an "On Submit" process to populate the items.
    If you are using an Automated Row Fetch, remember to select "Set memory Cache on Fetch" in that process.
    Hope this helps.

  • Livecycle populate text field with multiple records from list box

    Can someone tell me how can I populate a text field from list box when I have multiple select.
    Here is example:
    List box consist: Hello
                             World.
    I want to see this in text field: Hello,World.
    Thanks!

    Hi Legro
    I don't know if I understand you correctly, but you can do something like this:
    ----------------- java script begin ---------------------------------
    //Reset text field
    TextField.rawValue = "";
    //loop through items in listbox
    for(i = 0; i < ListBox.length; i++)
              //if item selected
              if(ListBox.getItemState(i))
                        //check if Text field value if null
                        if (TextField.isNull)
                                  TextField.rawValue = ListBox.getDisplayItem(i);
                        else
                                  TextField.rawValue = TextField.rawValue + " " + ListBox.getDisplayItem(i);
    ----------------- java script end ---------------------------------
    I have attached an sample PDF so that you can see how it works!!
    Kind Regards
    Søren Høy Nielsen Dafolo A/S

  • Auto populate text field base on anothe r text field input

    ive created a medical form that the end user enters codes for medical reasons and a description for that code. the description are very long and tedious. is there a way to have the user enter the code in one field  and have it auto populate another field with the correct description?
    I was able to do this with a  combo box but not with a standard text box. please note, i  have never learned javascript and have been ""duct taping" peices of code to make things work  up until now . appreciate the help

    The advantage of the combo box is the automatic validation of the input as the selection is made.
    You can use control statements like the "if" or "switch" statement or perform an array lookup. This action can be performed in the on blur action of the input filed or in the calculation script for the target field.

  • Populate Text fields from Select List

    I have a select list when selected should populate two text fields with values based on SQL Query
    Eg. The select list is for empno and populates ename and sal in two different text fields.
    I have looked at Denes' example http://htmldb.oracle.com/pls/otn/f?p=31517:42 It is very good but the only problem I am facing is how to populate more than one fields.
    Any help will be appreciated.
    ZRH

    Hi
    That would depend on where the SAL data is. If it's on your page, then you could probably do something with javascript. If not, you would have to do some Ajax to retrieve the value from the database. Have a look at: http://htmldb.oracle.com/pls/otn/f?p=31517:80
    Your select list could include both the ENAME and SAL values and your existing javascript would then just split the data into two parts and insert them into the appropriate fields.
    Andy

  • Populate text field based on the lov selected value

    Hi,
    based on the value selected in lov, i want to populate another text field. Below is the code I have written
    In PFR:
    if(pageContext.isLovEvent())
    String lovInputSourceId = pageContext.getParameter(SOURCE_PARAM);
    if ("lovCategory".equals(lovInputSourceId))
    java.util.Hashtable lovResults = pageContext.getLovResultsFromSession(lovInputSourceId);
    if(lovResults!=null)
    String value =(String)lovResults.get("lovCategory");
    amobj.categorycode(value);
    AMImpl code:
    public void categorycode(String code) {
    sundryCodeVOImpl vobj = getsundryCodeVO1();
    vobj.setWhereClause( "lookup_code = "+"'"+code+"'");
    vobj.reset();
    vobj.executeQuery();
    String desc = vobj.first().getAttribute("Description").toString();
    String attr = vobj.first().getAttribute("Attribute1").toString();
    testEOViewImpl vobj1 = gettestEOView1();
    vobj1.getCurrentRow().setAttribute("CodeDescription",desc);
    vobj1.getCurrentRow().setAttribute("PurchasingCategoryCd",attr);
    vobj1.executeQuery();
    With this code, the updated values for the attributes CodeDescription, PurchasingCategoryCd are getting inserted into the database table but they are now showing up in the text fields when a value is selected in lov.
    Please tell me what is the mistake I'm doing.
    Thanks
    Sunny

    I'm using Lov Map to populate the lov field say field A. But I need to populate another field say field B based on the value selected in field A.
    to give an example of my requirement. Consider a view object having attributes col1,col2,col3 and having following data.
    col1--col2--col3
    1-----a-------x
    2-----b------y
    3-----c------z
    I 'll populate the lov of field A with values in col1. when user selects value 1 in field A. automatically field B should show value 'a'. If user selects value 2 in field A, field B should show value 'b' so on.
    Thanks
    Sunny

  • Populate text boxes

    I am trying to find some code that would allow me to populate text fields
    Here is what I would like to do
    If a user selects his name in a drop down I would like the rest of the text fields to be populated with his info such as address...phone..fax and so on.
    Im not sure where to store this info that will need to populate the fields or how to code it being really new!
    Thanks for any help!

    Don't use Form default instances. I can't tell you how to get rid of them because I use custom default settings for my projects (_mytype="empty"). 
    This means, search_contact probably points to the invisible default instance whereas you've shown an explicit instance that you've created using the new keyword. I don't know the application structure
    so I can't tell what to change to make it work. It seems add_contact_getData should be part of the Form, then you can just delete "search_contact."
    Armin

  • Can't get a text field to atuo populate based upon a dropdown selection

    I have a drop down box with 3 values that can be selected:
    Dropdown2 = 101-3 subd.A
                          101-3 subd.B
                          101-3 subd.C
    I am trying to get a text field to auto populate based upon the selection:
    if Dropdown2 = 101-3 subd.A then Text4 = "ValueA"
    if Dropdown2 = 101-3 subd.B then Text4 = "ValueB"
    if Dropdown2 = 101-3 subd.C then Text4 = "ValueC"
    I have tried to create a custom calculation script for Text4:
    var v= getfiled("Dropdown2").value;
    if (v="101-3 subd.A") event.value = "ValueA";
         else if (v="101-3 subd.B") event.value = "ValueB";
         else if (v="101-3 subd.C") event.value = "ValueC";
         else event.value = " ";
    I have entered this script and the syntax appears to be correct.(At least to Acrobat XI.  I'm know programmer and have just enough knowledge to be dangerous).  When I select a value in Dropdown2 nothing happens.  No value appears in Text4.  I have checked the "commit selected value immediately" in the option of Dropdown2 per some google'ing.  I just can not understand why the values do not appear.  Any help would be appreciated.
    Thanks

    I made the changes and added the == to my if statements.  When I select a value in Dropdown2, Nothing appears in Text4.  I don't understand.  Is there something else that I need to do beside event.value="Some Value";?
    I know it has to be something simple that I am missing, but I just can't seem to see it.
    Text4 - Custom Calculation Script:
    var v= getfiled("Dropdown2").value;
    if (v=="101-3 subd.A") event.value = "ValueA";
         else if (v=="101-3 subd.B") event.value = "ValueB";
         else if (v=="101-3 subd.C") event.value = "ValueC";
         else event.value = " ";

  • How do you auto-populate a text field based on entries in other text fields?

    I would like to be able to have a text field that populates as "Complete" or "Incomplete" based on whether all the mandatory text fields have been filled out or not.
    For example, if the "First Name," "Last Name," and "City" text fields are not filled out, the "completion status" text field will show "Incomplete" and once they are filled out, the "completion status" text field will turn into "Complete."
    How would I do this using javascript? I've searched the web for a tutorial, but most of the results seem to be dropdown-centric.
    Please point me in the right direction!

    Try the script below. I put this on the calculate event for Field1
    if(FirstName.rawValue == null || LastName.rawValue == null || City.rawValue == null){
    Field1.rawValue = "Incomplete"
    else
    Field1.rawValue = "Complete"

  • How to populate Doc Header Text Field & Ref Field in OASV Transaction?

    Hello everyone,
    I need to seek your help regarding, on how can I populate values in "Document Header Text Field" & "Reference Text Field" in OASV transaction, as these fields are invisible and are mandotory at document type.
    (I know we can disable their status in the document type, but we don't want to do so).
    Regards,
    Saurabh Patni

    Hi Mukthar,
    Thanks for the quick reply.
    I had tried to work out with substitution rule for the document type and transaction code, but still no use, the same error persists.
    (In Subsitution I am going with constant value to be replaced), I am defining it for Callup point 1, but it is not working.

  • Populate drop-down list from multiple text fields.

    Just to begin, I am brand new to this application and brand new to coding in general. Anyways, this is what I am trying to accomplish. I need to populate a drop-down list from multiple text fields. I am able to populate one item using this in the calculate event:
    TextField1.rawValue
    After I type text in TextField1 and hit enter, it displays the text in the drop-down list. I need to do this but with more than just one text field to populate more options for the drop-down list. I will also need to do something similar with populating a drop-down list from selections made in multiple other drop-down lists.
    Thanks for any help you can give me.

    Thank you for your suggestion Geo Kaiser. With that, I was able to populate my drop-down lists, but now when I select an option from the drop-down list, the selection dissapears. The selection will appear briefly in the box but then dissapears although my drop-down list options remain there. Here is the code I am using for my text field to drop-down list:
    DropDownList1.clearItems()
    DropDownList1.addItem(TextField1)
    DropDownList1.addItem(TextField2)
    And here is my code for my drop-down list to populate another drop-down list:
    DropDownList3.clearItems()
    DropDownList3.addItem(DropDownList1)
    DropDownList3.additem(DropDownList2)
    Thanks again for your help. By the way, I am using Adobe Designer 7.0.

  • Populate a drop down list with data from Excel and fill in a text field, based on drop down selectio

    Hi!
    I have a problem with a PDF form: There's a drop down list that I populate with Excel data that I've put in an XML file through an XSD file -- no problem here. The drop down list has a data binding to the XML file, so that a choice in the drop down list can be associated with an object in the XML file. So, when I make a choice in the drop down list, a corresponding object value is fetched from the XML file and put in a text field on the form.
    How to do this is described by Stefan Cameron here:
    http://forms.stefcameron.com/2006/07/29/dynamic-properties/
    There's a snag, though, and to describe it more clearly:
    The XML file contains three types of objects: role, role number, and role cost center. Of these I use the first and the third, i.e. the role and the role cost center. The drop down list contains the roles, and when I select a role, the corresponding cost center is filled out in the text field. So far, so good!
    But -- if the cost center has the same value for two or more roles, all of these roles "bounce back" into the drop down list, that is, they are all selected in the drop down list. How many of these you can see depend on the height of the drop down list -- if it's low you'll only see the first one.
    If I modify Stefan Cameron's data in his example I get the same behavior, so the problem seems to have to do with how XML data are fetched.
    I'm sure there's a workaround, but I can't find it! I've spent many hours browsing the web without finding anyone with a similar problem.
    Any suggestions appreciated!

    Although your issue is far beyond mine, I was hoping you can help me out.....
    I need to create a drop down list of names which I wish to somehow link to an Excel spreadsheet.
    Please let me know the steps I need to do.  I've tried several things, but nothing seems to work and I'm not sure what I am doing wrong.
    Thank you

  • Can I populate a text field in one PDF with the modification date of a different file ?

    Rather convoluted problem here but I'm trying to place a text field on a PDF document that serves as the main menu page for a library of interlinked PDF documents
    The complete library contains over 7,000 files and additions are added and documents changed almost daily.
    We currently use batch files to open the main menu from it's shortcut and this runs a check on a sync log file (.txt) to ascertain when the last time the user synchronised with the server to get the latest copy of the files.
    Between a certain time range they are told how long it has been since they sync'ed and are offered the option to sync before opening, after a prescribed timeframe they cannot enter without synchronising. We use Allways Sync to conduct the file synchronisation with our mother files on our server.
    What I'd like to do is take advantage of Allways Syncs automatic synchronisation options to synchronise on log on and at prescribed idle periods there after.
    This works fine but I'd like the text field on the main menu PDF to say when the last synchronisation took place - easy if the main menu is the last file modified .. just use info.modDate.
    However, the main menu is rarely modified therefore I wish to import the text to populate the text field from a different file.. either by interrogating the other files modifictaion data (though I doubt Acrobat can do this) or by simply importing some text stored in another file (a .txt file?) which has previously been created by batch file commands.
    Any assistance would be greatly appreciated.
    Regards,
    Nifty Styles
    (Norfolk, England)
    P.S.  I'm using Acrobat 8.3.1. Professional on Windows XP (SP3).

    Thank you for all your help above.
    Just to confirm your advice, am I right with the following conclusions? :
    1. The script (function) to fill the text field with the modification date of a different PDF file needs to be stored in a folder level .js file.
    2. The document containing the text field needs to call the .js function either within the document script or within the custom script property of the text field itself.
    Further to that can you just advise on the syntax for accessing the modification date of the other document.
    Do I need to assign a variable to the address of the file to be used, and then use this variable in the text form filling script (as below) or can I use a direct file reference at the .modDate command.
    var LastSync = "C:\sync\bin\lastsync.pdf";
    var strMsg = util.printd("h:MM tt",LastSync.modDate) + " on ";
    strMsg += util.printd("dddd, d mmmm, yyyy",LastSync.modDate);
    this.getField("LastSyncDate").value = strMsg;
    If the syntax is totally different to the above I would be very grateful for some guidance in the right direction.
    I much appreciate your time to help me ... I'm almost there.
    Kind Regards,
    Nifty

  • How do I use Javascript to populate a text field based on a selection from a drop down box?

    Greetings,
    I have virtually no experience with JavaScript and I am trying to figure out how to add some basic automation features to an Adobe form.  I have a drop down box called "Hospital_Name" that will contain approximately 7 possible selections.  When the user makes a selection, I would like to have the text field (called "Hospital_Address") below the drop down box populate with the corresponding address for the selection.  I have the "Hospital_Address" text field configured for multiple lines and would like the address to have a line break between the street address and the city/state/zip.
    For example, if the user selected "Hospital 1", the text field would display:
    123 Main St
    Anytown, CA 12345
    Any help or examples you can provide would be greatly appreciated.

    You have the element names within the object within brackets.
    Make sure your brackets are properly placed and matched.
    // Place all pre-population data into a single data structure
    var Location = {
    "--Hospital--":{ line1: " ", line2: " " },
    "Bellevue Medical Center":{ line1: "2500 BMC Drive", line2: "Bellevue, NE 68123" },
    "CHI Bergan Mercy":{ line1: "7500 Mercy Road", line2: "Omaha, NE 68124" }, 
    "CHI Immanuel":{ line1: "6901 N. 72nd Street", line2: "Omaha, NE 68122" }, 
    "CHI Lakeside":{ line1: "16901 Lakeside Hills Court", line2: "Omaha, NE 68130" }, 
    "CHI Midlands":{ line1: "11111 S. 84th Street", line2: "Papillion, NE 68046" },
    "Creighton University Medical Center":{ line1: "601 N. 30th Street", line2: "Omaha, NE 68131" },
    "Nebraska Medical Center":{ line1: "4400 Emile Drive", line2: "Omaha, NE 68105" }
    // some debugging code to see location names;
    console.show();console.clear():
    for(I in Location) {
    console.println(I);
    // end debugging code;
    function SetFieldValues(Hospital_Name) {
        this.getField("AddLine1").value = Location[Hospital_Name].line1;
        this.getField("AddLine2").value = Location[Hospital_Name].line2;
    This is not a beginners task but requires a fair amount of knowledge about the structure of objects, defining strings, and structure of arrays.
    Are you sure you have all the field names correctly spelled and capitalized?
    Do you get any error in the JavaScript console?
    Just trying the line that defines the "Location", I get the following error:
    SyntaxError: invalid property id
    1:Console:Exec
    undefined
    All the form field in a PDF are processed by using JavaScript and any error in any script will stop JavaScript processing.
    It might help to have a link to the problem form.
    Make sure your brackets are properly placed and matched.
    // Place all pre-population data into a single data structure
    var Location = {
    "--Hospital--":{ line1: " ", line2: " " },
    "Bellevue Medical Center":{ line1: "2500 BMC Drive", line2: "Bellevue, NE 68123" },
    "CHI Bergan Mercy":{ line1: "7500 Mercy Road", line2: "Omaha, NE 68124" }, 
    "CHI Immanuel":{ line1: "6901 N. 72nd Street", line2: "Omaha, NE 68122" }, 
    "CHI Lakeside":{ line1: "16901 Lakeside Hills Court", line2: "Omaha, NE 68130" }, 
    "CHI Midlands":{ line1: "11111 S. 84th Street", line2: "Papillion, NE 68046" },
    "Creighton University Medical Center":{ line1: "601 N. 30th Street", line2: "Omaha, NE 68131" },
    "Nebraska Medical Center":{ line1: "4400 Emile Drive", line2: "Omaha, NE 68105" }
    function SetFieldValues(Hospital_Name) {
        this.getField("AddLine1").value = Location[Hospital_Name].line1;
        this.getField("AddLine2").value = Location[Hospital_Name].line2;

Maybe you are looking for

  • Background video

    Is this possible to embed a video in the background. lets say pretty much like this: http://gosharubchinskiy.com/ I did watch all the tutorials about how to embed a video in a normal way from youtube or vimeo, but is it possible to have the video run

  • Installation of BI Content cube

    Hi, We are going for a fresh BI implementation. Nothing is installed as of now. When I am trying to install one of the cubes with the grouping option 'in data flow before and after' its giving error for all the infobojects saying that they are not av

  • How do I undeploy/delete Web Dynpro App

    Hi, I created a Web Dynpro App in NWDS for some testing. Now I want to delete this App from Server but I cannot find any button saying undeploy or delete. Can anyone tell me how I can delete a deployed Web Dynpro App? Cheers Christian

  • Print Studio Pro plugin

    I  would like to use this plugin with Paintshop Pro (my image editor for over a decade).  The plugin works with all the Adobe products, but I'd rather not tether myself to their marketing model. Most Photoshop plugins work in PSP, is there a way  to

  • LDAP users

    SharePoint Foundation 2013 box connected to LDAP using FBA/ Claims. Most of the time, I can see LDAP users in PeoplePicker. But every now and then, they simply disappear.  And then reappear after some time. I have this error message in the event view