Problem to print a JPanel containing jfreeChart

I need help
I am developping an application that should display and print reports with histograms.
I make the histogram with Jfreechart and put it on a JPanel. the report is a Vector of JPanel.
1. When i print only the panel containing the JFreechart, the panel is printed but the range axis label
of JFreechart is inverted.
2. When i print all the report, nothing appears on the page of the panel containing JFreechart.
here is my printing code:
//code
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
if (pageIndex >= docToBePrinted.size()) {
return (NO_SUCH_PAGE);
} else {
componentToBePrinted = docToBePrinted.get(pageIndex);
//componentToBePrinted.repaint();
Dimension dim = componentToBePrinted.getSize();
double scaleX = pageFormat.getImageableWidth() / dim.width;
double scaleY = pageFormat.getImageableHeight() / dim.height;
double scale = Math.min(scaleX, scaleY);
Graphics2D g2D = (Graphics2D) g;
// g2D.translate(0, 0);
g2D.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
g2D.scale(scale, scale);
g2D.setPaintMode();
disableDoubleBuffering(componentToBePrinted);
componentToBePrinted.print(g2D);
g2D.dispose();
//componentToBePrinted.printAll(g2D);
enableDoubleBuffering(componentToBePrinted);
//componentToBePrinted.
return (PAGE_EXISTS);
//end of code
"docToBePrinted" is the report
Could anyone help me please !

I have the same problem. Similarly to another entry here, be very careful about how many times you reattempt it. I did it several times, hoping it would work out a kink, and it was on an expensive order, now there are over $2000 of "temporary authorizations" depleting my available credit on my card, and it's been that way for almost a week now.
I am living overseas, and am unfortunately restricted to dial-up internet to upload this, and it either gets stuck at 64kb/8Mb or just jumps right to 8/8Mb, when there is nothing wrong with the my internet connection.
I emailed Apple in response to the order cancellation email, and stated that perhaps it was the army firewall I'm behind, asking for the site the program connects to in an attempt to unblock the site if it's inadvertently getting blocked on my end. When they replied they said it's a technical issue and that I can call Apple to talk with someone, where they will determine how much the call will cost. That's outrageous to have something brand new, and have to pay for them to help you on an issue that truly may be as simple as giving out a website.
In response to an earlier reply, I am using iPhoto 5.0.4, and I just purchased my G5 back in October. Is there a later version to iLife that I'm not finding?
If anyone finds help with this issue, I would greatly appreciate some tips!
Thanks so much,
Dave

Similar Messages

  • Resolution problem when printing JPanel with picture on bg

    Hellow!
    I have some problems with printing JPanel component. I have a picture drawn on the background of the JPanel and several buttons on it. The whole JPanel is about 1600x800px. When i print whole the component with the help of PDF virtual printer, component is printed larger than A4 list. It is strange for me because print resolution is 600 dpi, so whole component must be a rectangle with the size about 2.5x1.5 inches. When I scale the graphics before painting component to fit image to page (i mean ... {color:#ff0000}g2d.scale(sc,sc); panel.paintAll(g2d);{color} ...), the picture's quality becomes very bad.
    I understod it so: I draw the component on the paper in screen resolution, then I decrease image size, so quality also decreases.
    My question is: how to draw on the graphics of printing paper the component in printers resolution (600dpi), but not in screen resolution.

    Hi there,
    Could you provide the community with a little more information to help narrow troubleshooting? What operating system?
    You can say thanks by clicking the Kudos Star in my post. If my post resolves your problem, please mark it as Accepted Solution so others can benefit too.

  • Scroll Bar Problem after Printing a web page containing multiple page data

    Hi All,
    I have a web application which has two DIV, one is main and one is child. I am having problem in printing multiple pages. There is a lot of data in the child DIV and i am using JavaScript functions to control the print functionality. When i print using window.print(), only the data on the main page currently being showed is printed. I further researched and checked out the Style.Overflow property.
    Now i am using divMain.style.overflow = "visible"
    After this the complete print comes. But in Firefox, the scroll bar disappears and only single page is left with no scroll bar .
    Now if after print i give divMain.style.overflow = "Auto" OR divMain.style.overflow = "Scroll", still the scroll bar doesn't come and if it comes then its inactive. I am unable to see the complete data on the page after the print is taken.
    The problem is not coming in I.E and the full data with scroll bar is recovered in I.E.
    Please help me how to get the normal page with full data and scroll bar after printing in Firefox.
    Thanks,
    Manuj

    hi, i would update my reader first to the newest version.
    does the size of the textfield never change, independant how much text is in it?
    perhaps check your subforms, if they are type "position" size does not change in my opinion, except your parent subforms expand to fit....
    or use "flowed" subforms...and regard the parent subforms too!

  • Printing a JPanel..............HELP required URGENTLY

    I m doing my application using JPanel which contains labels, textfields and buttons.
    Now I want to print this panel. Is it possible to print a JPanel. IF yes, then plz help me as I m stuck up into this big problem and due to which I m not able to complete my project.
    I tried many codes of printing, but I wasn�t able to print it. One of the code is given below which gives me an error in MouseListener and MouseEvent.
    //*********** Main User Interface Class ************
    public class ComponentPrintingTestUI extends JFrame implements MouseListener {
    //private static MyTextPane myTextPane;
    private static MyJPanel myJPanel;
    public ComponentPrintingTestUI() {
    initComponents();
    private void initComponents() {
    JFrame frame = new JFrame("ComponentPrintingTest");
    //JPanel contentPanel1 = new JPanel();
    //JPanel contentPanel2 = new JPanel();
    JPanel contentPanel3 = new JPanel();
    JPanel contentPanel4 = new JPanel();
    contentPanel3.setMaximumSize(new Dimension(270,170));
    contentPanel3.setMinimumSize(new Dimension(270,170));
    contentPanel3.setPreferredSize(new Dimension(270,170));
    //JButton textPrint = new JButton("Print TextPane");
    //textPrint.addMouseListener(this);
    JButton panelPrint = new JButton("Print JPanel");
    panelPrint.addMouseListener(this);
    //myTextPane = new MyTextPane();
    //myTextPane.setEditable(false);
    myJPanel = new MyJPanel();
    //contentPanel1.add(myTextPane, BorderLayout.CENTER);
    //contentPanel2.add(textPrint, BorderLayout.CENTER);
    contentPanel3.add(myJPanel, BorderLayout.CENTER);
    contentPanel4.add(panelPrint, BorderLayout.CENTER);
    //frame.add(contentPanel1, BorderLayout.NORTH);
    //frame.add(contentPanel2, BorderLayout.CENTER);
    frame.add(contentPanel3, BorderLayout.NORTH);
    frame.add(contentPanel4, BorderLayout.SOUTH);
    frame.setSize(1280,1024);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    public void mouseClicked(MouseEvent arg0) {
    // EditorFrame extends JFrame and has all the, well, editing stuff
    //EditorFrame frame = ClerkUtilities.getEventSourceFrame(e); // method simply grabs the source frame
    //PrintableTextPane tp = frame.getTextPane();
    PrinterJob printJob = PrinterJob.getPrinterJob();
    //PageFormat pf = printJob.defaultPage();
    //pf.setOrientation(PageFormat.LANDSCAPE);
    printJob.setPrintable(myJPanel);
    if (printJob.printDialog())
    try
    printJob.print();
    } // end try
    catch (Exception ex)
    ex.printStackTrace();
    } // end Exception catch
    } // end if
    //*********** Custom JPanel Class *************
    public class MyJPanel extends JPanel implements Printable {
    public MyJPanel() {
    initComponents();
    private void initComponents() {
    this.setMaximumSize(new Dimension(270,170));
    this.setMinimumSize(new Dimension(270,170));
    this.setPreferredSize(new Dimension(270,170));
    this.setBackground(Color.GRAY);
    public void paint(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.drawString("Sample drawstring", 20, 20);
    g2.drawString("Bottom line", 20, 150);
    public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException
    /* get component width and table height */
    Dimension dimension = this.getSize();
    double compWidth = dimension.width;
    double compHeight = dimension.height;
    System.out.println("Comp width: " + compWidth);
    System.out.println("Comp height: " + compHeight);
    Paper card = pageFormat.getPaper();
    card.setImageableArea(0, 0, 153, 243);
    card.setSize(153,243);
    pageFormat.setPaper(card);
    pageFormat.setOrientation(PageFormat.LANDSCAPE);
    /* get page width and page height */
    //double pageWidth = pageFormat.getImageableWidth();
    //double pageHeight = pageFormat.getImageableHeight();
    //double scale = pageWidth / compWidth;
    //double scale = compWidth / pageWidth;
    //System.out.println("Page width: " + pageWidth);
    //System.out.println("Page height: " + pageHeight);
    //System.out.println("Scale: " + scale);
    /* calculate the no. of pages to print */
    //final int totalNumPages= (int)Math.ceil((scale * compHeight) / pageHeight);
    if (pageIndex > 3)
    System.out.println("Total pages: " + pageIndex);
    return(NO_SUCH_PAGE);
    } // end if
    else
    Graphics2D g2d = (Graphics2D)g;
    g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
    System.out.println("Coords: " + pageFormat.getImageableX() + ", " + pageFormat.getImageableY());
    g2d.translate( 0f, 0f );
    //g2d.translate( 0f, -pageIndex * pageHeight );
    //g2d.scale( scale, scale );
    this.paint(g2d);
    return(PAGE_EXISTS);
    } // end else
    } // end print()
    //*********** Starter Class **********
    //public class ComponentPrintingTest {
    * @param args
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    ComponentPrintingTestUI ui = new ComponentPrintingTestUI();
    //ui.setVisible(true);
    I m a newbie to java and don�t have any idea abt printing of Panel. Plz Plz Plz help me.
    Thanks in advance.

    mansi_b85, next time when you post a question:
    - please use code tags (http://forum.java.sun.com/help.jspa?sec=formatting);
    - don't flag your question as urgent which you have done in 3 of your 4 posts here. This implies that your question is more important than other people's questions and/or your time is more valuable than ours (ours as in people who (try to) answer your question). This is considered rude;
    - try writing whole words instead of that horrible sms-speak (plz and abt)
    - post swing related questions in the swing forum.
    Thanks.

  • Problem with printing pdf

    IF POSSIBLE REPLY IN ITALIAN
    HI, i ve got a big problem.
    i 've to create an A0 page in vectorial pdf, which has connected different files: .psd files for the images with transparency, and vectorial .pdf for the drawings from cad.
    When i ve created my page, i export that in print pdf high quality.
    1° problem: sometimes it fails and tells me there s not enough memory
    2° problem: when print pdf is created, the plotter can t load it to print, it stops at 40% loading.
    there s a way to make an easy vectorial print pdf?
    using vectorial eps instead of vectorial pdf?
    using transparent tiff instead of psd?
    THANKS

    thank you for the fast reply Peter. Im working on an achitecture poster for my last exam, and it contains vector graphics sometimes overlayed on raster images.
    i don t like to use illustrator too, im using 3 programs already to create this poster. do u think .ai are easier than eps???
    i ve tryed to save new pdf without layers, but it didn t work. then i ve tryed to change pdf with eps on indesign, and now the print pdf saving is really faster. im gonna try to plot it and then i ll tell u what s changed.
    OH most important, i was drag n dropping pdf into indesign, and i read it s really wrong! so now i import vector eps to indesign ...
    Plot test...
    TY

  • Problem with printing files created by tcpdf class

    Hello,
    I have problem with printing pdf files created with tcpdf php class which contain embedded fonts
    http://www.tecnick.com/pagefiles/tcpdf/example_008.pdf
    Could someone try to print that example file at his Reader (printing to file .ps will be fine).
    I'm trying to determinate if problem is in my system (Ubuntu 8,04) in Reader or in class.
    Thanks in advance

    No problem with Adobe Reader 8 or 9 .

  • Is it possible to print a JPanel from the application?

    Hello,
    Just a quick question: Is it possible to print a JPanel from your application? I have plotted a graph and I would like user to be able to print this with a click of a button (or similar)
    Thanks very much for your help, its appreciated as always.
    Harold Clements

    It is absolutely possible
    Check out my StandardPrint class. Basically all you need to do is
    (this is pseudocode. I don't remember the exact names of methods for all this stuff. Look it up if there's a problem)
    PrinterJob pd = PrinterJob.createNewJob();
    StandardPrint sp = new StandardPrint(yourComponent);
    pd.setPageable(sp);
    //if you want this
    //pd.pageDialog();
    pd.doPrint();You are welcome to have use and modify this class but please don't change the package or take credit for it as your own code.
    StandardPrint.java
    ===============
    package tjacobs.print;
    import java.awt.*;
    import java.awt.image.BufferedImage;
    import java.awt.print.*;
    import javax.print.PrintException;
    public class StandardPrint implements Printable, Pageable {
        Component c;
        SpecialPrint sp;
        PageFormat mFormat;
         boolean mScale = false;
         boolean mMaintainRatio = true;
        public StandardPrint(Component c) {
            this.c = c;
            if (c instanceof SpecialPrint) {
                sp = (SpecialPrint)c;
        public StandardPrint(SpecialPrint sp) {
            this.sp = sp;
         public boolean isPrintScaled () {
              return mScale;
         public void setPrintScaled(boolean b) {
              mScale = b;
         public boolean getMaintainsAspect() {
              return mMaintainRatio;
         public void setMaintainsAspect(boolean b) {
              mMaintainRatio = b;
        public void start() throws PrinterException {
            PrinterJob job = PrinterJob.getPrinterJob();
            if (mFormat == null) {
                mFormat = job.defaultPage();
            job.setPageable(this);
            if (job.printDialog()) {
                job.print();
        public void setPageFormat (PageFormat pf) {
            mFormat = pf;
        public void printStandardComponent (Pageable p) throws PrinterException {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPageable(p);
            job.print();
        private Dimension getJobSize() {
            if (sp != null) {
                return sp.getPrintSize();
            else {
                return c.getSize();
        public static Image preview (int width, int height, Printable sp, PageFormat pf, int pageNo) {
            BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            return preview (im, sp, pf, pageNo);
        public static Image preview (Image im, Printable sp, PageFormat pf, int pageNo) {
            Graphics2D g = (Graphics2D) im.getGraphics();
            int width = im.getWidth(null);
            int height = im.getHeight(null);
            g.setColor(Color.WHITE);
            g.fillRect(0, 0, width, height);
            double hratio = height / pf.getHeight();
            double wratio = width / pf.getWidth();
            //g.scale(hratio, wratio);
            try {
                   sp.print(g, pf, pageNo);
              catch(PrinterException pe) {
                   pe.printStackTrace();
            g.dispose();
            return im;
        public int print(Graphics gr, PageFormat format, int pageNo) {
            mFormat = format;
            if (pageNo > getNumberOfPages()) {
                return Printable.NO_SUCH_PAGE;
            Graphics2D g = (Graphics2D) gr;
              g.drawRect(0, 0, (int)format.getWidth(), (int)format.getHeight());
            g.translate((int)format.getImageableX(), (int)format.getImageableY());
            Dimension size = getJobSize();
              if (!isPrintScaled()) {
                 int horizontal = getNumHorizontalPages();
                 int vertical = getNumVerticalPages();
                 int horizontalOffset = (int) ((pageNo % horizontal) * format.getImageableWidth());
                 int verticalOffset = (int) ((pageNo / vertical) * format.getImageableHeight());
                 double ratio = getScreenRatio();
                 g.scale(1 / ratio, 1 / ratio);
                 g.translate(-horizontalOffset, -verticalOffset);
                 if (sp != null) {
                     sp.printerPaint(g);
                 else {
                     c.paint(g);
                 g.translate(horizontal, vertical);
                 g.scale(ratio, ratio);
              else {
                 double ratio = getScreenRatio();
                 g.scale(1 / ratio, 1 / ratio);
                   double xScale = 1.0;
                   double yScale = 1.0;
                   double wid;
                   double ht;
                   if (sp != null) {
                        wid = sp.getPrintSize().width;
                        ht = sp.getPrintSize().height;
                   else {
                        wid = c.getWidth();
                        ht = c.getHeight();
                   xScale = format.getImageableWidth() / wid;
                   yScale = format.getImageableHeight() / ht;
                   if (getMaintainsAspect()) {
                        xScale = yScale = Math.min(xScale, yScale);
                   g.scale(xScale, yScale);
                   if (sp != null) {
                        sp.printerPaint(g);
                   else {
                        c.paint(g);
                   g.scale(1 / xScale, 1 / yScale);
                   g.scale(ratio, ratio);
             g.translate((int)-format.getImageableX(), (int)-format.getImageableY());     
            return Printable.PAGE_EXISTS;
        public int getNumHorizontalPages() {
            Dimension size = getJobSize();
            int imWidth = (int)mFormat.getImageableWidth();
            int pWidth = 1 + (int)(size.width / getScreenRatio() / imWidth) - (imWidth == size.width ? 1 : 0);
            return pWidth;
        private double getScreenRatio () {
            double res = Toolkit.getDefaultToolkit().getScreenResolution();
            double ratio = res / 72.0;
            return ratio;
        public int getNumVerticalPages() {
            Dimension size = getJobSize();
            int imHeight = (int)mFormat.getImageableHeight();
            int pHeight = (int) (1 + (size.height / getScreenRatio() / imHeight)) - (imHeight == size.height ? 1 : 0);
            return pHeight;
        public int getNumberOfPages() {
              if (isPrintScaled()) return 1;
            return getNumHorizontalPages() * getNumVerticalPages();
        public Printable getPrintable(int i) {
            return this;
        public PageFormat getPageFormat(int page) {
            if (mFormat == null) {
                PrinterJob job = PrinterJob.getPrinterJob();
                mFormat = job.defaultPage();
            return mFormat;
    }

  • Problem when printing " " using XSL

    I have a problem when printing the "<" .It is always printed as
    "&#60;" in the HTML file.
    I wish to transfer a Javascript text . I tried
    using CDATA . This is an extract of a portion in my XSL File
    which uses CDATA.
    <![CDATA[
    function createLOV(lov_name, array_touse) {
    document.writeln("<select name='" + lov_name + "'>");
    for (var i=0; i < array_touse.length; i++) {
    document.writeln("<option value='" + array_touse[i] + "'>" +
    array_touse[i] + "</option>");
    }]]>
    And this is what the HTML file contains
    function createLOV(lov_name, array_touse) {
    document.writeln("&#60;select name='" + lov_name + "'>");
    for (var i=0; i &#60; array_touse.length; i++) {
    document.writeln("&#60;option value='" + array_touse[i] + "'>" +
    array_touse[i] + "&#60;/option>"); }
    document.writeln("&#60;/select>");}
    I tried using the <xsl:text disable-output-escaping="yes"> but in
    vain.
    If i use < or &x3C; , i still get &#60; in the HTML file.
    How do I solve this problem. I'm using XSQL Servlet with JSDK2.1
    both running on Sun Solaris2.6 .
    Thanks in advance,
    Suresh
    null

    Suresh Seetharam (guest) wrote:
    : I have a problem when printing the "<" .It is always printed
    as
    : "&#60;" in the HTML file.
    : I wish to transfer a Javascript text . I tried
    : using CDATA . This is an extract of a portion in my XSL File
    : which uses CDATA.
    : <![CDATA[
    : function createLOV(lov_name, array_touse) {
    : document.writeln("<select name='" + lov_name + "'>");
    : for (var i=0; i < array_touse.length; i++) {
    : document.writeln("<option value='" + array_touse[i] + "'>" +
    : array_touse[i] + "</option>");
    : }]]>
    : And this is what the HTML file contains
    : function createLOV(lov_name, array_touse) {
    : document.writeln("&#60;select name='" + lov_name + "'>");
    : for (var i=0; i &#60; array_touse.length; i++) {
    : document.writeln("&#60;option value='" + array_touse[i] + "'>"
    +
    : array_touse[i] + "&#60;/option>"); }
    : document.writeln("&#60;/select>");}
    : I tried using the <xsl:text disable-output-escaping="yes"> but
    in
    : vain.
    : If i use < or &x3C; , i still get &#60; in the HTML file.
    : How do I solve this problem. I'm using XSQL Servlet with
    JSDK2.1
    : both running on Sun Solaris2.6 .
    : Thanks in advance,
    : Suresh
    Currently, the parser does not support the xsl:output and
    output-escaping mechanisms. We plan on adding support for this
    in a future release.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • Problem  in Printing the ALV list

    Hi,
       I have one problem with printing the ALV list. While printing the ALV list(thro Print Icon on application Tool bar) ,Fist page of my print out contains some other inforamtion.
      inforamtions included two tables
      first table  contains Sort Criteria, Ascdg, Descnd, Subtotal  columns.
      And second table contains Data statistics , number of
    columns.
    But from Second page onwards , my alv list printed correctly .
      How can i avoid the First page inforamtion and
          what is the Reason of coming like this?
    Thanks,
    Neptune.M

    I assume you are using function module Reuse_alv_grid_display or reuse_alv_list_display for ALV.
    If this is the case, there is a parameter called IS_PRINT that you need to supply while calling the function module.
    you can for exapmle declare
    data:
    printstruc type SLIS_PRINT_ALV.
    printstruc-NO_PRINT_LISTINFOS = 'X'.
    call function 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    IS_PRINT = printstruc
    There are many other flags in is_print structures that you can use to manipulate the printing.
    Cheers!

  • I had a problem with print preview of billing document.

    HI all,
    I had a problem with print preview of billing document which contains two output types ZR1 ZR2..
    For the footer text of billing document I maintained the font size as 7,5 pts, But when i go for print preview from output type ZR1 the font size of footer text is very small and looks good for output type ZR2.
    If i change the print options-->logical destination of output type ZR1 same as Output type ZR2, the footer text looks good.
    I think there is some issue with logical destination in print options for the output type ZR1, how can i resolve  it.

    hi,
    for both the output types , r u using same sapscript or smartform?
    if yes then, u can control it in output options of smartform and also in sapscript , you can control through if condition.
    and if differect sapscript or smartform then you should not get such problem.
    you can check the sapscript or smartfrom in TNAPR table.

  • Problem in printing to LPT1 through applet?

    Hello everyone,
    I am having problem in printing through Applet in LPT1 of remote client machine using "gridDoubleClicked" method of customized "GridPanel" which is third party component. The class structure is given below:
    public class GridPanel extends Panel implements GridPanelInterface, AdjustmentListener, KeyListener, FocusListener, Serializable
    }I am using above class to populate data in table and perform "double click" action. I am using JDK 1.5 and a self signed jar to access from remote machines through applet.The code, I am using is given below:
    public class testApplet extends Applet {
        printToLPT1 lpanel =new printToLPT1();
        public void init() {
          this.setLayout(new BorderLayout());
          this.add(lpanel, BorderLayout.CENTER);
          this.setSize(380, 250);
    public class printToLPT1 extends Frame{
    GridPanel grid;
    public printToLPT1() throws Exception {
    grid.addGridListener(new GridAdapter() {
                public void gridDoubleClicked(GridEvent ge) {               
                    testPrint();
    public static void testPrint() throws Exception {
            try {
                BufferedOutputStream pos = new BufferedOutputStream(new FileOutputStream("LPT1"));
                String str = "\n\n\n\n\n\n\n\n\n\n\n";
                pos.write(str.getBytes());
                pos.flush();
                pos.close();
            } catch (Exception fnfe) {
                throw new Exception("PRINTER SETUP IS NOT PROPER");
    }For applet, I have used following script in login.html:
    <APPLET
         height="200px"
         archive="testprinter.jar,jbcl.jar,grid.jar,plugin.jar" 
         width="390px"
         align="top"
         code="test.testApplet.class"
         name="Testing"
        ALT="<P>This applet requires Java to be enabled!  Check the browser options or see your SysAdmin." MAYSCRIPT>
        <P>This page requires Java!  Get it free from <A HREF='http://www.java.com/'>www.java.com</A>.</P>
    </APPLET>
    ------------------- If signed jar file of application is run using command line in client machine then "double clicked" of GridPanel method works fine and send signal to printer at LPT1 port but when same application is called using applet and accessed from remote machine with printer in LPT1 port, in that time also "double clicked" of GridPanel method works fine but printer could not be found and Exception is thrown java.lang.Exception:"PRINTER SETUP IS NOT PROPER" . Why is this happening? Can anyone suggest me the solution for this problem?
    Thanks in advance.
    -Ritesh
    Edited by: ritesh163 on Apr 15, 2010 2:56 PM

    The SSCCE for this problem is given below:
    //Applet class
    package test;
    import java.awt.BorderLayout;
    import javax.swing.JApplet;
    public class testApplet extends JApplet {
        testPrint lpanel =new testPrint();
        public void init() {
          this.setLayout(new BorderLayout());
          this.add(lpanel, BorderLayout.CENTER);    
          this.setSize(380, 250);    
    // Printing class...
    package test;
    import com.borland.jbcl.layout.XYConstraints;
    import java.awt.Color;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.io.BufferedOutputStream;
    import java.io.FileOutputStream;
    import wdn.grid.GridAdapter;
    import wdn.grid.GridData;
    import wdn.grid.GridEvent;
    import wdn.grid.GridPanel;
    public class testPrint extends javax.swing.JFrame {
        // Variables declaration - do not modify                    
        private javax.swing.JButton btnPrint;
        private javax.swing.JPanel jPanel1;
        // End of variables declaration     
        GridPanel grid;
        GridData gdata;
        String[] gridCols = {
            "Receipt No", "Name"};
        public testPrint() {
            grid = new GridPanel(0, 8);
            gdata = new GridData(0, 8);
            grid.setRowHeaderWidth(0);
            grid.setGridData(gdata);
            grid.setMultipleSelection(false);
            grid.setColWidths("100,60");
            grid.setColHeaders(gridCols);
            setGridProperties(grid);
            grid.setColSelection(false);
            this.setVisible(true);
            grid.addGridListener(new GridAdapter() {
                public void gridDoubleClicked(GridEvent ge) {
                   //This event works fine...
                    System.out.println("Press Re-Print button...");
                    try{
            stringToPrinter("testing by grid \n\n\n\n\n\n\n\n\n\n\n\n\n");
            }catch(Exception ex){
                ex.printStackTrace();
                public void gridCellsClicked(GridEvent ge) {
                    btnPrint.setEnabled(true);
            initComponents();
            jPanel1.add(grid, new XYConstraints(52, 60, 100, 150));
            grid.deleteRows(1, grid.getNumRows());
            grid.insertRow(1);
                        grid.setCellText(1, 1, "12134", false);
                        grid.setCellText(2, 1, "test" + "", false);
                        grid.repaintGrid();
        private void initComponents() {
            jPanel1 = new javax.swing.JPanel();
            btnPrint = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            btnPrint.setText("Print");
            btnPrint.setToolTipText("to Print");
            btnPrint.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnPrintActionPerformed(evt);
            org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .add(36, 36, 36)
                    .add(btnPrint)
                    .addContainerGap(287, Short.MAX_VALUE))
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                    .addContainerGap(198, Short.MAX_VALUE)
                    .add(btnPrint)
                    .add(57, 57, 57))
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
            pack();
        }// </editor-fold>                       
        private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {                                        
            try{
            stringToPrinter("testing \n\n\n\n\n\n\n\n\n\n\n\n\n");
            }catch(Exception ex){
                ex.printStackTrace();
        public static void setGridProperties(GridPanel grid) {
            grid.setRowHeaderWidth(0);
            grid.setAutoResizeColumns(true);
            grid.setRowNumbers(true);
            grid.setCellSelection(false);
            grid.setRowSelection(true);
            grid.setHighlightColor(Color.blue);
            grid.setHighlightTextColor(Color.white);
            grid.setAutoResizeRows(true);
            grid.addKeyListener(new KeyAdapter() {
                public void keyTyped(KeyEvent e) {
                public void keyPressed(KeyEvent e) {
                    if (e.getKeyChar() == KeyEvent.VK_SPACE) {
                public void keyReleased(KeyEvent e) {
        public static void stringToPrinter(String str) throws Exception {
            try {
                System.out.println("inside stringToPrinter...");
                BufferedOutputStream pos = new BufferedOutputStream(new FileOutputStream("LPT1"));
                System.out.println("inside stringToPrinter...1-pos::"+pos);
                pos.write(str.getBytes());
                pos.flush();
                pos.close();
            } catch (Exception fnfe) {
                throw new Exception("PRINTER SETUP IS NOT PROPER");
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new testPrint().setVisible(true);
    }

  • RoboHelp 10: Problems generating Printed Documentation

    Environment
    Windows 7 Enterprise, Service Pack 1, 64-bit operating system
    Office Professional Plus 2010 Versions 14.0.7106.5001 (64-bit)
    RoboHelp 10: 10.0.0.287
    Visual Studio 2010 Professional. I open RoboHelp from within Source Control (have been doing it for two years).
    Problem
    Sometime after moving to RoboHelp 10, and even after successfully generating Printed Documentation output, I encountered a major problem generating Printed Documentation from RoboHelp: “Internal error encountered. Failed to generated Printed Documentation”. The error occurred when I tried to generate Printed Doc using my default TOC, which looks something like this:
    Topic A
    Topic B
    Book 1
    Book 2
    Book 3
    Topic C
    Topic D
    Based on an old Peter Grainge reply to someone about a similar problem, I removed all but the first topic from the Chapter Layout pane and generated the Help. Everything was fine until I got to the topics after Book 3. At that point everything started to fail again. When I removed Topics C, D, etc. from the Chapter Layout pane, the output was built successfully.
    I tried moving Topics C, D, etc. to the top of the Chapter Layout pane, and got the same error. I tried creating a new folder and put Topics C, D, etc. into that folder. Failure after failure.
    As an experiment, I removed all the Topics C, D, etc from the Chapter Layout pane, but then added them to the Print Document Section Layout pane (not where I want them). The Printed Documentation built successfully.
    During attempts to build with Topics C, D, etc. in the Chapter Layout pane, I kept getting a Word error: Word is trying to recover your information. After that there was always a failure.
    Selecting PDF as the output did not work when the Topic C, D, etc. files were at the bottom of the Chapter Layout pane.
    I create a new TOC and a new Printed Documentation SSL. Failed to generate.
    As a matter of reference, I've been generating Printed Documentation from the same TOC for more than a year and so cannot figure out what has changed in RoboHelp or Word to cause this grief .
    Has anyone experienced anything like this?
    Carol

    Dear Peter,
    Thanks for following up. Last Friday I finished extensive testing on my own and working with RoboHelp Support. Here's what I sent to Support this morning.
    If after reading this screed, you think it worthwhile for me to get a copy from Source Control for you to look at, I will do so. Thanks for offering to look at it.
    Environment
    Windows 7 Enterprise Service Pack 1, 8.00 GB RAM, 64-bit OS
    Microsoft Office Professional Plus 2010 Version 14.0.7106.5003 64-bit--Note: We repaired my current version of Word, in case that was the problem, but did not reinstall Office--we do not think that the Word version is the problem because we generated successfully with other TOCs and when generating individual documents.
    RoboHelp 10.0.1.292. Upgraded from RoboHelp 9 in May 2013. Replaced hard drive in September 2013 and reinstalled RoboHelp.
    Visual Studio 2010 Professional 10.0.40219.1 SP1Rel (I open the project from Source Control and check files out to a folder on my desktop.)
    Issue
    Printed Documentation failed multiple times with the default Table of Contents, which contains all the topics in the project. TOC specs are as follows:
    Properties: .docx, desktop location, no conditions, embedded images, “Generate a single document”, “Retain hyperlinks”.
    330 files, 12 top-level books, 15 second-level books, 7 third-level books, 6 fourth-level books, and 8 fifth-level books
    Results
    Generation to Printed Documentation does NOT fail for other, module-specific TOCs, nor to WebHelp Pro SSLs for the same sets of topics. In addition, and perhaps more important, generation to Printed Documentation does NOT fail with “Generate Individual Documents” selected, or when there are approximately fewer than 259 files in the TOC.
    Did not fail consistently based on any particular topic.
    Did not fail consistently based on location of any particular topic in the TOC.
    Failed when I created new TOCs based on ‘working’ TOCs. For example, copied a module-specific TOC and then added topics to it from the default (superset) TOC. I did this in case the original default TOC was corrupted.
    Failed when I create a new TOC with the same folder/file structure from scratch.
    Failed when I created a new TOC with a flat file structure from scratch.
    Failed when I retrieved an older TOC from the last release of the product.
    Failed when I created new SSLs each time. I did this in case the SSLs had got corrupted.
    Failed when I did not open the project from Source Control (removed project from Source Control and worked locally).
    Began to see failure when there were more than about 258-263 files in the TOC. For example, successfully generated Printed Documentation with 262 files in the TOC. Added one topic and the generation failed. Removed that topic and added several others, one at a time. Consistently failed. To test this, I created a TOC with all the files in a flat structure, generated a report for the TOC, printed it, and counted the number of files. I then began deleting files and regenerating the Printed Document to try to identify the number of files in the TOC when the generation failed. Successfully generated up to about 258 files and then it began failing. (Occasional successes at 260 and 261, but that may be because I didn’t always consistently remove the Glossary and Index from the Chapter Layout pane.)
    Other Comments
    (I know that we should generally post non-RH issues to other forums, but in this case I wanted to include all potentially related issues in this posting.)
    The first time you generate any type of output, the “Critical error of Source Control Provider. Please restart IDE.” Message appears. This message appears behind RoboHelp. As a result, if the RoboHelp window is maximized, you think that RoboHelp is hung. Forcing a close of RoboHelp leaves the partially generated Word document in an unstable state. When you re-open RoboHelp and try to generate the output again, RoboHelp says that the output is in use. Unfortunately, there is no way to ‘free’ the Word document and you have to restart the computer. In addition, when the dialog box is hidden, even using Alt+Tab to find the dialog box is complicated because you can’t grab it and click OK until RoboHelp completes its processing. The workaround is to reduce the size of the application window so that you can see the dialog box and try to quickly grab it and click OK. That said, as soon as processing is complete you can grab the dialog box and click OK; at that point RoboHelp displays its own error message about the success or failure of the output generation. It is not clear whether the RoboHelp API or Source Control puts up this error message, but it’s definitely a problem until you happen upon the workaround.
    RoboHelp does not check SSLs even when I right-click the SSL in the Single Source Layouts pane, click Check In, select the XML and SSL files, and leave “Keep checked out” deselected. The red check mark remains next to the SSL name. In addition, even when I Check In All files before closing the project, the next time I open the project RoboHelp displays a series of Check In dialog boxes requiring me to check them in again.
    When RoboHelp hangs during a Printed Documentation failure and the Version Control setting is to check in all files when closing a project (which I’ve now deselected to avoid this problem), Ctrl+Alt+Del indicates that you cannot shut down the program because RoboHelp is waiting for a response. Yes, RoboHelp was waiting for me to check in some files (because of the Version Control setting), but hid the Check In Source Files dialog box behind the application. This usually left a Word document in limbo, forcing me to restart the computer.
    At one point RoboHelp stopped saving changes to an SSL after I made changes and clicked Save and Generate. Each time I reopened the SSL, I had to select .docx, etc. all over again.
    Carol

  • Printing a JPanel (Under pressure)

    I am trying to print a JPanel on which i have displayed information using drawString(). This works grand as long as the inforation all fits on one page. The problem occurs when i have too much information to display and it doesn't fit on one page. I thought that it would print the rest one different pages but this does not happen. Only the information that fits on the first page is printed.
    I'm wondering is there some way of printing over multiple pages.
    Any help would be really helpful.
    Thanks.

    Have you checked out the following webpage? Its from Manning's Swing book tutorial on building a word processor and theres a chapter on printing. It certainly helped me:
    http://manning.com/sbe/files/uts2/Chapter22html/Chapter22.htm

  • Printing a jpanel

    is it possible to print a jpanel i can print individual components but i want to do a printout that contains many components. any advice

    You make the JPanel implement the Printable interface. Here's a small code sample that I recently created when I tried to make a printable panel. Note that I've made it so that the buttons don't print:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.print.PageFormat;
    import java.awt.print.Printable;
    import java.awt.print.PrinterException;
    import java.awt.print.PrinterJob;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    public class PrintFrame extends JPanel implements Printable
        private static final int TF_SIZE = 20;
        private JFrame mainFrame = null;
        private NoPrintButton insertData = new NoPrintButton("Insert Data");
        private NoPrintButton printFrame = new NoPrintButton("Print");
        private String[] labelNames =
                "Name", "Age", "Phone Number", "Sex"
        private String[] textValues =
                "John Smith", "55", "555-555-5555", "male"
        private JTextField[] dataFieldArr = new JTextField[labelNames.length];
        public PrintFrame(JFrame mainFrame) {
            super();
            this.mainFrame = mainFrame;
            final int BS = 10;
            setBorder(BorderFactory.createEmptyBorder(BS, BS, BS, BS));
            setLayout(new BorderLayout());
            add(createTextPane(), BorderLayout.CENTER);
            add(createButtonPane(), BorderLayout.SOUTH);
        private JPanel createButtonPane()
            JPanel btnPane = new JPanel();
            btnPane.add(insertData);
            btnPane.add(printFrame);
            insertData.addActionListener(new ButtonListener());
            printFrame.addActionListener(new ButtonListener());
            return btnPane;
        private JPanel createTextPane()
            int labelLength = 100;
            int labelHeight = 20;
            JPanel textPane = new JPanel();
            textPane.setLayout(new GridLayout(0, 1));
            for (int i = 0; i < dataFieldArr.length; i++)
                JPanel rowPane = new JPanel();
                JLabel myLabel = new JLabel(labelNames);
    myLabel.setPreferredSize(new Dimension(labelLength, labelHeight));
    rowPane.add(myLabel);
    dataFieldArr[i] = new JTextField(TF_SIZE);
    rowPane.add(dataFieldArr[i]);
    textPane.add(rowPane);
    return textPane;
    private void printPanel()
    PrinterJob printJob = PrinterJob.getPrinterJob();
    boolean doPrint = printJob.printDialog();
    if (doPrint)
    printJob.setPrintable(this);
    try
    printJob.print();
    catch (PrinterException pe)
    pe.printStackTrace();
    public int print(Graphics g, PageFormat pf, int page)
    throws PrinterException
    if (page > 0)
    return NO_SUCH_PAGE;
    * User (0,0) is typically outside the imageable area, so we must
    * translate by the X and Y values in the PageFormat to avoid clipping
    Graphics2D g2d = (Graphics2D) g;
    g2d.translate(pf.getImageableX() + 30, pf.getImageableY() + 50);
    mainFrame.printAll(g); // if you want to print the JPanel only, then delete "mainFrame." here
    return PAGE_EXISTS;
    private class ButtonListener implements ActionListener
    public void actionPerformed(ActionEvent ae)
    NoPrintButton myBtn = (NoPrintButton) ae.getSource();
    if (myBtn == insertData)
    for (int i = 0; i < dataFieldArr.length; i++)
    dataFieldArr[i].setText(textValues[i]);
    else if (myBtn == printFrame)
    printPanel();
    * This is nothing but a plain JButton with the print method overridden by
    * a method that does nothing. This will prevent the button from being printed but
    * leaves a blank space in the output where the button used to be.
    * @author Pete
    private class NoPrintButton extends JButton
    public NoPrintButton(String text) {
    super(text);
    @Override
    public void print(Graphics g)
    // override print method with blank method
    private static void createAndShowGUI()
    JFrame frame = new JFrame("Print Frame Application");
    frame.getContentPane().add(new PrintFrame(frame));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args)
    SwingUtilities.invokeLater(new Runnable()
    public void run()
    createAndShowGUI();
    Edited by: petes1234 on Sep 17, 2007 5:36 PM

  • I spilled water on my laptop and my "i", "j" and "k" letters don't work on my laptop. However my main problem is that my password contains an "i" so i am locked out of my computer. Any ideas how I can get around the password and login.

    I spilled water on my laptop and my "i", "j" and "k" letters don't work on my laptop. However my main problem is that my password contains an "i" so i am locked out of my computer. Any ideas how I can get around the password and login. I tried the method where you go into single user mode and type in commands, however that method uses some of the letters that are not working on my laptop.

    You didn't mention which version of OS X your running but there are password reset utilities provided OS X: Changing or resetting an account password (Snow Leopard and earlier) - Apple Support  or  OS X: Changing or resetting an account password - Apple Support
    Alternately you can use an external keyboard to log in and change the password. Make a backup if you don't have one, it's likely that your problems aren't over. If that water continues to migrate downward and fries the logic board your macbook will be toast.

Maybe you are looking for