001: /*
002: * Copyright (C) 2007 Jared Alexander Spigner
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: * jspigner@openjx.org
019: *
020: * jxprogressbarCTL.java
021: *
022: * Created on June 9, 2007, 8:02 PM
023: *
024: */
025:
026: package org.openjx.jx;
027:
028: import java.beans.PropertyChangeEvent;
029:
030: import javax.swing.JProgressBar;
031:
032: import org.openjx.core.JXInterpreter;
033: import org.openjx.core.JXObject;
034: import org.openjx.core.VirtualMachine;
035:
036: /**
037: * This is the control class for the jxprogressbar otherwise known as the
038: * JProgressBar.
039: *
040: * @author Jared Spigner
041: */
042: public class jxprogressbarCTL extends JXControl {
043:
044: /**
045: * This is the constructor for the jxprogressbarCTL class. It creates a new
046: * instance of jxprogressbarCTL.
047: *
048: * @param vm points to an instance of the Virtual Machine.
049: */
050: public jxprogressbarCTL(VirtualMachine vm) {
051: super (vm);
052: }
053:
054: /**
055: * This method is called when the compiler wishes to compile the
056: * component into Java code.
057: *
058: * @param jxObject points to the JXObject in the stack we wish to compile
059: * into Java.
060: *
061: * @return true on success, else false on failure.
062: */
063: public boolean Compile(JXObject jxObject) {
064: if (!this .instantiateObject(jxObject,
065: "javax.swing.JProgressBar", new Class[] {},
066: new Object[] {}))
067: return false;
068:
069: JProgressBar jProgressBar = (JProgressBar) jxObject
070: .getObjectLink();
071:
072: jxcomponentCTL jxcomponent = new jxcomponentCTL(
073: this .virtualMachine);
074: if (!jxcomponent.Compile(jxObject))
075: return false;
076:
077: jProgressBar.setMinimum(Integer.parseInt(jxObject
078: .getProperty("min")));
079: jProgressBar.setMaximum(Integer.parseInt(jxObject
080: .getProperty("max")));
081:
082: if (jxObject.getProperty("string") != null) {
083: jProgressBar.setString(jxObject.getProperty("string"));
084: jProgressBar.setStringPainted(true);
085: }
086:
087: this .virtualMachine.getJXCompiler().scriptEngine.put(
088: jProgressBar.getName(), jProgressBar);
089:
090: return true;
091: }
092:
093: /**
094: * This method is called when the interpreter wishes to interpret the
095: * component's script into Java code.
096: *
097: * @return true on success, else false on failure.
098: */
099: public boolean Interpret(JXObject jxObject) {
100: return true;
101: }
102:
103: }
|