Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2007

Tip: Looking for answers? Try searching our database.

how to draw sth on a Panel permanently?

Thread view: 
Sowen Zhang - 20 Feb 2007 22:27 GMT
Hi all

I need to draw sth to a Panel in an action, for instance

Graphics g = palCanvas.getGraphics();
g.setColor(Color.cyan);
g.fillPolygon(p);

Yes, the polygon is drawn, but after I update any control in the same form
or resize the window, the polygon disappears.

Can someone tell me how can I keep it?
Thanks!

Signature

Best Regards!
Hong.
---------------------------
Image Processing and Watermark components for .NET
http://www.ImageComponent.NET

Personal Entertainment Shareware and Freeware
http://www.angGoGo.com

Andrew Thompson - 20 Feb 2007 22:35 GMT
...
> I need to draw sth to a Panel in an action, for instance
>
> Graphics g = palCanvas.getGraphics();

This is the wrong way to approach
custom painting.  It hould be done
on the Graphics object supplied to
paint()/paintComponent().

See,
<http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html>
for further details.

Andrew T.
Sowen Zhang - 20 Feb 2007 22:39 GMT
good reference, thanks a lot!

Signature

Best Regards!
Hong.

> ...
>> I need to draw sth to a Panel in an action, for instance
[quoted text clipped - 11 lines]
>
> Andrew T.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.