Results 1 to 7 of 7
  1. #1
    Y. Progammer is offline Member
    Join Date
    Feb 2010
    Posts
    68
    Rep Power
    0

    Default Unable to render printing the complete JPanel

    Hey guys! I am plotting a graph on a JPanel. Now when I print this JPanel only forty 40% of the graph is printed.. i mean less than 50% of the JPanel is printed from the very left of the screen ..

    Java Code:
                /*Handling the printing job*/
                if (event.getSource() == jButton4) {
                    PrinterJob job = PrinterJob.getPrinterJob();
                    /*code that renders contents to the page*/
                    job.setPrintable(new Printable() {
    
                        public int print(Graphics g, PageFormat pf, int page) throws
                                PrinterException {
    
                            if (page > 0) {
                                return NO_SUCH_PAGE;
                            }
    
                            Graphics2D g2d = (Graphics2D) g;
                            g2d.translate(pf.getImageableX(), pf.getImageableY());
    
                            testD.printAll(g);
    
                            return PAGE_EXISTS;
                        }
                    });
                    boolean doPrint = job.printDialog();
                    if (doPrint) {
                        try {
                            job.print();
                        } catch (PrinterException pe) {
                            javax.swing.JOptionPane.showMessageDialog(null, "Exception Caught", "Cannot render printing", javax.swing.JOptionPane.ERROR_MESSAGE);
                        }
                    }
                }
    plz suggest!:eek:

  2. #2
    Y. Progammer is offline Member
    Join Date
    Feb 2010
    Posts
    68
    Rep Power
    0

    Default


  3. #3
    Y. Progammer is offline Member
    Join Date
    Feb 2010
    Posts
    68
    Rep Power
    0

    Default

    Guys you can see that even the coordinate axes are not covered !!

  4. #4
    Y. Progammer is offline Member
    Join Date
    Feb 2010
    Posts
    68
    Rep Power
    0

    Default

    testD in the above snippet represents the JPanel on which I have plotted the graph.

  5. #5
    javastuden's Avatar
    javastuden is offline Senior Member
    Join Date
    Nov 2009
    Posts
    162
    Rep Power
    6

    Default

    hi ,
    i'm not an expert in graph increase the x any y value parameter +1 so that the printing will complete,this i had seen my tl is doing graph and he let us to change those query to get hte graph,i dont know what i side the code he written which all js ,css or some java code ,and he wont tell us how the program ,just change the quey ,check whether you got output give me the code,ok forget it ,in that i realize that the x and y axis are incrementing by 1,
    eg:if we want a date range sales graph from 2010-01-01 to 2010-02-15 then the date will incremented to 2010-02-16 and not 15 if like that then the output will be a yours,i hope you got the idea
    thanks

  6. #6
    Y. Progammer is offline Member
    Join Date
    Feb 2010
    Posts
    68
    Rep Power
    0

    Default

    Got not!!:confused:

  7. #7
    Y. Progammer is offline Member
    Join Date
    Feb 2010
    Posts
    68
    Rep Power
    0

    Default

    the graph is plotted completely on the panel but when it is rendered to the it gets clipped !

Similar Threads

  1. Why wont my object render properly
    By toecutter in forum AWT / Swing
    Replies: 3
    Last Post: 10-22-2009, 02:43 PM
  2. ejb 3.0 complete tutorial
    By better_me007 in forum Enterprise JavaBeans (EJB)
    Replies: 3
    Last Post: 09-28-2009, 11:52 AM
  3. Help me to complete this class, please
    By pink_872 in forum New To Java
    Replies: 6
    Last Post: 04-21-2009, 02:23 PM
  4. Download the Complete API?
    By JDCAce in forum NetBeans
    Replies: 2
    Last Post: 10-02-2008, 02:02 AM
  5. Loki Render 0.3
    By levent in forum Java Software
    Replies: 0
    Last Post: 07-26-2007, 09:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •