Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3902
| From | "Chanchal" <chanchal@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Drawing columns heade |
| Message-ID | <1c22fc8c-854d-4df2-8069-fb3cc9183243@b30g2000prf.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <b2e64b79-536a-4468-afdf-719d3f058aaf@1g2000 |
| Date | 2011-04-27 15:47 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
Apologies. There was a mistake in the code i put up last time
The correct code should be
<sscce>
import java.awt.*;
import javax.swing.*;
public class TableColumHeaderTest extends JFrame{
public TableColumHeaderTest() {
// I have to call this - matter of habit..
setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
setLayout(new BorderLayout());
Object[][] headerData = {{"H1","H2"}};
//line change from
//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);
// it is rarely necessary to call setVisible()!
// (excepting root components)
//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);
}
}
</sscce>
The output of this code is http://picasaweb.google.com/chanchal.jacob/Java/photo#5231234101780286098
But what exactly i want is http://picasaweb.google.com/chanchal.jacob/Java/photo#5231234103592954258
i.e. {"H1","H2"} should be shown as the column header. Not {"th","th"}
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next | Find similar | Unroll thread
Re: Drawing columns heade "Chanchal" <chanchal@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
csiph-web