Solved

Export JFrame contents without making the JFrame visible

Posted on 2013-12-20
5
264 Views
Last Modified: 2013-12-22
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
0
Comment
Question by:MarkLoveExEx
  • 3
  • 2
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39733501
All you need to do is ignore the gui and work directly on the BufferedImage and save it as i showed
0
 

Author Comment

by:MarkLoveExEx
ID: 39733731
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 39733772
If not, what am I to draw on?
The Graphics of the BufferedImage
0
 

Author Closing Comment

by:MarkLoveExEx
ID: 39734188
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 39734396
:)
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now