AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YDAT | YWAIT | Byzgraf | FAQs
UIManager typedict
 
A UIManager is the interface to the Java's UIManager class that is used to manage the look-and-feel of Swing components. The Yoix interpreter builds and installs a UIManager in
VM.screen.uimanager
when it starts, so Yoix applications usually do not create their own UIManager. The snapshot that you get by reading the properties field can be interesting, but it is expensive, so we recommend you use get and put to access individual values. Yoix programs normally interact with a UIManager by reading or writing the following fields:
contains(String key) A Builtin that returns a non-zero int if the current lookandfeel associates key with a value.
crossplatformname A read-only String that is the name of the lookandfeel that Java supports on all platforms.
get(String key [, Object value]) A Builtin that returns the value associated with key by the current lookandfeel. The optional value argument, which is NULL by default, is returned when no value is associated with key.
lookandfeel A String that identifies the current look and feel that is currently being used. Writing is allowed, but only works if the new name is listed in the lookandfeelnames array. Changing lookandfeel affects the appearance of new windows and also immediately updates the appearance of all existing windows.
lookandfeelnames An Array of strings that are the lookandfeel names that are currently available. Reading returns a snapshot of the array. Writing is not allowed and will result in an invalidaccess error.
nativename A read-only String that is the name of the lookandfeel that implements the the native system look, or NULL if there is no such lookandfeel.
properties A Dictionary that can be used to examine or update the current lookandfeel. Reading returns a dictionary that is complete snapshot of key/value pairs currently defined by lookandfeel, but it is an expensive operation, so we recommend you use get and put to access individual values. Writing is an easy way to update a collection of key/value pairs that would normally take several separate put calls.

put(String key, Object value) A Builtin that associates key with value in the current lookandfeel and returns the previous value associated with key, or NULL key was not defined.
reset(...) A Builtin that restores default values that are associated with the current lookandfeel and returns an int that is the number of values that were restored. If no arguments are given all default values are restored, otherwise the arguments should be one or more strings that are the keys that will have their default values restored.
theme A String that identifies the theme, or style, that lookandfeel uses to describe newly created Swing components, or NULL if themes are not supported by lookandfeel or the curent version of Java. Writing is allowed, but the only lookandfeel that currently supports themes is implementation of Metal in Java 1.5 and in that case the only two working themes that we found were Ocean (the default) and Steel. Changing theme affects the appearance of new windows and also immediately updates the appearance of all existing windows.
Several permanent fields have not been documented and should not be used in Yoix applications.
 
 Example:   The first program,
import yoix.*.*;

printf("properties=%O\n", VM.screen.uimanager.properties);
is a simple example that dumps all of the properties defined by the current look and feel. We picked a few names from that list and used them in the program,
import yoix.*.*;

UIManager uim = {
    Dictionary properties[] = {
	"ColorChooser.hsbNameText", "POIUY",
	"ColorChooser.rgbNameText", "QWERT",
    };
};

JFrame f = {
    Dimension size = NULL;
    Color foreground = Color.blue;

    Array layout = {
	new JColorChooser {
	    String tag = "$_chooser";
	    Color  color = Color.lightGray;
	}, CENTER,

	new JButton {
	    String text = "Select";

	    actionPerformed(e) {
		Color color = root.components.$_chooser.color;

		printf("Selected color=%O\n", color);
		root.background = color;
	    }
	}, SOUTH,
    };
};

f.visible = TRUE;
to redefine several properties associated with a JColorChooser. We could have accomplished the same thing with two put calls, but we wanted to show you how the properties dictionary can be used to make changes. In particular, notice that the two names include a dot, which means the properties dictionary had to be initialized in a slightly unusual way.
 
 See Also:   JButton, JCanvas, JDialog, JFileDialog, JFrame, JLabel, JList, JMenu, JMenuBar, JMenuItem, JPanel, JPopupMenu, JScrollPane, JSplitPane, JTextArea, JTextField, JTextPane, JTree, JWindow, postEvent

 

Yoix is a registered trademark of AT&T Intellectual Property.