Hello all
I've just started learning Java, and I am trying to create a basic application that maintains a list of contacts (their name, surname and email).
To being with I just wanted to create a simple frame that displays the labels and text boxes, using the following code:
import javax.swing.*;
import java.awt.*;
public class MyApplication {
this.setContentPanel(panel);
public static void main (String[] args) {
JFrame myFrame = new JFrame ("My Application");
myFrame.setSize (300, 200);
JLabel nameLabel = new JLabel("Name:");
JLabel surnameLabel = new JLabel ("Surname:");
JLabel emailLabel = new JLabel ("E-mail:");
JTextField name = new JTextField();
JTextField surname = new JTextField();
JTextField email = new JTextField();
JButton exit = new JButton ("Exit");
JPanel panel = new JPanel();
panel.add(nameLabel); panel.add(name);
panel.add(surnameLabel); panel.add(surname);
panel.add(emailLabel); panel.add(email);
panel.add(exit);
myFrame.setVisible(true);
}
}
However i keep on getting the following errors when i try to compile/run
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "(", ; expected
Syntax error on token ")", ; expected
at MyApplication.main(MyApplication.java:8)
Eclipse also highlights the opening curly brackets (the ones that belong to the public class MyApplication) as
Syntax error on token "{", { expected after this token
and the brackets around the main method.
I don't understand why this error occurs, I think I ahve the right number of brackets in suitable pairs and can't think what else is wrong.
Thanks for any help in advance (Sorry if my error is painfully obvious)