-
Print preview jtable
I have a jtable with which I display my database. I would like to preview the pages before printing, and in portrait mode all is correct :
dOM93.png
but when I change the mode to landscape, there is a loss of data. It does not display all the rows of the table. It only takes the last page and copies it to the other pages.
rI7XR.png
[CODE]
protected void getThePreviewPages()
{
m_wPage = (int)(pp_pf.getWidth());
m_hPage = (int)(pp_pf.getHeight());
int scale = getDisplayScale();
width = (int)Math.ceil(m_wPage*scale/100);
height = (int)Math.ceil(m_hPage*scale/100);
int pageIndex = 0;
try {
while (true) {
BufferedImage img = new BufferedImage(m_wPage, m_hPage,
BufferedImage.TYPE_INT_RGB);
Graphics g = img.getGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, m_wPage, m_hPage);
if (bScallToFitOnePage) {
m_target.print(g, pp_pf, -1);
PagePreview pp = new PagePreview(width, height, img);
m_preview.add(pp);
break;
} else
if (m_target.print(g, pp_pf, pageIndex) != Printable.PAGE_EXISTS)
break;
PagePreview pp = new PagePreview(width, height, img);
m_preview.add(pp);
pageIndex++;
}
} catch (OutOfMemoryError om) {
JOptionPane.showMessageDialog(this,
"image is too big that run out of memory.", "Print Preview",
JOptionPane.INFORMATION_MESSAGE);
}
catch (PrinterException e) {
e.printStackTrace();
System.err.println("Printing error: "+e.toString());
}
}
protected void previewThePages(int orientation)
{
if (displayArea != null) displayArea.setVisible(false);
m_preview = new PreviewContainer();
getThePreviewPages();
JPanel panel = new JPanel();
panel.add(m_preview);
JPanel panel1 = new JPanel();
panel1.add(panel);
displayArea = new JScrollPane(panel1);
getContentPane().add(displayArea, BorderLayout.CENTER);
setLocationRelativeTo(null);
setResizable(true);
setExtendedState(this.MAXIMIZED_BOTH);
setVisible(true);
System.gc();
}
Similar Threads
-
By anonymous in forum VB Classic
Replies: 4
Last Post: 02-05-2003, 01:58 PM
-
By anonymous in forum VB Classic
Replies: 0
Last Post: 08-08-2002, 07:10 AM
-
By Doug in forum VB Classic
Replies: 1
Last Post: 10-22-2000, 06:07 PM
-
By Gianni Spano in forum Architecture and Design
Replies: 1
Last Post: 10-05-2000, 11:25 PM
-
By George in forum Database
Replies: 7
Last Post: 07-28-2000, 06:23 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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|