Re: JTable sizing



Larry Coon wrote:
Roedy Green wrote:

freeze them with a set Max

Thanks. That section of the code now looks like:

JTable table = new JTable(new MyTableModel());
for (int i = 0; i < table.getColumnCount(); i++) {
TableColumn col = table.getColumnModel().getColumn(i);
col.setMinWidth(i*50+75);
if (i < table.getColumnCount() - 1)
col.setMaxWidth(i*50+75);
}

Not -exactly- what I want, but close enough. I assume that since
I'm now setting both the min & max widths, I can do away with
setting the preferred width.

One question: Since the default behavior for the horizontal scroll
bar is HORIZONTAL_SCROLLBAR_AS_NEEDED, then if I resize the window
so that it's not wide enough for the table, I should be getting a
horizontal scroll bar, right? I'm not getting one...


You don't have horizontal scroll because you defined auto resize mode.
Horizontal bar will appear if you will turn it off

table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);


Larry Coon
University of California
.



Relevant Pages

  • Re: FullScreen Mode Horizontal ScrollBar Missing
    ... Screen - which togles hiding sll of the tool bars and ... What is also does is hides the horizontal scroll bar but NOT the verticle. ... > GreenBoy wrote: ...
    (microsoft.public.excel.programming)
  • Re: scroll bars
    ... Projects are ok on other PCs ... Project at fault, ... I have done something that causes the horizontal scroll ... bar to disappear when I "remove split window" ... ...
    (microsoft.public.project)
  • Re: scroll bars
    ... Does it occur with this project on other PCs? ... Has SP3 been installed? ... I have done something that causes the horizontal scroll ... bar to disappear when I "remove split window" ... ...
    (microsoft.public.project)
  • Detecting if a combo box has a horizontal scrollbar
    ... I have tried querying the style, but combo boxes turn off the WS_HSCROLL ... STATE_SYSTEM_INVISIBLE even if the horizontal scroll bar is visible. ...
    (microsoft.public.win32.programmer.ui)
  • Re: JTable sizing
    ... TableColumn col = table.getColumnModel.getColumn; ... Since the default behavior for the horizontal scroll ... horizontal scroll bar, right? ... University of California ...
    (comp.lang.java.gui)

Loading