Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3898
| From | "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Drawing columns heade |
| Message-ID | <b2e64b79-536a-4468-afdf-719d3f058aaf@1g2000pre.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <c15838b3-6ebe-4079-81a5-31002b82643d@j1g2000p |
| Date | 2011-04-27 15:47 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
On Aug 6, 1:09 am, Chanchal <chanchal.ja...@gmail.com> wrote:
> Actually what i want to develop is a table like this
>
> http://picasaweb.google.com/chanchal.jacob/Java/photo#523104972145407...
Screenshots! Great gear. A picture speaks a
thousand words, no?
(snip)
> I have user JTable rather than 'tame-table' to reduce complexity of
> this example.
I notice. That code was also a very good description
of the *immediate* problem of the table header not
appearing (that is the current problem, right?).
You are going to swear when you see how close you
were to seeing that header.. ;)
<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"},{"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>
HTH
--
Andrew Thompson
http://pscode.org/
---
* 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 "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
csiph-web