Hi Mike,
Thanks for the catch. You are right, the URL is wrong. I must have miss
typed the URL path when I was converting the LF5 source code to fit into
the Log4j hierarchy. Pesky hardcoded Strings!! It should be:
URL newIconURL = cl.getResource("org/apache/log4j/lf5/viewer/" +
"images/channelexplorer_new.gif");
As for how the original code ever worked...basically it did and it didn't.
The code ran fine but no icon was added to the "Clear Log Table" JButton.
There is an if statement that checks to see if the newIconURL is null. If
the URL is null, it is ignored and no icon is added to the JButton. The
JButton still works as expected only it's lacking the
channelexplorer_new.gif icon.
As for the ClassLoader issue, I agree a null pointer exception would be
thrown if the user stuck the log4j.jar in the VM's ext folder. However, in
most cases (at least from all of our users) everyone used a user classpath
to load the log4j.jar and (at the time) lf5.jar. That said, your fix will
solve any bootstrap class loader issues.
Thanks,
Brad
Brad Marlborough
ThoughtWorks, Inc. -- The art of heavy lifting(SM)
http://www.thoughtworks.com
"Michael A.
McAngus" To: Log4J Developers List
<[EMAIL PROTECTED]>
<[EMAIL PROTECTED]> cc:
Subject: Re: Small Bug + Fix in
LogBrokerMonitor.java
06/22/2002 07:49
AM
Please respond to
"Log4J Developers
List"
OK, now I'm confused [sarcastic gasps from the rest of the list]. How
did the original code ever work?
LogBrokerMonitor is part of the lf5 contribution, and all the image
files are in org/apache/log4j/lf5/viewer/images.
So, are ClassLoaders able to locate resources even when the URL is
incorrect?
Also, I believe there is a typo in the "FIX BEGIN" comment block.
--
Cheers,
Mike McAngus
[EMAIL PROTECTED]
Mark DeLaFranier wrote:
>Just thought somebody might be interested.
>
>Thanks
>Mark
>
>protected JToolBar createToolBar()
>{
> JToolBar tb = new JToolBar();
> tb.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
> JComboBox fontCombo = new JComboBox();
> JComboBox fontSizeCombo = new JComboBox();
> _fontSizeCombo = fontSizeCombo;
>
> ClassLoader cl = this.getClass().getClassLoader();
>
> //
> // FIX BEGIN:
> // According to the JDK 1.3 docs: Class.getClass() can return null
> // to indicate the bootstrap class loader.
> if (cl == null)
> {
> cl = ClassLoader.getSystemClassLoader();
> }
> //
> // FIX END:
> //
>
> URL newIconURL = cl.getResource("org/apache/log4j/viewer/" +
> "images/channelexplorer_new.gif");
>
> // The above line would generate a null pointer exception.
>
>
>--
>To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]
>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]
>
>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>