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 / April 2006

Tip: Looking for answers? Try searching our database.

Paint problem

Thread view: 
DC - 28 Apr 2006 09:45 GMT
Good morning/afternoon/evening,

I have a problem with painting some dots, First off, the dots placing
information gets read from a file, and directly painted onto a canvas
which resides in a scrollpane.

The problem is, that after I initiated the read+paint that the graphics
just wont stay on the canvas when i move other windows over it.

The current structure is something like this:
I have 2 classes, 1 visual which contains a scrollpane, this scrollpane
contains the canvas of class 2, lets call the classes Visual and
ReadPaint for easy reference.

In the Visual class I do the following in the actionperformed:

ReadPaint RP = new ReadPaint();
g = RP.getGraphics;
RP.paintComponent(g);

And in ReadPaint:

paintComponent(Graphics g) {
graphics 2D g2d = (Graphics) g;

something = file.readByte()

dot = new Line2D (x1, x2, y1, y2); // values depend on whatever is read
from the file

g2d.setColor(something)
g2d.draw(dot)

}

Some more detailed information would be verry much appreciated on
whether im using the graphics wrong, painting on the wrong component
and what i could try to fix it. (remember the data that it gets fed is
from a file, so no pre determined value of "something" )

Greetings, DC
Thomas Weidenfeller - 28 Apr 2006 10:12 GMT
> g = RP.getGraphics;

Bzzzt, game over. See Q3.4 of the comp.lang.java.gui FAQ.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Roedy Green - 28 Apr 2006 12:46 GMT
>The problem is, that after I initiated the read+paint that the graphics
>just wont stay on the canvas when i move other windows over it.

That sort of problem is usually caused by you failing to keep a binary
list of where all the dots are so that when the display is eclipsed
you can repaint ALL of them in the clipregion, not just the recent
ones.
.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



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.