tags:

views:

407

answers:

1

How can i draw 2d in a JPanel that i have on my GUI? I can do it in eclipse but am having trouble doing it in netbeans. I've looked for some tutorials but the only good one i found was for netbeans 5.5 (world's fasted java netbeans 5.5 tutorial) and i guess netbeans removed some of the things needed for that tutorial.

+1  A: 

1) Go to the formview where you can edit your frame.
2) Select your panel
3) Click right and select costumize code
4) Add an override:

panel = new JPanel()
{
    public void paintComponent(Graphics g)
    {
        drawPanel(g);
    }
}

5) Create the drawPanel(Graphics g) method.

Martijn Courteaux
Thank you very much! :)
Dacto
Actually custom painting should be done by overriding the paintComponent() method, not the paint() method.
camickr