olduitable implements a wide variety of properties focused on customizing table's appearance.
These properties are: ButtonDownFcn, CellEditCallback, CellSelectionCallback, ColumnAlign, ColumnColor, ColumnEditable, ColumnFormat, ColumnFormatData, ColumnName, ColumnResizable, ColumnSortable, ColumnStriping, ColumnToolTip, ColumnWidth, Data, Enable, FontName, FontSize, FontStyle, ForegroundColor, GridColor, HeaderBackground, HeaderForeground, HeaderGridColor, HeaderSelectionBg, HeaderSelectionFg, KeyPressFcn, KeyReleaseFcn, Parent, Position, RowColor, RowHeight, RowName, RowStriping, SelectionBackground, SelectionForeground, SelectionBorderColor, Tag, UIContextMenu, Units, UserData and Visible.
Besides this class includes useful methods to insert or delete rows and columns, paste blocks of cells or sort columns as a typical spreadsheet, many of them available through a default context menu and keyboard shortcuts.
These methods are: saveInfo, fitAllColumns2Panel, fitColumn2Data, setSelection, getValue, setValue, setCellBg, setCellFg, sortColumn, unsort, paste, cut, insertRows, insertColumns, deleteRows, deleteColumns and loadInfo.
Compared to the undocumented Matlab's uitable, olduitable can be loaded faster when a large amount of data is assigned. Obviously, the official version is the fastest and also uses much less memory space, but if these are not a problem, this class could be a reasonable alternative.
To use this class, once downloaded the rar file we must copy the @olduitable folder to any folder that is in the Matlab search path or use the addpath command.
To prevent conflicts with other Java classes previously added to the dynamic path, is desirable to create (or modify) a custom javaclasspath.txt including the full name of the javaClasses.jar file (this is inside the @olduitable folder), that packages the necessary Java classes for olduitable to work.
For more details run 'doc olduitable' in the command window or go to https://github.com/pbaezr/olduitable/blob/master/README.md
There is one issue that needs an update. If I insert Chinese symbol in table, all characters will not be shown, instead just some square symbols. How can I fix this? Thanks
PERFECT!!!! Solve my headaches with uitable for SO SO many years! keeps working on that guys!!
I'm on a mountain vacation….
I'll test your suggestion within 2 weeks.
Send me your your email to firstname.lastname@example.org
Hi Alain, thanks for your comment and sorry for the delay.
To change the column header's font you have to add the follow code in set.FontSize function:
columnheaderRenderer = obj.columnHeader.getDefaultRenderer;
text = columnheaderRenderer.getLayout.getLayoutComponent(java.awt.BorderLayout.CENTER);
arrow = columnheaderRenderer.getLayout.getLayoutComponent(java.awt.BorderLayout.EAST); % arrow that indicates if the column is sorted
I have to add the column headers in the renderers to display the text in the center and the sort arrow to the right, so for this reason obj.columnHeader.setFont(font) doesn’t work
Maybe you have to modify too the ColumnName property because this considers a default height for the column header (24 px).
On the other hand, I have added the Extent property (read-only) that indicates the width and height of the rectangle containing the table in pixels, so for adjust the table size you use:
previousUnits = t.Units;
t.Units = ‘pixels’;
t.Position(3:4) = t.Extent;
t.Units = previousUnits;
I must tell you that my laptop has 3200X1800 screen definition with 14" diagonal. For the same reason the d.height must be scale according to a dpi value…
Thanks for your job.
Very versatile "uitable" and well documented. I have added a Background Property similar to the Foreground one.
I have tried to test more or less all the options. The font size value such as a current value of 12 is very small. I have introduced a scale factor depending of the dpi now this seems correct.
dpi = java.awt.Toolkit.getDefaultToolkit().getScreenResolution();
val = round(val * dpi / 96);
With this modification
% set value in the body
the last line has no effect although the font properties are OK.
t.fitAllColumns2Panel does not work in my test
Lastly a question, using standard uitable what would be the equivalent of setting position to extent?
Setting position(3) (in pixels) equal to the sum of column width (in pixels) does not work.
Added 'fitColumn2Data' method