aspose file tools*
The moose likes Java in General and the fly likes JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "JPanel" Watch "JPanel" New topic
Author

JPanel

Suela Smith
Greenhorn

Joined: Apr 20, 2006
Posts: 11
Hi everyone
I'm trying to build a JFrame that includes JPanels, JLabels, JButton, and JTextArea; I don't know why i get an error when i try to compile the code

code:

private JPanele panel1 = null;
private JPanele panel2 = null;
private JPanele panel2a = null;
private JPanele panel2b = null;
private JPanele panel2c = null;
private JPanele panel2a1 = null;

private JLabel label1 = null;
private JLabel label2 = null;
private JLabel label3 = null;
private Jlabel label4 = null;
private JLabel label5 = null;

private JTextField textfield1 = null;
private JTextField textfield2 = null;
private JTextField textfield3 = null;
private JTextField textfield4 = null;
private JTextField textfield5 = null;

private JTextArea textarea1 = null;

private JButton button1 = null;
private JButton button2 = null;
private JButton button3 = null;
private JButton button4 = null;


panel1 = new JPanel();
panel2 = new JPanel();
panel2a = new JPanel();
panel2b = new JPanel();
panel2c = new JPanel();
panel2a1 = new JPanel();

label1 = new JLabel("First Name");
label2 = new JLabel("Last Name");
label3 = new JLabel("Middle Name");
label4 = new JLabel("Age");
label5 = new JLabel("Gender");

textfield1 = new JTextField(20);
textfield2 = new JTextField(20);
textfield3 = new JTextField(20);
textfield4 = new JTextField(20);
textfield5 = new JTextField(20);

textarea1 = new JTextArea(50, 20);
JScrollPane scrollpane = new JScrollPane(textarea1);

button1 = new JButton("Save");
button1.addActionListener(al);
button2 = new JButton("Next");
button2.addActionListener(al);
button3 = new JButton("Load");
button3.addActionListener(al);
button4 = new JButton("Clear");
button4.addActionListener(al);

panel2.setLayout(new GridLayout(3. 1, 0, 0));

panel2a.setLayout(new GridLayout(2. 1, 0, 0));
panel1.add(scrollpane);

panel2a1.add(label1);
panel2a1.add(textfield1);

panel2a1.add(label2);
panel2a1.add(textfield2);

panel2a1.add(label3);
panel2a1.add(textfield3);

panel2a1.add(label4);
panel2a1.add(textfield4);

panel2a1.add(label5);
panel2a1.add(textfield5);

panel2.add(panel2a);
panel2.add(panel2b);
panel2.add(panle2c);

this getContentPane().setLayout(new GridLayout(2, 1, 0, 0);
this.getContentPane().add(panel1);
this.getContentPane().add(panel2);
this.setSize(800,600);
this.setLocation(200,200);
this.pack();
this.setVisible(true);
}//end constructor

Error:
illegal start of expresion
private JPanel panel1 = null;

any help is greatly appriciated
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
}//end constructor

if this is part of the constructor
private JPanel panel1 = null;

it should be
JPanel panel1 = null;
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPanel