I am very green at writing Java, I am trying to go through our chapter examples and putting in data for a mortgage calculator with a GUI. This code is far from finished but the example says
"Now save and compile" and this is where I am getting the error "Java 42 illegal start of expression".
I would appreciate any suggestions or explanation of what that error is REALLY telling me!:(
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class MortgageCalculator extends JApplet
implements ActionListener
{
Label greeting = new Label("Mortgage Calculator");
Font Big = new font("Times Roman",Font.ITALIC, 24);
public void init();
public void actionPerformed(ActionEvent thisEvent)
{
Object source = thisEvent.getSource();
if(source==principal)
{
String name = answer.getText();
personalGreeting.setText("Thank you"+ name);
}
}
{
add(greeting);
greeting.setFont(bigFont);
JButton principal = new JButton ("Principal");
principal.addActionListener(this);
answer.addActionListener(this);
JTextField answer = new JTextField("",10);
JLabel personalGreeting = newJLabel("");
FlowLayout flow = new FlowLayout();
if (source instanceof JTextField);
{
String name = answer.getText();
personalGreeting.setText("Thank you" + name);
}
{
JLabel greeting = new JLabel("Principal");
public void init();
{
Container con = getContentPane();
con.add(greeting);
con.add(answer);
con.add(principal);
con.add(personalGreeting);
answer.requestFocus();
}
}
}
}