Any idea why this is not working. public void setResultValue2() should be putting data in the " textArea2.setText(Double.toString(result2));"
//code citations from Mortgage calculator with GUI - DevX.com Forums//public class week2 { import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.text.*; import java.util.EventObject; import javax.swing.*; import javax.swing.border.Border; import java.awt.*; // Creates class for class public class week3o4 extends JFrame implements ActionListener { private static final long serialVersionUID = 8887922790267066604L; // Radio Button Selection JPanel rowOne = new JPanel(); JButton SELECTIONbutton1 = new JButton ("7 Years/5.35%"); JButton SELECTIONbutton2 = new JButton("15 Years/5.5%"); JButton SELECTIONbutton3 = new JButton("30 Years/5.75%"); JPanel R2 = new JPanel(); JLabel PRINCIPLE = new JLabel("Principle Amount in Dollars: ", JLabel.LEFT); JTextField MORTGAGEpaymentTEXT = new JTextField(10); JLabel TERMlabel = new JLabel("Mortgage Term in Years: ", JLabel.LEFT); JTextField TERMtextBOX = new JTextField(8); JLabel INTERESTtextLABEL = new JLabel("Interest Rate Percentage: ", JLabel.LEFT); JTextField INTERESTrateTEXT = new JTextField(5); JLabel MONTHLYpayLABEL = new JLabel("Monthly Payment $ ", JLabel.LEFT); JTextField MPAYTEXT = new JTextField(10); JLabel PRINCIPLEPAYMENT = new JLabel("Principle Amount without interest ", JLabel.LEFT); //// JTextField MORTGAGEpaymentbox = new JTextField(10); // Create buttons to calculate payment,exit and clear fields JPanel BOTTOMrow = new JPanel(); JButton calcBu = new JButton("CALCULATE"); JButton clBu = new JButton("CLEAR"); JButton exBu = new JButton("EXIT"); public week3o4(){ super("CALCULATOR"); setSize(400,500); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = getContentPane(); FlowLayout layout = new FlowLayout (FlowLayout.CENTER); pane.setLayout(layout); // Add to the screen FlowLayout layout1 = new FlowLayout(); rowOne.setLayout(layout1); // Add Button Group ButtonGroup btnGrp = new ButtonGroup(); btnGrp.add(SELECTIONbutton1); btnGrp.add(SELECTIONbutton2); btnGrp.add(SELECTIONbutton3); rowOne.add(SELECTIONbutton1); rowOne.add(SELECTIONbutton2); rowOne.add(SELECTIONbutton3); pane.add(rowOne); // Create a border around the radio buttons Border titledRadioBorder = BorderFactory.createTitledBorder("Choose one"); rowOne.setBorder(titledRadioBorder); // Listeners SELECTIONbutton1.addActionListener(this); SELECTIONbutton2.addActionListener(this); SELECTIONbutton3.addActionListener(this); // text boxes and labels and places default values GridLayout layout2 = new GridLayout (4, 1); R2.setLayout(layout2); R2.add(PRINCIPLE); R2.add(MORTGAGEpaymentTEXT); //MORTGAGEpaymentTEXT.setText("200000"); R2.add(TERMlabel); R2.add(TERMtextBOX); //TERMtextBOX.setText("30"); R2.add(INTERESTtextLABEL); R2.add(INTERESTrateTEXT); //INTERESTrateTEXT.setText("5.75"); R2.add(MONTHLYpayLABEL); R2.add(MPAYTEXT); MPAYTEXT.setEnabled(false); pane.add(R2); // Create Label for Text Box JPanel rowFour = new JPanel(); JLabel paymentLabel = new JLabel ("Payment #"); JLabel balLabel = new JLabel (" Balance"); JLabel ytdPrincLabel = new JLabel (" Principal"); JLabel ytdIntLabel = new JLabel (" Interest"); // Display area JPanel rowFive = new JPanel(new FlowLayout()); JTextArea textArea2 = new JTextArea(10, 31); JScrollPane scroll = new JScrollPane(textArea2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); // Add Text Box Label FlowLayout layout4 = new FlowLayout (FlowLayout.LEFT, 10, 10); rowFour.setLayout (layout4); rowFour.add(paymentLabel); rowFour.add(balLabel); rowFour.add(ytdPrincLabel); rowFour.add(ytdIntLabel); pane.add(rowFour); // Add Text Box FlowLayout layout5 = new FlowLayout (FlowLayout.CENTER, 10, 10); rowFive.setLayout(layout5); rowFive.add(scroll); pane.add(rowFive); setContentPane(pane); setVisible(true); //JTextField textArea2 = new JTextField(10); //R2.add(textArea2); //////// //textArea2.setEnabled(false); ///////// // format adding the buttons to the row FlowLayout LO3 = new FlowLayout (FlowLayout.CENTER, 10, 10); BOTTOMrow.setLayout (LO3); BOTTOMrow.add(calcBu); BOTTOMrow.add(clBu); BOTTOMrow.add(exBu); pane.add(BOTTOMrow); // listeners calcBu.addActionListener(this); clBu.addActionListener(this); exBu.addActionListener(this); setContentPane(pane); setVisible(true); } public static void main(String[] args)throws ParseException { @SuppressWarnings("unused") week3o4 frame = new week3o4(); } public void setResultValue() { double PRINCIPLE = Double.parseDouble(MORTGAGEpaymentTEXT.getText()); double term = Double.parseDouble(TERMtextBOX.getText()); double rate = Double.parseDouble(INTERESTrateTEXT.getText()) / 100.; double result = (PRINCIPLE * ( rate/12))/(1-( Math.pow (1/( 1 +(rate/12)), (term*12)))); //equation cited from [url=http://www.hughchou.org/calc/formula.html]Mortgage calculations -- how loan amortization works[/url] MPAYTEXT.setText(Double.toString(result)); } public void setResultValue2() { double PRINCIPLE = Double.parseDouble(MORTGAGEpaymentTEXT.getText()); double term = Double.parseDouble(TERMtextBOX.getText()); double rate = Double.parseDouble(INTERESTrateTEXT.getText()); double result2 = (PRINCIPLE * ( rate/12))/(1-( Math.pow (1/( 1 +(rate/12)), (term*12)))); } public void actionPerformed(ActionEvent event) { if (event.getSource() == SELECTIONbutton1) { MORTGAGEpaymentTEXT.setText("200000");; MPAYTEXT.setText("");; INTERESTrateTEXT.setText("5.35");; TERMtextBOX.setText("7");; } if (event.getSource() == SELECTIONbutton2) { MORTGAGEpaymentTEXT.setText("200000");; MPAYTEXT.setText("");; INTERESTrateTEXT.setText("5.50");; TERMtextBOX.setText("15");; } if (event.getSource() == SELECTIONbutton3) { MORTGAGEpaymentTEXT.setText("200000");; MPAYTEXT.setText("");; INTERESTrateTEXT.setText("5.75");; TERMtextBOX.setText("30");; } if (event.getSource() == calcBu) { setResultValue(); setResultValue2();} if (event.getSource() == clBu) { MORTGAGEpaymentTEXT.setText("");; MPAYTEXT.setText("");; INTERESTrateTEXT.setText("");; TERMtextBOX.setText("");; } Object command = event.getSource(); if (command == exBu){ System.exit(0); } } }