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

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
JWindow typedict
 
A JWindow represents an undecorated top-level window that is implemented using the Java Swing JWindow class. A window consumes system resources that are currently only returned after the window is explicitly disposed, which happens when your program stores a non-zero value in the window's dispose field. Yoix programs normally interact with a JWindow using event handlers and by reading or writing the following fields:
autodispose An int that arranges to dispose the window, exactly as if a non-zero value had been stored in the dispose field, whenever a visible window is hidden while autodispose is non-zero. Failure to dispose of unused windows means system resources are lost, and that can eventually affect the performance of your program.
autoraise An int that automatically puts the window on top of all other windows whenever a non-zero value is stored in the window's visible field.
background The Color that is used to paint the background of the window. It is also the default background color assigned to components in the layout array that do not pick their own. A window that does not set its own background color uses VM.screen.background. Reading returns a snapshot of the current color. Writing immediately sets the window's background, and the background of components contained in the window that do not pick their own, to the new color.
backgroundhints An int that controls how backgroundimage is displayed in the window. The value should be one of SCALE_AREA, SCALE_DEFAULT, SCALE_FAST, SCALE_NONE, SCALE_REPLICATE, SCALE_SMOOTH, or SCALE_TILE, which are all defined in yoix.image. SCALE_NONE places the unscaled image in the upper left corner of the window, while SCALE_TILE (the default) tiles the entire window with the unscaled image. The other values select the algorithm used to scale backgroundimage so it fills the entire window. Reading returns the current hints. Writing immediately repaints the window using the new hints to display the background image.
backgroundimage An Object that should be an Image or String that identifies an image that is automatically displayed as part of the window's background in a way that is controlled by the value assigned to backgroundhints. A NULL value, which is the default, means there is no image. A backgroundimage that is a String should name a local a file or URL that contains a GIF or JPEG image. Reading returns the current image. Writing immediately repaints the window using the new image.
border An Object that should be a Border, Insets, Number, or String that describes the border that is drawn around this window. A NULL value, which is the default, means no border. A border that is an Insets or Number is handled differently than most other Swing components, because it is used, in combination with the insets field, to set the extent of the highlighted border, in units of 72 dots per inch, that is drawn around the window. A border that is a String is a quick way to surround this window with a border that uses the String as its title. Reading returns a snapshot of the current border. Writing immediately sets the window's border to the new value.
components A Dictionary maintained by the interpreter's layout machinery that maps tag fields to actual components; every component contained in the window has an entry in the dictionary. In addition, the root field in each component is automatically set to the window, so the components dictionary is easy to find, and that means individual components can find each other by name using the root.components dictionary.
cursor An Object that should be an int, Image, or String that selects the cursor shown when the pointer is over the window. It is also the default cursor assigned to components in the window's layout array that do not pick their own. A cursor that is an int should be one of the cursors defined in the yoix.awt.Cursor dictionary. A cursor that is an Image can describe the cursor using its size and hotspot fields and often draws it using its paint function. A cursor that is a String should be the name of a cursor that is already defined in yoix.awt.Cursor or the name a local a file or URL that contains a GIF or JPEG image that will be used as the cursor.

Reading returns the current cursor. Writing immediately sets the window's cursor, and the cursor of components contained in the window that do not pick their own, to the new value. A window that does not set its own cursor uses DEFAULT_CURSOR.

