Export JFrame contents without making the JFrame visible

The attached (working) program creates a JFrame, adds a custom JPanel, draws some basic Graphics2D shapes, and finally exports the contents to a png file.

I need to be able to run the attached program without the JFrame actually showing up on my screen. Eventually, it will be run from the command line, and all I want is the exported file.  I tried to comment out the f.setVisible(true) line, but this causes an error.

Can this be done?
StartHere.java
FB.java
MyJpanel.java
MarkLoveExExAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
CEHJConnect With a Mentor Commented:
If not, what am I to draw on?
The Graphics of the BufferedImage
0
 
CEHJCommented:
All you need to do is ignore the gui and work directly on the BufferedImage and save it as i showed
0
 
MarkLoveExExAuthor Commented:
It seems that the whole approach so far is to use GUI components. I am having trouble stripping out the GUI and still making the png image. Am I not to use JFrame and JPanels? If not, what am I to draw on?
0
 
MarkLoveExExAuthor Commented:
Ok. I understand now. I got it to work. It actually made my code a lot simpler getting rid of the unneeded GUI components. Thanks for your help. My java skills sure are rusty...
0
 
CEHJCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.