Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Save java frame as pdf/image.

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Save java frame as pdf/image.

    Hello everyone,
    i made a small application/program in java like this using NETBEANS

    of.jpg
    iff u cant see the image properly herre is the link
    http://i45.tinypic.com/314eds7.png

    so what i want is when i click the save button in the below it should save the frame / the contents in the frame as same in picture shown as a PDF file or an image(.png/jpg/jpeg/.......) formats
    and it should ask me in which directory it should save the file/image.
    Using NetBeans
    can anyone please help me ASAP

    Thank you
    Attached Images Attached Images
    Last edited by Austin777; October 15th, 2012 at 02:23 AM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Save java frame as pdf/image.

    What have you tried? Where are you stuck? I'd recommend a google search of something like "java paint to image" to get started.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Re: Save java frame as pdf/image.

    Quote Originally Posted by KevinWorkman View Post
    What have you tried? Where are you stuck? I'd recommend a google search of something like "java paint to image" to get started.
    just check the url http://i45.tinypic.com/314eds7.png

    I've tried in google but I dint get exactly as I want

    there "1000 x" "500 x" are labels and in the textfields we hav to give inputs then it will multiply
    and all the multiplied values are added when total button is pressed

    so what I want is when I press the save button in the bottom then it should take screenshot same as the image/pic I've given(URL) and it should save as a pdf file or an image

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Save java frame as pdf/image.

    Right. What have you done code-wise to paint your components to an image? What did you find in google? Because when I performed the search, I found several links. I figured your google-fu was just as good as mine though.

    If you're confused about something, I recommend you create an SSCCE that tries to draw a single component (say, a JButton) to an image instead of your entire gui.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Save java frame as pdf/image.

    can anyone please help me ASAP
    This actually causes your help to slow down. First, it wastes everyone's time to read it, slowing them down. Then someone has to tell you it is considered rude, not just on a forum but in life, to demand help, and/or to demand help asap. Then people waste even more time reading this post, and by the time it is all over, collectively, more than an hour of human life was wasted because you said you were in a hurry. Try to relax friend, I read every post on this forum every day, and not one time did i know someone wrote "hurry", "now", "important", "homework due", or "asap" until I was here to read it. (myself and many others I might add) You rob yourself an hour of manpower!

  6. #6
    Junior Member
    Join Date
    Oct 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Save java frame as pdf/image.

    Well since there are a lot of parts to your question, I'll break down a few of the terms you should use in your Google search:

    Java Robot Class - For taking pixel data from the screen.
    Creating a Bitmap - For turning the pixel data into an image that (Insert program here) can recognize.
    JTree/Directory Tree/File System Tree - For a "Save as..." Function.

    Happy programming,

    Donny.

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Save java frame as pdf/image.

    You could use the Robot class, or you could also pass the Graphics of a BufferedImage into your component's paint or paintComponent() method.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Image without a frame, is it possible?
    By knightmetal in forum AWT / Java Swing
    Replies: 5
    Last Post: August 15th, 2012, 03:52 AM
  2. adding background image to a frame???
    By overdriveboy in forum AWT / Java Swing
    Replies: 1
    Last Post: May 14th, 2012, 06:53 PM
  3. [SOLVED] JChooser save ---> Works but Can't see the saved image in the folder
    By justyStepi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 13th, 2012, 03:06 PM
  4. How to save Image into a package by JButton save?
    By justyStepi in forum AWT / Java Swing
    Replies: 1
    Last Post: May 12th, 2012, 07:02 PM
  5. Save JPanel as image
    By fahien in forum AWT / Java Swing
    Replies: 1
    Last Post: March 4th, 2011, 08:20 AM