Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Export JFrame contents without making the JFrame visible

Posted on 2013-12-20
5
Medium Priority
?
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

610 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