Link to home
Start Free TrialLog in
Avatar of bumpert
bumpert

asked on

Creating an Image of a invisible component

Hi, i know how to create a Image from a JComponent or anything that have a paint function. It create my Image with no problem. But now i have to create a Image Object of a JComponent that the user won't have to see. I set my Component to setVisible(false) and when i create the Image, my Image Object is null but if i setVisible(true) and i do the Image it's ok. So my question: "is there a way to create an Image Object from a Component that are not visible?"

i use this code to create the Image Object


Rectangle rect = table.getBounds();
Image ima = createImage(rect.width, rect.height);
Graphics2D g = (Graphics2D) ima.getGraphics();
table.paint(g);
g.dispose();



thx
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

You could only save an image of something when it's visible, so you'd have to show it then hide it.
Avatar of bumpert
bumpert

ASKER

hummm it's not really usefull.... cause i do my picture when a bi things is loading, so the user have the time to see the component visible, and i cant do my image elsewhere...

i was thinking that somebody could have a solution for that :(

thx
AFAIK, that's the situation i'm afraid
Avatar of bumpert

ASKER

humm ok
ASKER CERTIFIED SOLUTION
Avatar of vitallis
vitallis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bumpert

ASKER

thx someone already answer me on the java forum, but i'll give you the points
Avatar of bumpert

ASKER

java sun forum, sorry :)
Sorry bumpert - for some reason, an off-screen image didn't occur to me.
Avatar of bumpert

ASKER

no problem man, we cannot know all the things :)
if yes i didn't post qa question here :)

thx to all for your help
im leaving this topic