



Different GUI requirements might prefer using a compact combo-box approach, or the larger stand-alone panel. The same FontChooserPanel can also be displayed as a stand-alone font-selection panel, unrelated to any combo-box. For example, the preview text can be modified via the panel’s PreviewText property (or the setPreviewText(text) method). The combo-box presents a FontChooserPanel, which can be accessed (via the PopupPanel property or the corresponding getPopupPanel() method) after it has been initially created.
#FONT BOX MATLAB TEXT UPDATE#
There is also a corresponding setSelectedFont(font) to programmatically update the control with the specified Font object. Within the callback function, use getSelectedFont() to retrieve the updated font (again, a object). Set(hjFontPicker, 'ItemStateChangedCallback', FontComboBox = javacomponent(jFontPicker, position, gcf) Set (hjFontPicker, 'ItemStateChangedCallback', ) = javacomponent (jFontPicker, position, gcf ) This component has two variants: as a drop-down/combo-box ( ) and as a standard JPanel ( ): = javacomponent(jFontPanel,, gcf) FontChooserPanelĪs a final alternative for font selection, we can use the JIDE font-selection component. JFontPicker = .FontPicker(jFont, jLayout) JFont = ('Tahoma',, 10) % initial font to display (may not be ) JLayout = javaMethod('valueOf', '.FontPicker$Layout', 'WIDE_WITH_SAMPLE') % options: COMPACT, WIDE, WIDE_WITH_SAMPLE PLAIN, 10 ) % initial font to display (may not be ) JLayout = javaMethod ( 'valueOf', '.FontPicker$Layout', 'WIDE_WITH_SAMPLE' ) % options: COMPACT, WIDE, WIDE_WITH_SAMPLE Several screenshots of different parameter combinations are shown below: Up until Matlab release R2010a, FontPicker‘s constructor accepted optional parameters of a pre-selected font (a object), an optional boolean flag indicating whether to display sample text using the selected font, an optional layout indicator, and optional list of selectable font names. We can do this using the .FontPicker class. This is useful in forms where the font selection is only one of several user-configurable options, and where enough space must be reserved for other configuration controls. Use of drop-downs significantly reduces the display “real-estate” required by the control. FontPickerįont selection can also be shown with drop-downs (combo-boxes), rather than with lists as in DesktopFontPicker, FontPrefsPanel, or uisetfont. Using this class is admittedly more cumbersome than DesktopFontPicker and I would not recommend using it in practice. The only documented font-selection alternative in Matlab is uisetfont, which presents a popup dialog window that returns the selected font properties in a simple Matlab struct: Readers who are interested in additional details about the components mentioned in today’s post are referred to sections 3.3.3 and 5.5.2 of my book, Undocumented Secrets of MATLAB-Java Programming. However, since internal components can change without prior notice, there is no assurance that any particular component will continue to be available in future Matlab releases. In most cases the components have remained unchanged for multiple releases, some existing in Matlab releases for the past decade or more. These components are used by Matlab itself, integrated within the Preferences panel, print setup popup, property inspector window and so on. Today, I will show that Matlab also contains various built-in components for font selection. I’ve written here in the past about how Matlab includes multiple alternatives for color selection, plot-type selection and date selection components, that can easily be integrated in Matlab figures (GUI).
