I want to print a JFrame with two things in it.
I have a Jtable that could have as many as 500 row in it, and I need to be able to print all of them. I have a JTextfield under the JTable in the Jframe. I want to print both of these at the same time. The problem I am having is when I print the jtable it only prints the visible part. What I really care about is the content of the JTable and not the Table itself.
Edit: I use Netbeans to build my Gui so I don't really know how to display the code for the Panel, Table, and TextFields.
                           PrinterJob PJ   =   PrinterJob.getPrinterJob();
                       PJ.setPrintable(this);
                    boolean doPrint = PJ.printDialog();
       JOptionPane.showMessageDialog(null, doPrint);
        if(doPrint){
            try {
                PJ.print();
            } catch (PrinterException ex) {
                JOptionPane.showMessageDialog(null, ex.getMessage());
           }
        } 
I have the print method here
   public int print(Graphics g, PageFormat format, int page_index) throws PrinterException {
    if (page_index > 0) {
        return Printable.NO_SUCH_PAGE;
    }
      // get the bounds of the component
    Dimension dim = this.getSize();
    double cHeight = dim.getHeight();
    double cWidth = dim.getWidth();
    // get the bounds of the printable area
    double pHeight = format.getImageableHeight();
    double pWidth = format.getImageableWidth();
    double pXStart = format.getImageableX();
    double pYStart = format.getImageableY();
    double xRatio = pWidth / cWidth;
   double yRatio = pHeight / cHeight;
    Graphics2D g2 = (Graphics2D) g;
    g2.translate(pXStart, pYStart);
    g2.scale(xRatio, yRatio);
    this.paint(g);
     this.print(g);
    return (Printable.PAGE_EXISTS);
}
now when i use this code it give me complete frame image and also only the dipalyed jtable..
1.What i want is how can omit the buttons
2.print my jlables ,jTextFields and my Jtable together on same page as it will be a bill of store... now when i m using jtable.print(); it is only showing jtable on page ..similar results for other JComponents any help ..how can i do this