Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I show the headers of a JTable, without JScrollPane/JPanel/JDialog

843804Jan 25 2005 — edited Jan 27 2005
Hi,

I have been trying to do this for days now...to no avail.
I need to pring out a JTable. My code looks something like the following:
public int print(Graphics g, PageFormat format, int pageIndex) {
     table.setSize(new Dimension(260, 75 + 12*table.getModel().getRowCount()));
     buffered = PatientPrintManager.disableDoubleBuffering(panel);
     g2d.scale(X_SCALE, 1);
     table.paint(g2d);

     ...
     
Now that works fine. The problem is, header don't show up. So I tried putting the JTable inside a JScrollPane/JPanel/JDialog. You would think this would work out fine. But the problem is, in order for them to work. The JScrollPane/JPanel/JDialog must be visible, otherwise it wont print.

So I create my own classes (of the object above), and overrose the isShowing() method to return true. Now you would think this would work. Wrong again.
Turns out, that before the printing occurs, java checks to see if the object being printed belongs to the correct thread (i.e. the thread that is created when on of the above objects is set to be visible).

So now that none of that works. I need to someone figure out how to show a JTable with headers, without using such objects.

any help is greatly appreciated, as my frustration is pushing me beyong my limits. Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 24 2005
Added on Jan 25 2005
4 comments
836 views