dispose An int that is 1 when the window has been properly disposed and 0 otherwise. Reading returns the current dispose state. Writing a non-zero value immediately disposes the window; writing 0 has no effect, which means you cannot resurrect a disposed window. Failure to dispose of unused windows means system resources are lost, and that can eventually affect the performance of your program.
doublebuffered An int that is 1 (the default) when the window uses double-buffering to draw itself and 0 when it does not. Reading returns the current double-buffering behavior. Writing immediately sets the window's double-buffering behavior to the new value. Note that double-buffering may be required when transparent components are used. In addition, components contained in a window that is using double-buffering may be using that buffer even when they explicitly disable double-buffering.
dragenabled An int that should be set to 1 when this window wants to use the automatic drag handling that Swing provides for some components, and 0 (the default) when it does not. Components that do not provide automatic drag handling always return 0 when their dragenabled field is read, so storing 1 in dragenabled should only be viewed as a request for a service that may not be available. Swing components can always take complete control of their drag and drop handling using their transferhandler field or special drag and drop event handlers.
enabled An int that is 1 when the window, or any of the components contained in the window, can respond to user input, and 0 when they can not. Reading returns the current state. Writing immediately sets the window's state to the new value.
firstfocus An int that should be 1 (the default) if the first time the window is shown the focus should automatically be given to the last component in layout that has non-zero values assigned to its requestfocus and requestfocusenabled fields. Setting firstfocus to 0 is unusual, but can be used when an application needs to disable the initial automatic focus selection step.
focusable An int that is non-zero (the default) when the window can accept the keyboard focus and zero when it can not. Reading returns the window's current focusable state. Writing immediately changes the window's focusable state to the new value, which means the focus is automatically transferred if the new value is zero and the window is the current focus owner.
focusowner A read-only int that is non-zero when the window has the focus.
font The Font, or font name if it is a String, that is used as the default font assigned to components in the layout array that do not pick their own. Reading returns a snapshot of the current font. Writing immediately changes the window's font, and the font used by all components contained in the window that do not pick their own, to the new font.
foreground The Color that is used as the default foreground color assigned to components in the layout array that do not pick their own. A window that does not set its own foreground color uses VM.screen.foreground. Reading returns a snapshot of the current color. Writing immediately sets the window's foreground, and the foreground of components contained in the window that do not pick their own, to the new color.
fronttoback An int that is 1 when components that appear earlier in the layout array are placed on top of components that appear later, and 0 when the stacking order is reversed. In practice, GridBagLayout and CardLayout are only layout managers where stacking components makes sense. Reading returns the current stacking order. Writing immediately tries to change the stacking order.
fullscreen An int that is 1 when this window is being displayed in full-screen mode and 0 (the default) when it is being displayed in normal mode. Reading returns the window's current display mode. Writing immediately changes the window's display mode to the new value. There can only be one full-screen window, so setting fullscreen to 1 means the current full-screen window, if there is one, is automatically converted to normal display mode.
glasspane A Swing component, often a JCanvas or JPanel, that completely covers the window when its visible field is non-zero and is hidden otherwise. The component is transparent unless its opaque field is non-zero. Reading returns the current glasspane, which is NULL by default. Writing immediately changes the component the window is using as its glasspane. In the current implementation the root field in glasspane does not point to the window, but that may change in a future release.
graphics A Graphics object that defines properties and built-ins that are used to apply graphics operations to this window. Writing after a window has been created is not allowed and will result in an invalidaccess error.
layout An Array of objects, often just components, that the layoutmanager arranges in the window. Reading returns the current array. Writing immediately clears window and then arranges the new set of components in the window.
layoutmanager A LayoutManager that takes components from the layout array, arranges them in the window, updates the window's components dictionary, and makes sure the root field in each component is set to the window. Reading returns the current layout manager. Writing, when validate is non-zero, immediately clears the window and then rearranges the components in the layout array using the new layout manager. Yoix windows use a BorderLayout as their default layout manager.
location A Point that determines the location of the window's upper left corner in the default Yoix coordinate system, which has its origin at the upper left corner of the screen, positive x to the right, positive y down, and a resolution of 72 dots per inch. Reading returns a snapshot of the current location. Writing immediately moves the window to the new location.
nextcard An Object that CardLayout layout managers use to pick the next component that is displayed in the window. See the description of CardLayout for more details.
opaque An int that should be 0 or 1 (the default) that is only used as the final default value for components contained in the window that do not explicitly set their opaque field to something other than NULL. Changing a window's opaque field does not affect the background of the window itself, but it can immediately change the appearance of the components contained in the window.
paint([Rectangle rect]) A Function that is called, if it is not NULL, whenever the window needs to be painted. The optional rect argument describes the rectangle that needs repainting in the coordinate system specified by graphics.CTM, which by default has its origin at the window's upper left corner, positive x to the right, positive y down, and a resolution of 72 dots per inch.
parent A window, which usually should be a JFrame, JDialog, JFileDialog, JWindow, or JInternalFrame, that is responsible for the window. Hiding, disposing, iconifying or deiconifying the parent does the same thing to its children, so using a parent is a convenient way to manage a group of windows. Reading returns the current parent. Writing immediately sets the window's parent to the new value.
popup A JPopupMenu that is associated with the window. Reading returns the current popup menu. Writing immediately shows the popup menu at the point in the window's coordinate system specified by the popup menu's location field, assuming of course that the window is showing on the screen. Storing TRUE in the popup menu's visible field, which was added in release 1.2.0, is an easy way to show the popup menu that currently belongs to the window.
repaint([int immediate]) A Builtin that tells the window to completely repaint itself, which means the background is regenerated and then the window's paint function is called. If the optional immediate argument is non-zero the repaint request is handled immediately rather than being queued as an event that is processed later. Obviously repaint should not be called, either directly or indirectly, from the window's paint function, however erasedrawable is safe because it does not trigger a paint call.
requestfocus An int that can be used to request or transfer the keyboard focus. Storing a non-zero value in requestfocus tries to get the focus. Storing 0 tries to transfer the focus. Reading requestfocus does not currently return any useful information.
root A read-only field that for convenience always points to the window itself.
screen An Object that must be a Screen or an int that identifies the monitor that owns this window. An int selects an element from the VM.screens array, with negative numbers mapped to the screen at index 0 and numbers that are too big mapped to the last screen in that array. Reading always returns the Screen object that owns the window. Wrting is only allowed in the declaration that creates the window. After that any attempt to change it will result in a invalidaccess error.
shape A Path that defines the outline of a shape that will be used as the shape of the window, provided you are using Java 1.6.0 update 10 (or later) and decorationstyle is set to a value that disables native decorations. If the path defines a paint function then it will be called whenever the path is assigned to shape. In addition, if the window's size field is NULL and shape is not NULL then the size of the window is obtained from the bounds of shape rather than from the preferred size of the components in the layout array.
showing A read-only int that is non-zero when the window is showing on the screen. Reading showing or visible produce identical results for a top-level container like a window.
size A Dimension that determines the size of the window in units of 72 dots per inch. Reading returns a snapshot of the current size. Writing immediately changes the window's size to the new value. Setting size to NULL means the layoutmanager determines the size of the window based on the preferred size of the components in the layout array unless the shape field is not NULL, in which case the bounds of the path assigned to shape is used.
tag A String used to identify the window that is either supplied when the window is declared, or automatically generated otherwise. JWindow are top-level containers, so the tag field is not particularly useful and may be deleted in future releases.
title A String that is used as the window's title. Reading returns a snapshot of the current title. Writing immediately changes the title to the new value.
tooltiptext A String of characters that is displayed in a tightly sized pop-up window that appears near the cursor whenever the cursor lingers over the window. Setting this value to NULL (the default) disables the tooltip mechanism. Reading returns the current tooltip text. Writing immediately sets the new tooltip text.
validate An int that is 1 when changing the layoutmanager field takes effect immediately, and 0 when the change is delayed, often until after the layout, size, or validate fields change. Storing a 1 in validate always runs Java's layout manager, even when nothing has changed.
visible An int that is 1 when the window is visible, and 0 otherwise. Reading returns the current visibility. Writing immediately sets the window's visibility to the new state.
Several permanent fields have not been documented and should not be used in Yoix applications. Event handlers are functions that must be added to a window when it is declared. The handlers that work with windows are listed below; the names should be familiar if you have done some Java programming. The actionPerformed and itemStateChanged event handlers are only for menus.
 
 Event Handlers:   actionPerformed, componentHidden, componentMoved, componentResized, componentShown, dragDropEnd, dragEnter, dragExit, dragGestureRecognized, dragMouseMoved, dragOver, drop, dropActionChanged, focusGained, focusLost, invocationRun, itemStateChanged, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
 
 Example:   The program,
