🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #924

Re: Setting column titles in JTable, TableDialogEditDemo example

#924
From: John McGrath [TeamB]
Date: Thu, 02 Dec 2004 03:27
53 lines
3699 bytes
On 12/1/2004 at 5:04:16 PM, Richard wrote:

> Ok.  Is there a similarly easy (or at least elegant) way to get row
> headers (i.e., a JLabel name for each row)?  I've searched the
> newsgroups and the help system, and it looks like the only way is to
> manually use column 1 for the row labels.

There is an analogous way to place the row headers:  a JScrollPane has a
row header as well as a column header, so you just need to place the row
header component there and the JScrollPane will handle the scrolling.

There is no Swing component for row headers that is analogous to the
JTableHeader, but it can be pretty easy to write, especially if you use
fixed row heights.  You just need to use another JTable, with your own
TableCellRenderer to make the headers look like you want them to look.
But if your row heights vary, then you have to deal with synchronizing
them.

One good place to figure out how to do odd things in Swing was always the
"tame" Swing examples site.  A guy named Nobuo Tamemasa had a very large
site with examples of doing just about anything you might want to do with
Swing.  Unfortunately, the site went off-line, and nobody seems to know
what happened to the guy.  But fortunately, some people managed to save
the examples from his site, and you can find them pretty easily on the net.

The following is a nicely organized site allows you to browse through the
Tamemasa examples, with screen shots and source code for each one.

    http://www.objects.com.au/java/examples.do

This site is not as well suited to browsing.  It has some screen shots,
but I do not think you can see the source code directly.  But it has a zip
file with the entire collection available for download:

    http://www.physci.org/codes/tame/index.jsp

One last note:  The exact legal status of the source code is not clear.
Nobuo Tamemasa had these examples posted on the web for several years
without any copyright notice, so it is very reasonable to assume that he
expected people to use them.  But he is nowhere to be found, and AFAIK he
never gave anyone explicit permission to post them elsewhere.  It is safe
to use the examples for learning Swing, since that was the intent of his
site, but I would definitely not recommend cutting a book deal where you
plan to publish them.  :o)

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <xn0dqic152q8rpn001@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!news-out.ntli.net!newsrout1-gui.ntli.net!ntli.net!pe1.news.blueyonder.co.uk!blueyonder!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41a8c0a1@newsgroups.borland.com> <41ab0304@newsgroups.borland.com> <xn0dqe27g17u5no001@newsgroups.borland.com> <41ae3fd6$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,2ec5ccf013472ede
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "John McGrath  [TeamB]" <ng-b@JPMcGrath.net>
Subject: Re: Setting column titles in JTable, TableDialogEditDemo example
Newsgroups: borland.public.jbuilder.java.swing
References: <41a8c0a1@newsgroups.borland.com> <41ab0304@newsgroups.borland.com> <xn0dqe27g17u5no001@newsgroups.borland.com> <41ae3fd6$1@newsgroups.borland.com>
User-Agent: XanaNews/1.16.5.2
Message-ID: <xn0dqic152q8rpn001@newsgroups.borland.com>
X-Ref: newsgroups.borland.com ~XNS:00000090
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
NNTP-Posting-Host: 141.158.60.123
Date: 1 Dec 2004 20:27:18 -0700
X-Trace: newsgroups.borland.com 1101961638 141.158.60.123 (1 Dec 2004 20:27:18 -0700)
Lines: 53
X-Authenticated-User: jpmcgrath
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!news-out.ntli.net!newsrout1-gui.ntli.net!ntli.net!pe1.news.blueyonder.co.uk!blueyonder!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail