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 9 of 9

Thread: Print out a JFrame

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Print out a JFrame

    Hi all....
    i have many panels and texts and Tables ... All are inside a JFrame (or a JTabbedPane)
    My Question is sooooo simple :
    How to Print this JFrame (or JTabbedPane) ?!
    i searched the web and found so many codes but they r all so complicated...
    Please any body help me with a VERY SIMPLE code doing that ?!!
    (Note : the JFrame has the same dimension as an A4 Paper)
    many many Thanks...


  2. #2
    Junior Member
    Join Date
    May 2010
    Location
    India
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Print out a JFrame

    Give the code you have attempted.
    You won't get full code here, so pleas post how much you have tried.
    Hint-
    Try using methods setVisible(true), setSize(width, height) of JFrame class.

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Print out a JFrame

    See the tutorial on the Sun...I mean, Oracle, website.
    Lesson: Printing (The Java™ Tutorials > 2D Graphics)
    Its fairly easy to implement the Printable interface and work from there. I'd suggest working through the examples in the tutorial then working from there...if you has problems along the way I'd suggest posting a specific example for others to chew on.

  4. #4
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: Print out a JFrame


  5. #5
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Print out a JFrame

    Hi all...
    The code in the link :

    Printing Support in Swing Components (The Java™ Tutorials > 2D Graphics > Printing)

    is so good, since it reachs the final goal and prints exactelly what i need (a component with all its subComponents)...
    But it is NOT so simple to import it to my original application code...
    in Fact, i have my own DataBase-Java-application with about 100+ pages of code...
    in a side of this application, i need to print a JFrame -or JTabbedPane- with its SubComponents...
    i tried to use directely in my code the method :

    frameToPrint.printAll(g);

    But what is the Graphics g ??
    i tried create a Graphics object g, i get that it is (abstract and can't be instantiab...) message...

    All what i want is to simplify the code in the above link since i dont want what he does inside (Creation of Gui and main and other things...)
    Simply : what i have to add to my code to quickly and directely use the printAll() method or like ?!
    Sorry and Many Thanks for any help...

  6. #6
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Print out a JFrame

    Are you still having problems with this ellias2007?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  7. #7
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Print out a JFrame

    Let me thank you JavaPF for your last post and your help...

    Are you still having problems with this ellias2007?

    YES, in fact i can now print the JPanel but NOT in the true orientation ...
    in fact, i have to print it as LANDSCAPE position but it is always printed in the PORTRAIT (other Orientation) Position ....
    i tried to use many functions like setPaper(), setOrientation().....still failed
    Many thanks for any help

  8. #8
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Print out a JFrame

    Any help please

  9. #9
    Junior Member
    Join Date
    Jun 2010
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Print out a JFrame

    I'm having a problem printing as well. I've made a program that takes input from the user to calculate specific formulas for making gears. I'm using a tabbed pane, with Panels for each pane. input is entered into JTextfields, and output to JTextfields as well.

    My question, how do i format and print JUST the output. i don't want to print the whole JFrame, just the output fields.

Similar Threads

  1. 500 Ways to Print 1 to 10
    By Freaky Chris in forum The Cafe
    Replies: 132
    Last Post: August 1st, 2014, 06:47 AM
  2. Print out object that is in a tree
    By dubois.ford in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 26th, 2010, 02:25 AM
  3. print space
    By brainTuner in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 1st, 2010, 06:09 PM
  4. Can someone please tell me why my code doesn't print out anything?
    By deeerek in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 6th, 2010, 08:35 AM
  5. print hex decimal value
    By ran830421 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 25th, 2009, 07:23 PM