> I have code that will convert a JTable to an image, but the problem is that
> if the height of the JTable is greater than the height of the screen, the
> bottom of the table is cut off. I do not want to display the JTable on the
> screen at any time. Here is my code:
you can place your frame left from screen, so it is invisible for user.
> myJTable.setSize(width, height);
> JScrollPane scrollPane = new JScrollPane(myJTable);
> scrollPane.setBorder(new javax.swing.border.EmptyBorder(2, 2, 2, 2));
> scrollPane.setViewportBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
> scrollPane.setPreferredSize(new Dimension(width, height));
> JFrame frame = new JFrame();
[quoted text clipped - 5 lines]
> Graphics2D g2 = buffered.createGraphics();
> scrollPane.printAll(g2);
why scrollPane.printAll(g2) ?
you should ask JTable for preferredSize and create BufferedImage with
appropriate size.
then just paint myJTable into g2.
--
____________
http://reader.imagero.com the best java image reader.
Ben Wilson - 20 Apr 2004 17:39 GMT
ak
Thanks for responding...
> > I have code that will convert a JTable to an image, but the problem is
> that
[quoted text clipped - 3 lines]
>
> you can place your frame left from screen, so it is invisible for user.
I have already achieved the process of creating an image of the table
without showing it on the screen. The only problem that remains is
that the table cannot be bigger than the screen, and if it is, it gets
cut off. I don't know why the table has to be associated with the
screen at all since I don't want to display it.
> > myJTable.setSize(width, height);
> > JScrollPane scrollPane = new JScrollPane(myJTable);
[quoted text clipped - 16 lines]
> appropriate size.
> then just paint myJTable into g2.
You suggestion works too, however it doesn't address the problem. It
appears that a frame cannot be bigger than the screen, and a component
cannot be laid out unless it is in a frame. If anyone knows a way
around this, I would really like to know!
Thanks
Ben
Thomas Weidenfeller - 21 Apr 2004 07:59 GMT
> You suggestion works too, however it doesn't address the problem. It
> appears that a frame cannot be bigger than the screen, and a component
> cannot be laid out unless it is in a frame. If anyone knows a way
> around this, I would really like to know!
AffineTransform, ScrollPane, and maybe a few more.
/Thomas