Solved

Export JFrame contents without making the JFrame visible

Posted on 2013-12-20
5
269 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 77
starter POM and spring-boot-starter,  spring-boot-web 2 54
JList custom Cell Renderer refresh 15 56
How to convert String matching to regex in java 4 30
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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.

808 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