i'm using NetBeans and i keep getting an error in this code:

package desktopapplication7;

import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class Frame extends JFrame 
{
    Container c= getContentPane();
    setLayout(new BorderLayout(5,10));
    JPanel p= new JPanel();
    p.add(new JButton("OK"));  // ERROR HERE
    
    c.add(p,BorderLayout.Center);  // ERROR HERE
}

on both lines above, it keeps telling me : <identifier> Expected.

can anyone help me fixing this ?

If you want to call methods you can only do it inside other methods (a Constructor maybe).
Where you wrote the code that gives you the error you can only put variable declarations.
So you must declare a method (preferably a Constructor) and put the code that gives you the error there

OH i see .... don't know how i missed that one, probably of tiredness.
Thanks a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.