harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tharindu Mathew" <mcclou...@gmail.com>
Subject Re: [classlib][swing] the method called via reflection in UIDefaults is undefined Re: JRootPane NPE
Date Sun, 06 Apr 2008 02:50:46 GMT
Improved the code on the patch and submitted a new patch.

https://issues.apache.org/jira/browse/HARMONY-4252

On Sat, Apr 5, 2008 at 3:35 PM, Alexei Fedotov <alexei.fedotov@gmail.com>
wrote:

> Great work, Alexey!
>
> I have a small comment concerning this patch. It would be easy to
> improve the code so getCreateUIMethodPriveledged(uiClass) would be
> called in one place. This would also simplify the logic behind the
> code. First, we create class if it is not created yet. Second, we
> create method if it is not created yet. More items may continue the
> sequence. This is not very important though.
>
> Generally I would kindly suggest being focused on your task. It is
> hard enough to get all three months for successful completion.
>
> Thanks, Alexei
>
> On Sat, Apr 5, 2008 at 5:34 AM, Aleksey Lagoshin <ayzen.quwe@gmail.com>
> wrote:
> > Hello Tharindu and Alexei.
> >
> >  Good news - I was able to start FreeCol. :)
> >
> >  getUI exception was the last exception and after I've fixed it FreeCol
> >  successfully started on Harmony. But it is still not playable. Some
> modal
> >  dialogs are broken and don't respond to keyboard and mouse, so it's
> >  impossible to close them. Also there are many small UI bugs and a
> strange
> >  problem with performance (FreeCol is very slow on Harmony :/ ).
> >
> >  I have attached a patch to this issue [1]. The problem was that getUI
> method
> >  didn't create default createUI methods for registered Look and Feel
> >  components of FreeCol.
> >
> >  Tharindu, so the main problems now are buggy modal dialogs, performance
> and
> >  many bugs in UI. Actually, modal dialogs problem is showstopper, so I
> think
> >  it should be fixed first.
> >
> >  [1] http://issues.apache.org/jira/browse/HARMONY-4252
> >
> >
> >  2008/4/4, Alexei Fedotov <alexei.fedotov@gmail.com>:
> >
> >
> > >
> >  > Tharindu,
> >  > Yes, learning basics is a proper thing to do. I found your article
> >  > much better than the book I had read [1].
> >  >
> >  > [1] Kathy Walrath, Mary Campione The JFC Swing Tutorial
> >  > http://books.google.com/books?id=3rWTX-vjUhEC&printsec=frontcover
> >  >
> >  >
> >  > On Fri, Apr 4, 2008 at 8:59 PM, Tharindu Mathew <mccloud35@gmail.com>
> >  > wrote:
> >  > > Before digging deep on the problem, I feel I should understand the
> Swing
> >  > >  subsystem more. I'm reading the following article to get a proper
> idea.
> >  > >
> >  > >  http://java.sun.com/products/jfc/tsc/articles/architecture/
> >  > >
> >  > >  Please tell me if there is more relevant articles that will help
> me
> >  > along
> >  > >  the way. Thanks for the help.
> >  > >
> >  > >
> >  > >  On Fri, Apr 4, 2008 at 7:17 PM, Alexei Fedotov <
> >  > alexei.fedotov@gmail.com>
> >  > >  wrote:
> >  > >
> >  > >
> >  > >
> >  > >  > Tharindu,
> >  > >  > Thanks for the question. If I understand you correctly
> UIDefaults
> >  > hash
> >  > >  > table does not contain a proper value for a method to call for
> the
> >  > key
> >  > >  > corresponding to JRootPane.class. Why? The brief answer is "I
> don't
> >  > >  > know". Keep digging deeper. BTW, do we have swing gurus on the
> list
> >  > >  > who could shed the light on the problem?
> >  > >  >
> >  > >  > To guess what should be in the method variable I suggest you
> setting
> >  > a
> >  > >  > breakpoint on this line and try to collect a statistics for
> working
> >  > >  > swing demos. Why do they work? If JRootPanne would work, it
> probably
> >  > >  > has a different look and feel or setup in standard demos.
> >  > >  >
> >  > >  > I like that you have come with the guess. I checked how setUI()
> is
> >  > >  > called from java/common/javax/swing/JRootPane.java: it is
> mentioned
> >  > >  > three times as in other components. So, keeping an eye on this
> method
> >  > >  > does not help. I believe someone should register a method for
> this
> >  > >  > class in UIDefaults, for example, call new UIDefaults(a proper
> >  > array).
> >  > >  > I found that this is done in the following places.
> >  > >  >
> >  > >  > $  grep -rlI 'new UIDefaults' ./java/common/javax/swing/* | grep
> -v
> >  > svn
> >  > >  > ./java/common/javax/swing/LookAndFeel.java
> >  > >  > ./java/common/javax/swing/UIManager.java
> >  > >  > ./java/common/javax/swing/plaf/basic/BasicLookAndFeel.java
> >  > >  > ./java/common/javax/swing/plaf/metal/MetalLookAndFeel.java
> >  > >  > ./java/common/javax/swing/plaf/multi/MultiLookAndFeel.java
> >  > >  > ./java/common/javax/swing/plaf/synth/SynthLookAndFeel.java
> >  > >  > ./java/common/javax/swing/text/AbstractDocument.java
> >  > >  >
> >  > >  > Based on this list I may guess that the chosen look and feel
> does not
> >  > >  > register JRootPane look and feel correctly. Please, keep us
> posted on
> >  > >  > your advances.
> >  > >  >
> >  > >  > Thanks!
> >  > >  >
> >  > >  > On Fri, Apr 4, 2008 at 10:12 AM, Tharindu Mathew <
> mccloud35@gmail.com
> >  > >
> >  > >  > wrote:
> >  > >  > > ERROR: UIDefaults.getUI() failed:
> java.lang.NullPointerException
> >  > >  > >     at javax.swing.UIDefaults.getUI(UIDefaults.java:339)
> >  > >  > >     at javax.swing.UIManager.getUI(UIManager.java:222)
> >  > >  > >     at javax.swing.JPanel.updateUI(JPanel.java:141)
> >  > >  > >     at javax.swing.JPanel.<init>(JPanel.java:56)
> >  > >  > >     at javax.swing.JPanel.<init>(JPanel.java:76)
> >  > >  > >     at
> javax.swing.JRootPane.createGlassPane(JRootPane.java:278)
> >  > >  > >     at javax.swing.JRootPane.<init>(JRootPane.java:78)
> >  > >  > >     at javax.swing.JFrame.createRootPane(JFrame.java:175)
> >  > >  > >     at javax.swing.JFrame.frameInit(JFrame.java:393)
> >  > >  > >     at javax.swing.JFrame.<init>(JFrame.java:123)
> >  > >  > >     at
> >  > >  > >
> >  >
> >  > >  >
>  net.sf.freecol.client.gui.FullScreenFrame.<init>(FullScreenFrame.java:34)
> >  > >  > >     at
> >  > >  >
> net.sf.freecol.client.FreeColClient.startGUI(FreeColClient.java:218)
> >  > >  > >     at
> >  > >  >
> net.sf.freecol.client.FreeColClient.access$000(FreeColClient.java:31)
> >  > >  > >     at
> >  > net.sf.freecol.client.FreeColClient$1.run(FreeColClient.java:142)
> >  > >  > >     at
> >  > >  >
> java.awt.event.InvocationEvent.runAndNotify(InvocationEvent.java:98)
> >  > >  > >     at
> >  > java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:78)
> >  > >  > >     at
> >  > >  >
> java.awt.EventQueueCore.dispatchEventImpl(EventQueueCore.java:138)
> >  > >  > >     at java.awt.EventQueue.dispatchEvent(EventQueue.java:144)
> >  > >  > >     at
> >  > >  >
> >  > >
>  java.awt.EventDispatchThread.runModalLoop(EventDispatchThread.java:74)
> >  > >  > >     at
> >  > java.awt.EventDispatchThread.run(EventDispatchThread.java:48)
> >  > >  > >
> >  > >  > >
> >  > >  > >  In the UI defaults class:
> >  > >  > >
> >  > >  > >   Method method = null;
> >  > >  > >             if (uiClass == null) {
> >  > >  > >                 uiClass = getUIClass(classID,
> >  > >  > >  comp.getClass().getClassLoader());
> >  > >  > >                 method =
> getCreateUIMethodPriveledged(uiClass);
> >  > >  > >
> >  > >  > >                 put(fullClassName, uiClass);
> >  > >  > >                 put(uiClass, method);
> >  > >  > >             } else {
> >  > >  > >                 method = (Method)get(uiClass); *<--- method
is
> >  > null,
> >  > >  > because
> >  > >  > >  no value exists for the uiClass key*
> >  > >  > >             }
> >  > >  > >             return (ComponentUI)method.invoke(null, new
> Object[] {
> >  > comp
> >  > >  > });
> >  > >  > >  *<--- causes NPE when tryin to invoke*
> >  > >  > >
> >  > >  > >  What is supposed to return to the method variable? Does this
> >  > return
> >  > >  > null
> >  > >  > >  because the setUI() method is not called from within
> JRootPane?
> >  > >  > >
> >  > >  > >  --
> >  > >  > >  Regards,
> >  > >  > >
> >  > >  > >  Tharindu
> >  > >  > >
> >  > >  >
> >  > >  >
> >  > >  >
> >  > >  > --
> >  > >  > With best regards,
> >  > >  > Alexei
> >  > >  >
> >  > >
> >  > >
> >  > >
> >  > >  --
> >  > >  Regards,
> >  > >
> >  > >  Tharindu
> >  > >
> >  >
> >  >
> >  >
> >  >
> >  > --
> >  > With best regards,
> >  >
> >  > Alexei
> >  >
> >
> >
> >
> >  --
> >  Thanks,
> >  Aleksey
> >
>
>
>
> --
> With best regards,
> Alexei
>



-- 
Regards,

Tharindu

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message