• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JPanel

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
}//end constructor

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

it should be
JPanel panel1 = null;
 
reply
    Bookmark Topic Watch Topic
  • New Topic