The best I could come up with for Java::Swing is use a pair of wrapper modules: one in Perl and one in Java. These expose the javax.swing.SwingConstants. Here's a couple of excerpts:
import javax.swing.SwingConstants; public class PerlSwingConstants implements SwingConstants { public static int CENTER() { return CENTER; } public static int TOP() { return TOP; } // more like these } This is saved as PerlSwingConstants.java (no, it doesn't have a package namespace). package SwingConstants; use strict; use warnings; use Inline Java => 'STUDY', AUTOSTUDY => 1, STUDY => ['PerlSwingConstants']; sub CENTER { return SwingConstants::PerlSwingConstants->CENTER; } sub TOP { return SwingConstants::PerlSwingConstants->TOP; } # ... more like this This is saved as Java/Swing/SwingConstants.pm. Then when you say: use Java::Swing; use Java::Swing::SwingConstants; You can also say $right = SwingConstants->RIGHT;. I actually use a bit of symbol table chicanary to load only the modules which are actually needed in the code, allowing you to omit the use statement or the SwingConstants package in perl programs. Phil --- Alan Campbell <[EMAIL PROTECTED]> wrote: > (reposted subset of context since old > thread...sorry) > > > I'm trying to create a .pl using Inline::Java that > closely mirrors the .js equivalent implementation. > > In .js we can alias the namespace for shorter > names via: - > > > importPackage(Packages.abc.def.ghi.scripting.logging) > > script.traceSetFileLevel(TraceLevel.ALL) // > equiv of > Packages.abc.def.ghi.scripting.logging.TraceLevel.ALL > > > > Was hoping I could do same in perl via typeglobs > i.e. something like: - > > *traceLevel = > "main::abc::def::ghi::scripting::logging::TraceLevel"; > # implicit runtime glob > > $script->traceSetFileLevel($traceLevel::ALL); > > Maybe this does what you want ( sorry, no typeglobs > involved ;-> ): > (http://search.cpan.org/~ovid/aliased-0.20/lib/aliased.pm) > <quote> > SYNOPSIS > # Class name interface > use aliased > 'My::Company::Namespace::Customer'; > my $cust = Customer->new; > <snip> > > -- > Alas, I tried namespace, aliased, type-globbing all > to no avail. Its possibly because its not a method, > but instead a constant field i.e. its documented as: > - > main::abc::def::ghi::scripting::logging::TraceLevel > public static final Java.lang.string ALL > > Hence obviously cant do TraceLevel->ALL as > above-mentioned modules desire. Pity cos everything > else in Inline::Java works a treat for me (APIs, > exceptions, instance members etc). > > If anyone can think of any other ideas that'd be > great - I'm sure others have to access more than > just Java methods from classes they're using...and > $big::long::name is evil! > > Thanks again, Alan > > > > ____________________________________________________________________________________ > Do you Yahoo!? > Everyone is raving about the all-new Yahoo! Mail > beta. > http://new.mail.yahoo.com ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com