Re: Drawing columns headers of a JTable
Actually what i want to develop is a table like this
http://picasaweb.google.com/chanchal.jacob/Java/photo#5231049721454071970
So what i thought is i can use a 'tame table' as columnHeaderView of
the scroll pane and another table to display the data. following is my
code to do that
<code>
import java.awt.*;
import javax.swing.*;
public class TableColumHeaderTest extends JFrame{
public TableColumHeaderTest() {
setLayout(new BorderLayout());
Object[][] headerData = {{"H1","H2"},{"H3","H4"}};
Object[][] dataData = {{"D1","D2"},{"D3","D4"}};
Object[] tempHead = {"th","th"};
JTable headerTable = new JTable(headerData,tempHead);
JTable dataTable = new JTable(dataData,tempHead);
dataTable.getTableHeader().setVisible(false);
JScrollPane scrollPane = new JScrollPane(dataTable);
scrollPane.setColumnHeaderView(headerTable);
scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER,
headerTable);
getContentPane().add(BorderLayout.CENTER, scrollPane);
pack();
}
public static void main(String[] args){
TableColumHeaderTest t = new TableColumHeaderTest();
t.setSize(400,300);
t.setVisible(true);
}
}
</code>
I have user JTable rather than 'tame-table' to reduce complexity of
this example. But i think, if this works, the same concept will work
for 'tame-table' aslo. However the above code is not displaying the
table which i set as columnHeaderView for the JSCrollPane. Could you
please tell me what is preventing it being displayed and how i can
overcome that.
Also, i think, removing the column header and preventing two rows from
scrolling would make the same visual effect. Can that be done?
Thanks and Regards
Chanchal
On Aug 5, 6:37 pm, Andrew Thompson <andrewtho...@gmail.com> wrote:
On Aug 5, 11:07 pm, Chanchal <chanchal.ja...@gmail.com> wrote:
I mention this because you asked another question
on this forum that I discussed with you, and I am
wondering if what I said, solved the problem.
i'd like to bring to your attention that i have posted a reply to you
for the discussion mentioned.
I did not know what you meant until I checked my email.
*Do not send me email.*
If you start a thread on usenet, it is considered best
to keep the thread public, and my posting answers to the
groups is *not* a general invitation to contact me privately,
or 'chat' or any of the other inane things people seem
to want to do.
Any replies you have worth hearing, are best shared
with the same community where the thread is. Right
on the original thread.
The problem i'm currently facing is while using the code found athttp://www.codeguru.com/java/articles/139.shtml
Ohhh! You should have said you meant a 'tame'
table! When you said JTable I though you were
referring to the core J2SE class before any
alterations had been made.
The reason we should distinguish between them is
that while the tame codes achieved some amazing
things, on occasions they used very unusual means
to do that, and some of those techniques may not
work very well today.
Even more problematic, there are very few experts
around on the tame codes, so I doubt many people
will dare trying to badger one into a specific GUI.
You might try posting an SSCCE of code adapted from
the tame codes to demonstrate your problem, perhaps
someone can figure the solution from that.
<http://pscode.org/sscce.html>
--
Andrew Thompsonhttp://pscode.org/