Hi!
Iam wondering if there is a way to add row names to JTable as u can add
colum names?
and how do I create multiple JTables in one gui?
________________________
Thanx in advance
|
|
0
|
|
|
|
Reply
|
Carramba
|
4/1/2006 5:05:40 PM |
|
Carramba wrote:
> Hi!
>
> Iam wondering if there is a way to add row names to JTable as u can add
> colum names?
> and how do I create multiple JTables in one gui?
>
>
>
> ________________________
> Thanx in advance
>
>
Use a layout that suites you design and then just add the JTables
JComponents to different locations in your layout. See layouts "Laying
Out Components Within a Container"
http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html
--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
|
|
0
|
|
|
|
Reply
|
IchBin
|
4/2/2006 12:09:34 AM
|
|
Hi you can use this code to add a new table as a row header table. You
need to define your own Data Model (RowModel in this sample) so that it
displays the correct RowHeaderValue
JTable table = new JTable();
JScrollPane scrollPane = new JScrollPane(table,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
add(scrollPane, BorderLayout.CENTER);
// rowHeader is the table which will have your row header details
JTable rowHeader = new JTable(new RowModel(table.getModel()));
TableCellRenderer renderer = new RowHeaderRenderer();
Component comp =
renderer.getTableCellRendererComponent(rowHeader, null, false, false,
rowHeader.getRowCount() - 1, 0);
rowHeader.setIntercellSpacing(new Dimension(0, 0));
rowHeader.setPreferredScrollableViewportSize(d);
rowHeader.setRowHeight(table.getRowHeight());
rowHeader.setDefaultRenderer(Object.class, renderer);
scrollPane.setRowHeaderView(rowHeader);
JPanel blank = new JPanel();
blank.addMouseListener(ml);
scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, blank);
|
|
0
|
|
|
|
Reply
|
hari
|
4/3/2006 8:42:41 AM
|
|