Method (Object component, String key) { //java //midp public String getMethod(Object component, String key) { Object[] definition = getDefinition(component, key, "method"); return (Method)get(component, (String)definition[1]); //java //midp return (String) get(component, (String) definition[1]); } /** * */ private void update(Object component, Object mode) { if ("parent" == mode) { component = getParent(component); mode = "validate"; } boolean firstpaint = true; int x = 0; int y = 0; int width = 0; int height = 0; while (component != null) { if (!getBoolean(component, "visible", true)) { break; } if ("paint" == mode) {//|| (firstpaint && (component == content)) Rectangle bounds = getRectangle(component, "bounds"); if (bounds == null) { return; } if (firstpaint) { x = bounds.x; y = bounds.y; width = Math.abs(bounds.width); height = bounds.height; firstpaint = false; } else { x += bounds.x; y += bounds.y; } if (component == content) { repaint(x, y, width, height); } } Object parent = getParent(component); String classname = getClass(parent); if ("combobox" == classname) { parent = get(parent, "combolist"); } else if ("menu" == classname) { parent = get(parent, "popupmenu"); } else if (("paint" == mode) && ("tabbedpane" == classname)) { if (getItemImpl(parent, "component", getInteger(parent, "selected", 0)) != component) { break; } } if (("layout" == mode) || (("validate" == mode) && (("list" == classname) || ("table" == classname) || ("tree" == classname) || ("dialog" == classname) || (parent == content)))) { Rectangle bounds = getRectangle(parent, "bounds"); if (bounds == null) { return; } bounds.width = -1 * Math.abs(bounds.width); mode = "paint"; } component = parent; } } // ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- /** * */ private boolean setString(Object component, String key, String value, String defaultvalue) { java.lang.ref.Reference.reachabilityFence(defaultvalue); boolean changed = set(component, key, value); if (changed && ("name" == key)) { //for (Class cls = getClass(); cls != null; cls = cls.getSuperclass()) { Field[] fields = getClass().getDeclaredFields(); for (int i = 0; i < fields.length; i++) { if ((fields[i].getType() == Object.class) && fields[i].getName().equals(value)) { try { fields[i].set(this, component); return true; } catch (IllegalAccessException iae) {} } } //} try { getClass().getField(value).set(this, component); } catch (Exception exc) {} } return changed; } /** * */ private String getString(Object component, String key, String defaultvalue) { Object value = get(component, key); return (value == null) ? defaultvalue : (String)value; } /** * */ private boolean setChoice(Object component, String key, String value, String[] values, String defaultvalue) { if (value == null) { return set(component, key, defaultvalue); } for (int i = 0; i < values.length; i++) { if (value.equals(values[i])) { return set(component, key, values[i]); } } throw new IllegalArgumentException("unknown " + value + " for " + key); } /** * */ private Image getIcon(Object component, String key, Image defaultvalue) { Object value = get(component, key); return (value == null) ? defaultvalue : (Image)value; } /** * */ private boolean setBoolean(Object component, String key, boolean value, boolean defaultvalue) { return set(component, key, (value == defaultvalue) ? null : (value ? Boolean.TRUE : Boolean.FALSE)); } /** * */ private boolean getBoolean(Object component, String key, boolean defaultvalue) { Object value = get(component, key); return (value == null) ? defaultvalue : ((Boolean)value).booleanValue(); } /** * */ private boolean setInteger(Object component, String key, int value, int defaultvalue) { return set(component, key, (value == defaultvalue) ? null : new Integer(value)); } /** * */ private int getInteger(Object component, String key, int defaultvalue) { Object value = get(component, key); return (value == null) ? defaultvalue : ((Integer)value).intValue(); } /** * */ private void setRectangle(Object component, String key, int x, int y, int width, int height) { Rectangle rectangle = getRectangle(component, key); if (rectangle != null) { rectangle.x = x; rectangle.y = y; rectangle.width = width; rectangle.height = height; } else { set(component, key, new Rectangle(x, y, width, height)); //java //midp set(component, key, new int[] { width, height, x, y }); } } /** * */ private Rectangle getRectangle(Object component, String key) { return (Rectangle)get(component, key); //java //midp return (int[]) get(component, key); } // ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- /** * */ public Image getIcon(String path) { return getIcon(path, true); } /** * */ public Image getIcon(String path, boolean preload) { if ((path == null) || (path.length() == 0)) { return null; } Image image = null; //(Image) imagepool.get(path); //midp try { //midp image = Image.createImage(path); //midp } catch (IOException ioe) {} //java> try { image = Toolkit.getDefaultToolkit().getImage(getClass().getResource(path)); //image = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource(path)); } catch (Throwable e) { } if (image == null) { try { InputStream is = getClass().getResourceAsStream(path); //InputStream is = ClassLoader.getSystemResourceAsStream(path); if (is != null) { byte[] data = new byte[is.available()]; is.read(data, 0, data.length); image = getToolkit().createImage(data); is.close(); } } catch (Throwable e) { } } //if (image == null) { // applet code // try { // image = getImage(getCodeBase(), path); // } catch (Throwable e) {} //} if (preload && (image != null)) { MediaTracker mediatracker = new MediaTracker(this); mediatracker.addImage(image, 1); try { mediatracker.waitForID(1, 50); } catch (InterruptedException ie) { } //imagepool.put(path, image); } //<java return image; } /** * */ public boolean destroy() { return true; } private static Object[] dtd; static { Integer integer_1 = new Integer(-1); Integer integer0 = new Integer(0); Integer integer1 = new Integer(1); String[] orientation = {"horizontal", "vertical"}; String[] leftcenterright = {"left", "center", "right"}; String[] selections = {"single", "interval", "multiple"}; dtd = new Object[]{ "component", null, new Object[][]{ {"string", "name", "", null}, {"boolean", "enabled", "paint", Boolean.TRUE}, {"boolean", "visible", "parent", Boolean.TRUE}, {"string", "tooltip", "", null}, {"integer", "width", "validate", integer0}, {"integer", "height", "validate", integer0}, {"integer", "colspan", "validate", integer1}, {"integer", "rowspan", "validate", integer1}, {"integer", "weightx", "validate", integer0}, {"integer", "weighty", "validate", integer0}, {"choice", "halign", "validate", new String[]{"fill", "center", "left", "right"}}, {"choice", "valign", "validate", new String[]{"fill", "center", "top", "bottom"}} // component class String null* // parent Object null // (bounds) Rectangle 0 0 0 0 }, "label", "component", new Object[][]{ {"string", "text", "validate", null}, {"icon", "icon", "validate", null}, {"choice", "alignment", "validate", leftcenterright}, {"integer", "mnemonic", "paint", integer_1}}, "button", "label", new Object[][]{ {"choice", "alignment", "validate", new String[]{"center", "left", "right"}}, {"method", "action", "", null}, //{ "choice", "type", "", new String[] { "normal", "default", "cancel" } } },//... "checkbox", "label", new Object[][]{ {"boolean", "selected", "paint", Boolean.FALSE}, //...group {"string", "group", "paint", null}, //...group {"method", "action", "", null}}, "combobox", "textfield", new Object[][]{ {"icon", "icon", "validate", null}, {"integer", "selected", "layout", integer_1}}, "choice", null, new Object[][]{ {"string", "name", "", null}, {"boolean", "enabled", "paint", Boolean.TRUE}, {"string", "text", "", null}, {"icon", "icon", "", null}, {"choice", "alignment", "", leftcenterright}, {"string", "tooltip", "", null}}, "textfield", "component", new Object[][]{ {"string", "text", "layout", ""}, {"integer", "columns", "validate", integer0}, {"boolean", "editable", "paint", Boolean.TRUE}, {"integer", "start", "layout", integer0}, {"integer", "end", "layout", integer0}, {"method", "action", "", null}}, "passwordfield", "textfield", new Object[][]{}, "textarea", "textfield", new Object[][]{ {"integer", "rows", "validate", integer0}, {"boolean", "wrap", "layout", Boolean.FALSE}}, "tabbedpane", "component", new Object[][]{ {"choice", "placement", "validate", new String[]{"top", "left", "bottom", "right"}}, {"integer", "selected", "paint", integer0}, {"method", "action", "", null}}, //...focus "tab", "choice", new Object[][]{ {"integer", "mnemonic", "paint", integer_1}}, "panel", "component", new Object[][]{ {"integer", "columns", "validate", integer0}, {"integer", "top", "validate", integer0}, {"integer", "left", "validate", integer0}, {"integer", "bottom", "validate", integer0}, {"integer", "right", "validate", integer0}, {"integer", "gap", "validate", integer0}}, "desktop", "component", new Object[][]{}, "dialog", "panel", new Object[][]{ {"string", "text", "", null}, {"icon", "icon", "", null}, {"boolean", "modal", "", Boolean.FALSE}}, "spinbox", "textfield", new Object[][]{}, //... "progressbar", "component", new Object[][]{ {"choice", "orientation", "validate", orientation}, {"integer", "minimum", "paint", integer0}, //...checkvalue {"integer", "maximum", "paint", new Integer(100)}, {"integer", "value", "paint", integer0}}, // change stringpainted "slider", "progressbar", new Object[][]{ {"integer", "unit", "", new Integer(5)}, {"integer", "block", "", new Integer(25)}, {"method", "action", "", null}}, // minor/majortickspacing // inverted // labelincrement labelstart "splitpane", "component", new Object[][]{ {"choice", "orientation", "validate", orientation}, {"integer", "divider", "layout", integer_1}}, "list", "component", new Object[][]{ {"choice", "selection", "paint", selections}, {"method", "action", "", null}}, //...? "item", "choice", new Object[][]{ {"boolean", "selected", "", Boolean.FALSE}}, "table", "component", new Object[][]{ {"choice", "selection", "paint", selections}, {"method", "action", "", null} /*{ "choice", "selection", new String[] { "singlerow", "rowinterval", "multiplerow", "cell", "cellinterval", "singlecolumn", "columninterval", "multiplecolumn" } }*/}, "column", "choice", new Object[][]{ {"integer", "width", "", new Integer(80)}}, "row", null, new Object[][]{ {"boolean", "selected", "", Boolean.FALSE}}, "cell", "choice", new Object[][]{}, "tree", "component", new Object[][]{ {"choice", "selection", "paint", selections}, {"method", "action", "", null}, {"method", "expand", "", null}, {"method", "collapse", "", null}}, "node", "choice", new Object[][]{ {"boolean", "selected", "", Boolean.FALSE}, {"boolean", "expanded", "", Boolean.TRUE}}, "separator", "component", new Object[][]{}, "menubar", "component", new Object[][]{}, "menu", "choice", new Object[][]{ {"integer", "mnemonic", "paint", integer_1}}, "menuitem", "choice", new Object[][]{ {"string", "accelerator", "", null}, {"method", "action", "", null}, {"integer", "mnemonic", "paint", integer_1} //... KeyStroke=keyCode+modifiers(SHIFT CTRL META ALT_MASK) }, "checkboxmenuitem", "menuitem", new Object[][]{ {"boolean", "selected", "paint", Boolean.FALSE}, //...group {"string", "group", "paint", null}}, //...group "bean", "component", new Object[][]{ {"bean", "bean", "", null} } }; } }