how do i create a jtable header that takes up 2 lines ?
such as below ?
| Sex |
| M | F |
Thanks again
http://members.xoom.com/lookads
Printable View
how do i create a jtable header that takes up 2 lines ?
such as below ?
| Sex |
| M | F |
Thanks again
http://members.xoom.com/lookads
Check out this site..
http://www2.gol.com/users/tame/swing...Examples2.html
cannot compile the source code at
http://www2.gol.com/users/tame/swing...Examples2.html
because it imports user defined classes.
so, how now ?
http://members.xoom.com/lookads
Which example you were trying to compile ?
the example is this, as below. it could not compile :-
http://www2.gol.com/users/tame/swing...erExample.java
/* (swing1.1beta3)
*
* |-----------------------------------------------------|
* | | Name | Language |
* | |-----------------|--------------------------|
* | SNo. | | | | Others |
* | | 1 | 2 | Native |-----------------|
* | | | | | 2 | 3 |
* |-----------------------------------------------------|
* | | | | | | |
*
*/
//package jp.gr.java_conf.tame.swing.examples;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import jp.gr.java_conf.tame.swing.table.*;
/**
* @version 1.0 11/09/98
*/
public class GroupableHeaderExample extends JFrame {
GroupableHeaderExample() {
super( "Groupable Header Example" );
DefaultTableModel dm = new DefaultTableModel();
dm.setDataVector(new Object[][]{
{"119","foo","bar","ja","ko","zh"},
{"911","bar","foo","en","fr","pt"}},
new Object[]{"SNo.","1","2","Native","2","3"});
JTable table = new JTable( dm ) {
protected JTableHeader createDefaultTableHeader() {
return new GroupableTableHeader(columnModel);
}
};
TableColumnModel cm = table.getColumnModel();
ColumnGroup g_name = new ColumnGroup("Name");
g_name.add(cm.getColumn(1));
g_name.add(cm.getColumn(2));
ColumnGroup g_lang = new ColumnGroup("Language");
g_lang.add(cm.getColumn(3));
ColumnGroup g_other = new ColumnGroup("Others");
g_other.add(cm.getColumn(4));
g_other.add(cm.getColumn(5));
g_lang.add(g_other);
GroupableTableHeader header = (GroupableTableHeader)table.getTableHeader();
header.addColumnGroup(g_name);
header.addColumnGroup(g_lang);
JScrollPane scroll = new JScrollPane( table );
getContentPane().add( scroll );
setSize( 400, 120 );
}
public static void main(String[] args) {
GroupableHeaderExample frame = new GroupableHeaderExample();
frame.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
System.exit(0);
}
});
frame.setVisible(true);
}
}
http://members.xoom.com/lookads
What errors you are getting ? Did you download all the 4 files ????
If not , download all the 4 files . If yes , try to compile those files like this..
c:\> javac.exe GroupableHeaderExample.java ColumnGroup.java GroupableTableHeader.java GroupableTableHeaderUI.java
Before you compile , comment all "package ... " code.
I did compile those files in my machine. It's working fine.
Poochi..
Yes. It works. I did not know that i have to download all the files you specified.
Previously, i only downloaded 1 file and tried to compile.
Now, it works.
Thanks a lot.
http://members.xoom.com/lookads
:-)) you are welcome ..