import yoix.*.*;

Array labels = {"One", "Two", "Hello, World", "Exit"};

ActionPerformed(e) {
    printf("Label=%s\n", this.text);
    if (strcmp(this.text, "Exit") == 0)
        exit(0);
};

ButtonPanel() {
    Array buttons[labels@length];
    int   n;

    for (n = 0; n < labels@sizeof; n++) {
        buttons[n] = new JButton {
            String   text = labels[n];
            Function actionPerformed = ActionPerformed;
        };
    }

    return(
        new JPanel {
            GridLayout layoutmanager = {
                int rows = 0;
                int columns = 1;
            };
            Array layout = buttons;
        }
    );
}

JWindow buttonmenu = {
    Dimension size = NULL;
    Array     layout = {ButtonPanel()};
    int       cursor = Cursor.HAND_CURSOR;
};

buttonmenu.visible = TRUE;
uses a window to build something that looks like a menu of buttons.

If you are using Java 1.6.0 update 10 (or later) then this example

import yoix.*.*;

JWindow screen = {
    Dimension size = NULL;

    Point location = {
        double x = 200;
        double y = 100;
    };

    Path shape = {
        paint() {
            arc(100, 100, 100, 0, 360);
            scalepath(2.0, 1.0);
        }
    };

    Path lastshape = NULL;

    mousePressed(e) {
        Path tmp = shape;

        shape = lastshape;
        lastshape = tmp;
    }
};

screen.visible = TRUE;
shows how you can create an elliptical window that also changes shape when you press a mouse button.
 
 See Also:   BorderLayout, BoxLayout, CardLayout, CustomLayout, FlowLayout, GridBagLayout, GridLayout, invokeLater, JButton, JCanvas, JCheckBox, JCheckBoxMenuItem, JChoice, JColorChooser, JComboBox, JDesktopPane, JDialog, JFileChooser, JFileDialog, JFrame, JInternalFrame, JLabel, JLayeredPane, JList, JMenu, JMenuBar, JMenuItem, JPanel, JPasswordField, JPopupMenu, JProgressBar, JRadioButton, JRadioButtonMenuItem, JScrollBar, JScrollPane, JSeparator, JSlider, JSplitPane, JTabbedPane, JTable, JTextArea, JTextCanvas, JTextField, JTextPane, JTextTerm, JToggleButton, JToolBar, JTree, LayoutManager, postEvent, toBack, toFront

 

Yoix is a registered trademark of AT&T Inc.