Link to home
Start Free TrialLog in
Avatar of Olaf_Bloemer
Olaf_Bloemer

asked on

Some questions about JTable. (row-based design, displaying headers or not, )

I want to display a list of n pairs (x_value, y_value)
in a JTable with 2 rows (and n+1 columns) in a matter
like

x_value     x1     x2     x3     ...     xn
y_value     y1     y2     y3     ...     yn

Hence what I needed, would be a JTable with specifying
types for the rows rather than columns.
In addition the y-values should be editable while the
x-values are not.

1. Is it possible to specify row headers?

2. What is the standard method to suppress column headers?

3. Why are column headers shown, if adding a JTable to
some Layout wrapping it with a JScrollPane, while
headers are not shown, when not using JScrollPane.
Is it a Java bug?

Thank you very much!
ASKER CERTIFIED SOLUTION
Avatar of António Sargento
António Sargento
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Olaf_Bloemer
Olaf_Bloemer

ASKER

Thank you for your answers and the example!
But how can I get, say, cells with right alignment
for the y_values while staying with left alignment
for the x_values?
You could do that by defining your own CellRender.
In http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
there was several examples how could you define a cell render.
Thank you for your efforts.
It's not really satisfying that there no classes
like TableRow and TableRowModel, but I'll try to find
a systematic work-around...

Thanks again,
best regards,

Olaf