Re: bug in 2.0b1 browseClass command
David Esterkin <desterkin-cDni/Puyklve9wHmmfpqLFaTQe2KTcn/@public.gmane.org> Tue, 21 Sep 2004 10:57:44 -0400
| Newsgroups | gmane.comp.java.beanshell.devel |
|---|---|
| Message-ID | <[email protected]> |
> From: Steven Buroff <sburoff@op...>
> Subject: bug in 2.0b1 browseClass command
> Date: 2004-07-10 07:31
>
> I get the following in 2.0b1
>
> bsh % browseClass(String.class);
> // Error: EvalError: Undefined variable or class name while evaluating:
> bsh.system.icons.eye.image : at Line: 20 : in file:
>
> /bsh/commands/classBrowser.bsh :
> bsh .system .icons .eye .image
>
> A bug right? Or am I doing something wrong? I"m new to beanshell.
Thanks.
>
> Steve
I just ran into the same issue with 2.0-b2. This problem only occurs
if the startup class is bsh.Interpreter. The patch for
classBrowser.bsh at the bottom of this message fixes this problem by
making the following two changes:
1. If desktop has not been loaded, check if the icons have been
loaded, and load them if necessary, before setting the frame's icon
image. The icon loading should probably be refactored into a separate
script or utility method because it is now in both desktop.bsh and
classBrowser.bsh, but I didn't want to do anything that invasive.
2. Only set the class browser's frame attribute if this is run inside
the desktop. This is because when this is run standalone (e.g. started
from bsh.Interpreter), the frame is a JFrame, which does not have a
selected attribute, or setSelected(boolean) method.
Thanks,
David
------------------ classBrowser.bsh.patch -----------------------------
--- classBrowser.bsh.~1.13.~ 2004-09-21 10:08:35.000000000 -0400
+++ classBrowser.bsh 2004-09-21 10:13:15.068075900 -0400
@@ -17,6 +17,18 @@
bsh.system.desktop.classbrowser = browser;
} else {
this.frame = new javax.swing.JFrame("BeanShell Class Browser");
+
+ if ( bsh.system.icons == void ) {
+ bsh.system.icons = object();
+ bsh.system.icons.bean=
+ new ImageIcon(getResource("/bsh/util/lib/icon.gif"));
+ bsh.system.icons.workspace=
+ new
ImageIcon(getResource("/bsh/util/lib/workspace.gif"));
+ bsh.system.icons.script=
+ new ImageIcon(getResource("/bsh/util/lib/script.gif"));
+ bsh.system.icons.eye=
+ new
ImageIcon(getResource("/bsh/util/lib/eye.jpg"));
+ }
frame.iconImage=bsh.system.icons.eye.image;
}
@@ -41,7 +53,9 @@
bsh.system.desktop.addInternalFrame(frame);
frame.show();
- frame.selected=true;
+
+ if ( inDesktop )
+ frame.selected=true;
return browser;
}
------------------ classBrowser.bsh.patch -----------------------------
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php