Hi Everybody!! I'm new to java and am experementing with GUI and would like if someone could please help me, because I can't figure out how to fix the problem. The part in red is the part where I cannot figure out how to fix it because it says it's an illegal start of an expression. Thanks in advance and taking the time to help and read!
Here it is:
public class MyNew extends JFrame implements ActionListener
{
public static void main(String[] args)
{
publicMyNew start= newMyNew();
{
super("Text Fields");
JPanel pane=(JPanel) getContentPane();
pane.setLayout(new BorderLayout());
givenName=newJTextField(10);
familyName=newJTextField(10);
fullName=newJTextField(10);
fullName=setEditable(false);
JPanel inFieldPane=newJPanel();
inFieldPane.setLayout(new GridLayout(2,2));
inFieldPane.add(newJLabel("Given name"));
inFieldPane.add(givenName);
givenName.addActionListener(this);
inFieldpane.add(new JLabel("Family Name"));
inFieldPane.add(familyName);
familyName.addActionListener(this);
pane.add(inFieldPane,BorderLayout.NORTH);
JPanel submitPane= newJPanel();
submitPane.setLayout(new FlowLayout());
submitPane.add(new JLabel("Press button to enter names"));
JButton submitButton=newJButton("Submit");
submitButton.addActionListener(this);
submitPane.add(submitButton);
pane.add(submitPane,BorderLayout.CENTER);
JPanel outFieldPane= new JPanel();
outFieldPane.setLayout(new GridLayout(1,2));
outFieldPane.add(newJLabel("Full Name"));
outFieldPane.add(fullName);
pane.add(outFieldpane,BorderLayout.SOUTH);
pack();
setVisible(true);
}
[COLOR="red"]public void actionPerformed (ActionEvent e)[/COLOR]
{
if(e.getActionCommand().equals("Submit"))
{
String fullString=familyName.getText().trim()+","
+givenName.getText(). trim();
fullName.setText(fullString);
}
}
}