> At present I am beating my head against the sizes of columns
> in a JTable.

    JTable is an entirely different creature.  Although the default cell
renderer is a JLabel, sizing depends on a number of factors.  For the down
and dirty, see JTable.doLayout()

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTable.html#doLayout()


    JTable row heights: JTable.getRowHeight() - Returns the height of a
table row, in pixels. The default row height is 16.0.

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTable.html#getRowHeight
()

    See also getRowHeight(int row), setRowHeight(int rowHeight),
setRowHeight(int row, int rowHeight)


    JTable column widths are determined by the individual TableColumn.
Unfortunately, the easiest way to get TableColumns is by
JTable.getColumnModel() - Returns the TableColumnModel that contains all
column information of this table.

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTable.html#getColumnMod
el()

then

    TableColumnModel.getColumn(int columnIndex) - Returns the TableColumn
object for the column at columnIndex.

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/table/TableColumnModel.h
tml#getColumn(int)


    Once you have the TableColumn,

    TableColumn.getMinWidth() - The default minWidth is 15.

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/table/TableColumn.html#g
etMinWidth()


    TableColumn.getPreferredWidth() - The default preferred width is 75.

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/table/TableColumn.html#g
etPreferredWidth()

    See also getMaxWidth(), setMaxWidth(int maxWidth), setMinWidth(int
minWidth), setPreferredWidth(int preferredWidth)

    The books I mentioned earlier go into detail about how all this works
together, including end user resizing on the fly.  And you're welcome, hope
you find the AWT book helpful.

    There are also several JTable demos included in the JDK, as well as
SwingSet2.  Again, the Java Tutorial has a section on JTables.  Being good
at GUIs is no different than any other area - no pain, no gain.  If the pain
is not acceptable, call in someone who chose to go through it.


                                                         Joe Sam

Joe Sam Shirah -        http://www.conceptgo.com
conceptGO         -        Consulting/Development/Outsourcing
Java Filter Forum:       http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International?    http://www.jguru.com/faq/I18N
Que Java400?             http://www.jguru.com/faq/Java400


----- Original Message -----
From: "Richard O. Hammer" <[EMAIL PROTECTED]>
To: "Research Triangle Java User's Group mailing list." <[EMAIL PROTECTED]>
Sent: Tuesday, September 02, 2003 5:16 PM
Subject: Re: [Juglist] the sizing of Java GUI components


> Thanks to those who have responded to my question.
>
> I know about layout managers, and some years ago made a handful of
> frames with gridbaglayout, getting them laid out well enough for my
> need at the time.  But I remember the need for trial and error,
> setting sizes and preferred sizes and usually having my settings
> ignored when the component was displayed, until somehow I stumbled
> onto something that worked.  Trial and error works, given time.
>
> Which size settings work in which circumstances?  Is there anybody
> savvy enough to predict and get results better than random?  If so
> that person might know some principles.  I'd like to know those
> principles too.
>
> At present I am beating my head against the sizes of columns in a
> JTable.  In preference to descending into the specifics of what I am
> trying to do with a JTable, I have hoped to learn principles which I
> might apply ... assuming those principles exist.
>
> Joe Sam Shirah wrote:
> >     My recommendations for serious Swing developers are David Geary's
> > Graphic Java series, Volume 1 ( AWT ) and Volume 2 (  JFC ), and John
>
> Thank you.  I've heard Geary's books recommended before, and have
> ordered the Volume 1.
>
> Rich Hammer
>








_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to