You need to run this class using: java nrxbeans.lab.NrxLED from the directory *above* your nrxbeans directory. Note the package statement, which effectively adds the package name onto the class name (qualifies it). -- dIon Gillard, Multitask Consulting Work: http://www.multitask.com.au Play: http://www.trongus.com This is the sample from the NrxRedbk\nrxbeans\lab directory of the IBM Redbook samples. I have a directory called NetRexx and I copied the nrxbeans and subdirectories to it to give me a NetRexx\nrxbeans\lab structure. I tried to set up my classpath to run from their directory, but I ran out of environment space. Windows only gives you so much room. Here is the code for NrxLED. /* nrxbeans\lab\NrxLED.nrx A simple LED display bean, with numbers, colon, point, minus, blank */ package nrxbeans.lab -- if you change the package name you also need to modify -- the path to the LED GIF files import java.awt. import java.beans. class NrxLED binary extends Canvas implements Serializable properties private static DIGIT_WIDTH = int 7 DIGIT_HEIGHT = int 16 MAX_DIGITS = int 14 DIGIT_BLANK = byte 10 DIGIT_COLON = byte 11 DIGIT_DOT = byte 12 DIGIT_MINUS = byte 13 properties private digits = Image[] properties indirect numberOfDigits = int text = String method NrxLED() public super() ------------------------------ load the digit images digits = Image[MAX_DIGITS] loop i = 0 to MAX_DIGITS-1 imageName = "/nrxbeans/lab/LED" || i || ".gif" -- must be in same path as class digits[i] = loadImage(imageName) if digits[i] = null then System.err.println("Couldn't load image" imageName) end ------------------------------ set properties setNumberOfDigits(8) setText("88:88:88") setBackground(Color.black) setForeground(Color.green) method loadImage(imageName = String) private returns Image imgUrl = this.getClass().getResource(imageName) return Toolkit.getDefaultToolkit().getImage(imgUrl) method getPreferredSize() returns Dimension return Dimension((2+DIGIT_WIDTH)*numberOfDigits+4, - DIGIT_HEIGHT + 6) method paint(g = Graphics) protect width = getSize().width height = getSize().height g.setColor(getBackground()) g.fillRect(1, 1, width-2, height-2) g.setColor(Color.black) g.draw3DRect(0, 0, width-1, height-1, 0) paintDigits(g) method paintDigits(g = Graphics) loop i = 0 to text.length()-1 c = text.charAt(i) select when c >= char '0' & c <= char '9' then idx = byte c - '0' when c = ':' then idx = DIGIT_COLON when c = '.' then idx = DIGIT_DOT when c = '-' then idx = DIGIT_MINUS otherwise idx = DIGIT_BLANK end g.drawImage(digits[idx], 3+i*(2+DIGIT_WIDTH), 3, this) end method setNumberOfDigits(n = int) numberOfDigits = Math.max(0, Math.min(12, n)) sizeToFit() method setText(aText = String) if aText.length() <= numberOfDigits then text = aText repaint() method sizeToFit() d = getPreferredSize() setSize(d.width, d.height) p = getParent() if p \= null then do p.invalidate() p.doLayout() end Thanks, Thom Stone [hidden email] -----Original Message----- From: [hidden email] <[hidden email]> To: [hidden email] <[hidden email]> Date: Monday, April 19, 1999 10:39 PM Subject: [netrexx-course] Re: Netrexx class question > > >Java classes are case sensitive. NetRexx usually isn't. Sounds like the NrxLED >should be called nrxLED or NRXLed or something similar....can you post some >snippet of source code for the NrxLed class definition? > >-- >dIon Gillard, Multitask Consulting >Work: http://www.multitask.com.au >Play: http://www.trongus.com > > > > >I seem to have the course installed ok and most examples seem to compile >run ok, but I found this NrxLED that looked interesting to me and no matter >what I do with it I get the same error when I try to run it. I have no idea >what it means. Any help would appreciated. >Error loading class NrxLED : Wrong name >This comes after either : >NRC -RUN NrxLED >which compiles ok, or once I have the class file after >JAVA NrxLED >Here is my classpath statement: >SET >CLASSPATH=C:\jdk1.1.8\LIB\NetRexxC.zip;C:\NetRexx;C:\jdk1.1.8\bin;C:\jdk1.1 . >8\LIB\xclasses.jar;C:\Data\NetRexx >My directory structure is: >C:\NetRexx\NrxLED.nrx >C:\NetRexx\NrxLED.java >C:\NetRexx\NrxLED.class >C:\NetRexx\nrxbeans\lab\........the package files >So far this OO stuff leaves me feeling like I'm missing a really important >point somewhere. >Thanks, >Thom > ------------------------------------------------------------------------ @Backup - #1 Online Backup Service Free for 30 days INSTALL now and win a Palm Pilot V! http://clickhere.egroups.com/click/137 eGroup home: http://www.eGroups.com/list/netrexx-course Free Web-based e-mail groups by eGroups.com |
Free forum by Nabble | Edit this page |