Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

[Java] Drawing complex shapes using Swing?

Options
  • 04-03-2006 12:02pm
    #1
    Registered Users Posts: 383 ✭✭


    Hey guys,

    Need to draw some shapes (Like stickmen, rounded rectangles, diamonds, etc...) Is it possible to do this with out overriding the paint() or paintComponents()?

    If I use paint() I always get refresh problems, that the image disappears if some other windows (example: message box) appears over it. Any suggestions?

    thx.


Comments

  • Registered Users Posts: 885 ✭✭✭clearz


    use
    JPanel drawPnl = new JPanel()
    {
        public void paintComponent(Graphics g)
        {
            super.paintComponent(g);
            /* Draw Code here */
        }
    };
    

    then add the Panel to your frame. You can of course just create a subclass of JPanel and override the paintComponent method either.


  • Registered Users Posts: 383 ✭✭cherrio


    Works perfect :) thx.


Advertisement