Two Laptop Bag*
The moose likes Swing / AWT / SWT and the fly likes Bmp, gif, jpeg Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Bmp, gif, jpeg" Watch "Bmp, gif, jpeg" New topic
Author

Bmp, gif, jpeg

Tys Seyffert
Ranch Hand

Joined: Jan 12, 2004
Posts: 32
Hey all,

Is it possible to save a panel as a graphic file like a bmp, gif, jpeg?

I have a calender that has a panel as the base. I want to save the the calender as a graphic.

Thank you

Tys
nikos sokaf
Ranch Hand

Joined: May 01, 2004
Posts: 57
If you're trying to save an image then you have to work with the image.Use the proper API. (See working with images on java.sun.com).

If you're trying to *print* a form, then i don't thing that there is a way you should do that, because this is an operating system's ability.I mean that in other languages, like C++,VB use some System's libraries (like MCI) to print a form etc. The reason is that the programming languages they can use such libraries, are written in system's code-base.And to be more specific: the operating system are written with these languages(talking for C++).Java is Platform Indepedent so i think what you're looking for can't be done.If there is a way to save a panel as an image without using system's libraries, post it if you'll find it, because i don't know any.Java is a low level to high level language,and probably there is a way, but i think it is very advanced.

I'm not telling you to stop looking, I'm telling you what i think.It is intresting , and if you find anything post it!

Best regards
Nikos sokaf
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

This could be buggy, I didn't test anything. Should give you the general idea though. Google's an amazing thing you know.



GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by nikos sokaf:
If you're trying to *print* a form, then i don't thing that there is a way you should do that, because this is an operating system's ability...Java is Platform Indepedent so i think what you're looking for can't be done.

I'm not telling you to stop looking, I'm telling you what i think.It is intresting , and if you find anything post it!

Best regards
Nikos sokaf


Um...Not exactly. Printing is a task performed by a Printer Driver. All printers are registered with the OS. It's the VM's job to locate those drivers and pass the information to them. That's why we have a different VM for different platforms.

Printing API/Tutorial
nikos sokaf
Ranch Hand

Joined: May 01, 2004
Posts: 57
Hi Gregg,
I believe at last, you are right!
But i think this could be difficult.I haven't try it.But this is true you posted.


Farewell!
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by nikos sokaf:
Hi Gregg,
I believe at last, you are right!
But i think this could be difficult.I haven't try it.But this is true you posted.


Farewell!


It is difficult. The printing API sucks. But it's not much better in any otehr language. You really have to do a lot of preparations of whatever you are printing before sending it to the printer. Like making sure the margins are right and the print area is right, etc, etc. Someone needs to make a higher level API for this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bmp, gif, jpeg
 
Similar Threads
What attachments are allowed?
Thread life cycle
pls help ....writing image to file
Multi display Applet
ImageIO.read(InputStream ..) returns null