Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Java-table with horizontal scroll bar

Subject: Java-table with horizontal scroll bar

From: Bruno Luong

Date: 18 Feb, 2010 11:06:05

Message: 1 of 4

I'm using the wonderful Java-based table by Yair Altman:
http://www.mathworks.com/matlabcentral/fx_files/14225/1/table.png

The table is embedded within a GUI panel. When the table is longer than the panel, a vertical scroll bar automatically appears. But when the table is larger, it does not seem to have an similar horizontal scroll bar. Is it possible?

I run 2006B under windows. Here is the example code:

f = figure();
createTable(f, num2cell(rand(1,100)), num2cell(rand(100))) ;

Thanks,

Bruno

Subject: Java-table with horizontal scroll bar

From: Oleg Komarov

Date: 18 Feb, 2010 12:04:06

Message: 2 of 4

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <hlj6ut$pvu$1@fred.mathworks.com>...
> I'm using the wonderful Java-based table by Yair Altman:
> http://www.mathworks.com/matlabcentral/fx_files/14225/1/table.png
>
> The table is embedded within a GUI panel. When the table is longer than the panel, a vertical scroll bar automatically appears. But when the table is larger, it does not seem to have an similar horizontal scroll bar. Is it possible?
>
> I run 2006B under windows. Here is the example code:
>
> f = figure();
> createTable(f, num2cell(rand(1,100)), num2cell(rand(100))) ;
>
> Thanks,
>
> Bruno

Quickly tested your lines of code... R2009b Win64 2008 doesn't have horizontal scroll bar.

Oleg

Subject: Java-table with horizontal scroll bar

From: Yair Altman

Date: 18 Feb, 2010 17:03:06

Message: 3 of 4

"Bruno Luong" <b.luong@fogale.findmycountry> wrote...
> I'm using the wonderful Java-based table by Yair Altman:
> http://www.mathworks.com/matlabcentral/fx_files/14225/1/table.png
>
> The table is embedded within a GUI panel. When the table is longer than the panel, a vertical scroll bar automatically appears. But when the table is larger, it does not seem to have an similar horizontal scroll bar. Is it possible?

Thanks for the kind words Bruno.

CreateTable sets the column resizing mode to AUTO_RESIZE_SUBSEQUENT_COLUMNS (line #212). This means that it always uses the entire container width and resizes its columns accordingly when either a column or the container is resized. You can modify this by providing a different resizing mode. Two separate examples were provided in CreateTable's help section:

createTable(...,'AutoResizeMode',javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS)
createTable(...,'AutoResizeMode',4)

In your case, I think you wanted AUTO_RESIZE_OFF (=0). The full list of available resize modes is presented here: http://java.sun.com/javase/6/docs/api/javax/swing/JTable.html#field_summary

Yair Altman
http://UndocumentedMatlab.com

Subject: Java-table with horizontal scroll bar

From: Bruno Luong

Date: 18 Feb, 2010 17:46:05

Message: 4 of 4

Hello Yair,

I knew I'll get assistance from you and it will work! You are the Java king.

Bruno

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us