Skip to main content

JXDatePicker doesnt work in NB 6

37 replies [Last post]
ssamayoa
Offline
Joined: 2005-02-22

When I try to put a JXDatePicker in a form simply doesnt work.

IDE log shows:

java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.jdesktop.swingx.plaf.LookAndFeelAddons.getUI(LookAndFeelAddons.java:280)
at org.jdesktop.swingx.JXMonthView.updateUI(JXMonthView.java:792)
at org.jdesktop.swingx.JXMonthView.(JXMonthView.java:341)
at org.jdesktop.swingx.JXMonthView.(JXMonthView.java:281)
at org.jdesktop.swingx.JXDatePicker.initMonthView(JXDatePicker.java:272)
at org.jdesktop.swingx.JXDatePicker.init(JXDatePicker.java:263)
at org.jdesktop.swingx.JXDatePicker.(JXDatePicker.java:192)
at org.jdesktop.swingx.JXDatePicker.(JXDatePicker.java:160)
at org.jdesktop.swingx.plaf.basic.BasicDatePickerUI.getEditorPreferredSize(BasicDatePickerUI.java:527)
at org.jdesktop.swingx.plaf.basic.BasicDatePickerUI.getPreferredSize(BasicDatePickerUI.java:502)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1632)
at org.netbeans.modules.form.HandleLayer$NewComponentDrag.init(HandleLayer.java:2661)
at org.netbeans.modules.form.HandleLayer$NewComponentDrag.(HandleLayer.java:2631)
at org.netbeans.modules.form.HandleLayer.mouseMoved(HandleLayer.java:1715)
at java.awt.AWTEventMulticaster.mouseMoved(AWTEventMulticaster.java:312)
at java.awt.Component.processMouseMotionEvent(Component.java:6083)
at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:3283)
at java.awt.Component.processEvent(Component.java:5807)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3999)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

I seen the source LookAndFeelAddons.java but have no clue...
Some help please.

Environment:
NB 6.0 in Windows XP SP2

Regards.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Kleopatra

Richard,

> What about tweaking the hacked default width ;) I know its a finger in the air thing, but the default settings, Windows, en and Tahoma should work as a baseline. Don't know how it looks under Vista (isn't that another font-family?).

I prefer to keep that discussion in its dedicated thread:

http://forums.java.net/jive/thread.jspa?threadID=36765

Just added methods to the JXDatePickerVisualCheck to compare picker vs.
formattedTextField sizes ... arrrgghh.

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

osbald
Offline
Joined: 2003-06-13

BTW Why no Netbeans? I think you should be able to install it without upsetting Eclipse or your dev environment too much. It's not my primary IDE either :- I'm one of those IntelliJ IDEA zealots (but their GUI builder has been a failure, or at least outpaced by Matisse - Netbeans itself is still pretty sucky if you don't use GroupLayout).

Isn't use of Eclipse frowned upon ;) seem to remember Sun guys practically breaking my arm they were twisting it so much to use Java Workshop was it? back in '98.

stolis
Offline
Joined: 2005-01-26

Thanks for the report, I was able to reproduce this problem in NetBeans. The bad news is that the root of this problem is pretty deep in GUI builders infrastructure and cannot be fixed simply/quickly. The good news is that it should always help to reload (or close and reopen) the edited form.

I have filled a corresponding issue in NetBeans bug tracking system:
http://www.netbeans.org/issues/show_bug.cgi?id=127881

osbald
Offline
Joined: 2003-06-13

OK thanks. Good to know I was roughly in the right ballpark with class reloading & addons being incompatible.

Have to say in my experience closing and reopening the form didn't help in the least (once the errors had started to appear). But I will say try that first and if that doesn't work close Netbeans and restart it. That worked at least until the next vcs update & build. Think Windows might account for some of the differences in clean builds. It'd take very little for explorer to lock a file/dir and I am in the habit of losing previews and test frames behind the Netbeans frame. Briefly see the orphans when I close NB :- which'll also free any locks of course by the time I restart.

baix
Offline
Joined: 2008-02-15

My exception isn't thrown with NB it is thrown in a simple java applet having a JXDatePicker that uses the Windows Look and Feel. I posted into this thread because the exception that was previously posted here is the same as I get.

kleopatra
Offline
Joined: 2003-06-11

> My exception isn't thrown with NB it is thrown in a
> simple java applet having a JXDatePicker that uses
> the Windows Look and Feel. I posted into this thread
> because the exception that was previously posted here
> is the same as I get.

Yeah, I know that you experience it in an applet - but you don't seem to understand what is needed to try and track your problem (which is obviously not the same, the stacktrace you posted is different from the original and didn't go away after the recent changes as the original did ;-) down - and I won't repeat myself again.

Jeanette

Kleopatra

jdnc-interest@javadesktop.org schrieb:
> Now I've used the weekend build and still get the exception but if I use the default look and feel not the WLF I get no exception.
>

WLF meaning windows? Could you please further describe your context? OS,
browser, jdk version ...

And please post the example applet (including the html). I simply can't
reproduce it on windows (xp or vista), in firefox, jdk1.6. Somebody else
please take over?

CU
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

baix
Offline
Joined: 2008-02-15

if I do not change the look and feel (Java Look and Feel) all works fine but if I change the look and feel with

[code]
public void init() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
} catch (final ClassNotFoundException e) {
e.printStackTrace();
} catch (final InstantiationException e) {
e.printStackTrace();
} catch (final IllegalAccessException e) {
e.printStackTrace();
} catch (final UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
super.init();
}
[/code]

at applet initialization the previously announced exception is thrown if and only if I press the refresh button of the web browser. I'm using windows xp with firefox and internet explorer and jdk 1.6. The html code is just the old applet invocation

The date picker is placed on a panel with

[code]

add(getTxtExpirationDate(), new GridBagConstraints());

private JXDatePicker getTxtExpirationDate() {
if (this.txtExpirationDate == null) {
this.txtExpirationDate = new JXDatePicker(System.currentTimeMillis());
}
return this.txtExpirationDate;
}
[/code]

and the code is packed into a jar file.

Kleopatra

sigh ... how often do I have to spell it out: if I write "And please
post the example applet (including the html)" I really mean "small (!)
runnable (!) example". Especially if the issue is so unreproducible - no
way anybody will try and assume what's in your code that we can't see.

Haven't touched applets for years, so not the best person to look into
this: from what I faintly remember there classloader problems were
abundant. Which might be the case here as well (wildly guessing - it's
up to you to dig further) - could it be that the part using the
datepicker is loaded by another than the monthView loaded from the
archive? (haha, that sounds confusing even to myself, sorry ;-)

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

kleopatra
Offline
Joined: 2003-06-11

> Sorry, I forgot to announce that I'm using version
> 0.9.1. Here is the stacktrace of the java console:
>

could you please a more recent build, f.i. the weekly from this weekend?

Thanks
Jeanette

PS: @ssamayoa - did you try a more recent build and if so, what has been the outcome?

baix
Offline
Joined: 2008-02-15

Now I've used the weekend build and still get the exception but if I use the default look and feel not the WLF I get no exception.

Sergio Samayoa

Jeanette:
I just installed last weekly build and have no problem putting a
JXDatePicker in a form.

Baix:
> Now I've used the weekend build and still get the exception but if I use
the

I guess you mean WLF = Windows L&F, isn't?

Let me understand:

If you use "default" L&F (which is?) you get an exception but if you use
Windows L&F not.

What is your default L&F?

-----Mensaje original-----
De: jdnc-interest@javadesktop.org [mailto:jdnc-interest@javadesktop.org]
Enviado el: Lunes, 18 de Febrero de 2008 09:16 a.m.
Para: jdnc@jdnc.dev.java.net
Asunto: Re: JXDatePicker doesnt work in NB 6

Now I've used the weekend build and still get the exception but if I use the
default look and feel not the WLF I get no exception.
[Message sent by forum member 'baix' (baix)]

http://forums.java.net/jive/thread.jspa?messageID=259483

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Kleopatra

Sergio
> I just installed last weekly build and have no problem putting a
> JXDatePicker in a form.
>
>

thanks! So at least part of the issue looks solved.

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

osbald
Offline
Joined: 2003-06-13

As I happened to be in Netbeans I thought I'd try it too. No problem dragging todays snapshot of JXDatePicker into an empty form. It's not quite wide enough to show some dates without getting truncated though. (just the default format).

Which feeds into the other topic on pref-widths I think. As idiot proofing it'd be nice if your hack was a little wider; if it's column-based another column would just about work (for en dates).

osbald
Offline
Joined: 2003-06-13

Then again..

Don't know if this is related at all but I notice if I rebuild the main project inside Netbeans then some of the swingx components appear to start throwing NPEs deep within Matiesse.

Things like JXDatePicker, JXMonthView even JXLoginPane cause the errors while JXTable, JXTreeTable, JXTree are untroubled. If I remove the troublesome component while its in this erroring state the form works again (eg delete the JXDatePicker) ..If I change nothing quiting the IDE and restarting it will have everything working again ~ until the next time you build. .?

Not particularly diagnostic/reproducible I know.. worth mentioning the weirdness though.

Stacktrace as follows:

java.lang.IllegalArgumentException: Component must be non-null
at org.jdesktop.layout.GroupLayout$ComponentSpring.(GroupLayout.java:2640)
at org.jdesktop.layout.GroupLayout$ComponentSpring.(GroupLayout.java:2620)
at org.jdesktop.layout.GroupLayout$SequentialGroup.add(GroupLayout.java:1537)
at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.fillGroup(SwingLayoutBuilder.java:264)
at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.composeGroup(SwingLayoutBuilder.java:216)
at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.fillGroup(SwingLayoutBuilder.java:237)
at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.composeGroup(SwingLayoutBuilder.java:216)
at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.fillGroup(SwingLayoutBuilder.java:235)
at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.composeGroup(SwingLayoutBuilder.java:216)
at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.fillGroup(SwingLayoutBuilder.java:237)
at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.composeGroup(SwingLayoutBuilder.java:216)
at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.createLayout(SwingLayoutBuilder.java:159)
at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.setupContainerLayout(SwingLayoutBuilder.java:107)
at org.netbeans.modules.form.VisualReplicator.setupContainerLayout(VisualReplicator.java:792)
at org.netbeans.modules.form.VisualReplicator.cloneComponent(VisualReplicator.java:725)
at org.netbeans.modules.form.VisualReplicator.createClone(VisualReplicator.java:182)
at org.netbeans.modules.form.VisualReplicator.createClone(VisualReplicator.java:170)
at org.netbeans.modules.form.FormDesigner$4.run(FormDesigner.java:555)
at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:232)
at org.openide.util.Mutex.doEventAccess(Mutex.java:1223)
at org.openide.util.Mutex.readAccess(Mutex.java:284)
at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:217)
at org.netbeans.modules.form.FormDesigner.createFormView(FormDesigner.java:550)
at org.netbeans.modules.form.actions.TestAction.run(TestAction.java:132)
at org.netbeans.modules.form.actions.TestAction.performAction(TestAction.java:104)
at org.openide.util.actions.CallableSystemAction$1.run(CallableSystemAction.java:118)
at org.netbeans.modules.openide.util.ActionsBridge.doPerformAction(ActionsBridge.java:77)
at org.openide.util.actions.CallableSystemAction.actionPerformed(CallableSystemAction.java:114)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at org.openide.awt.ToolbarButton.processMouseEvent(ToolbarButton.java:61)
at java.awt.Component.processEvent(Component.java:5806)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4413)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4243)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Sergio Samayoa

Is with the latest build (17.02.08) or older one?

Which OS?
Is NB 6, isn't?

Regards.

-----Mensaje original-----
De: jdnc-interest@javadesktop.org [mailto:jdnc-interest@javadesktop.org]
Enviado el: Lunes, 18 de Febrero de 2008 12:16 p.m.
Para: jdnc@jdnc.dev.java.net
Asunto: Re: JXDatePicker doesnt work in NB 6

Don't know if this is related at all but I notice if I rebuild the main
project inside Netbeans then some of the swingx components appear to start
throwing NPEs deep within Matiesse.

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

osbald
Offline
Joined: 2003-06-13

Using Windows XP, JDK 6.0_u4, Netbeans 6.01 and Swing Extensions Layout (the swinglabs 1.5 backport). The build of swingx was the morning of the 18th. But it shouldn't matter too much so long as it was later than Kleopatras less-hacky hack made earlier in this thread.

Had some problems duplicating this at home on very simple fresh project (not the companies multi-module one). What I'm doing is importing a fresh swingx.jar into the palette (wonder if there is and easier way to do this), creating a new app, adding a new PanelForm and slapping down a few labels and a JXDatePicker. Now preview everything looks good (good-ish days of last week in the month always seem to be truncated, not quite wide enough by default).

Now do a clean rebuild and try to Preview again, get a very thin frame and flashing error in lower left corner of NB. The detailed stacktrace pretty much as above. Now try removing our JXDatepicker and hit preview - form is working again. But add another JXDatePicker or any of the others mentioned before and the stacktrace re-appears. Some JXComponents work, others will throw the error. Until you next shutdown & restart the JVM which is Netbeans in this instance.

Where my machine at home differed was closing down and restarting Netbeans the form works again. But for some reason clean-build wasn't cleaning fully. I had to delete the build and dist folders from my project manually, then build and the stracktrace reappears on previews (sometimes the previews just stop working and you dont see any error messages?).

What I suspect is Netbeans is doing some class reloading and the components causing the problems are likely to be those using LookAndFeelAddons as they've already been on the ropes over in process locale and L&F changes. Suspect this class reloading exposes another related issue. Haven't checked the source at all so feel free to shoot me down - I'm guessing JXTable, JXTree etc.. wouldn't need addons as they extend their swing counterparts.

- RichardO

Kleopatra

Richard,

thanks for detailed description - I'm at my wit's end and alerted our
Netbeans contact. Hopefully, he has some idea.

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

osbald
Offline
Joined: 2003-06-13

I'm not sure how this relates (if indeed it does) to the original nor other similar reports (where are they?). But it's the only errors I could wring out of Netbeans. Did wonder if the Applets lifetime might not create a similar scenario? In the old world no, it'd be a new JVM each time the page was loaded but with the Java Plugin acting like a quick-starter (warm JVM) might that not be another re-loading occurrence? Into the realm of day-dreams here.. just wondered to myself.

What about tweaking the hacked default width ;) I know its a finger in the air thing, but the default settings, Windows, en and Tahoma should work as a baseline. Don't know how it looks under Vista (isn't that another font-family?).

Kleopatra

jdnc-interest@javadesktop.org schrieb:
> What about tweaking the hacked default width ;) I know its a finger in the air thing, but the default settings, Windows, en and Tahoma should work as a baseline. Don't know how it looks under Vista (isn't that another font-family?).
>
you can always set the column count on the editor ;-)

No, just kidding - didn't yet have the time (prefer the fun of thinking
about real challenges over the bore of pixel counting). Did the
appearance change after the re-hacked hack?

Actually, it should be the editor itself which should report a preferred
size guaranteed to show the complete formatted string (if the column
count isn't set). I'm thinking about moving it there, but .. not sure yet.

CU
Jeanette

PS: no, you won't nudge me into Netbeans, not even for a quick check
(which wouldn't solve the problems anyway)

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

osbald
Offline
Joined: 2003-06-13

> you can always set the column count on the editor

Actually thats probably exactly what I'm still doing. I haven't updated my ComponentFactory to cater for swingx changes in an age.. that may be where you noticed the collapsing with nulls issue in the first place.. (my hacked cell renderer impl)

..Just thinking of the "broken windows" thing. Doing it properly seems hard, as you could have several inputformats too (at least used to be able to).

> PS: no, you won't nudge me into Netbeans, not even for a quick check

Oh its like that is it ;) well you probably won't get cross at me for playing devils advocate with Geertjan then: http://blogs.sun.com/geertjan/entry/beans_binding_via_the_road

ssamayoa
Offline
Joined: 2005-02-22

> but a lot of properties (like UI, UIClassID, formats, etc) shown with "java.lang.ClassCastException@

".

Never mind.

My NB project doesnt included beaninfo and I installed components in the pallete from the project.

Regards.

baix
Offline
Joined: 2008-02-15

Sorry, I forgot to announce that I'm using version 0.9.1. Here is the stacktrace of the java console:

basic: Exception: java.lang.NullPointerException
java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.jdesktop.swingx.plaf.LookAndFeelAddons.getUI(LookAndFeelAddons.java:279)
at org.jdesktop.swingx.JXDatePicker.updateUI(JXDatePicker.java:275)
at javax.swing.SwingUtilities.updateComponentTreeUI0(Unknown Source)
at javax.swing.SwingUtilities.updateComponentTreeUI0(Unknown Source)
at javax.swing.SwingUtilities.updateComponentTreeUI0(Unknown Source)
at javax.swing.SwingUtilities.updateComponentTreeUI0(Unknown Source)
at javax.swing.SwingUtilities.updateComponentTreeUI0(Unknown Source)
at javax.swing.SwingUtilities.updateComponentTreeUI0(Unknown Source)
at javax.swing.SwingUtilities.updateComponentTreeUI0(Unknown Source)
at javax.swing.SwingUtilities.updateComponentTreeUI(Unknown Source)
at xxx(xxx.java:39)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

baix
Offline
Joined: 2008-02-15

and it is still thrown if I use:

[code]
new JXDatePicker(System.currentTimeMillis());
[/code]

ssamayoa
Offline
Joined: 2005-02-22

FWIW:

This is the piece of code which causes the NPE

[code]
public static ComponentUI getUI(JComponent component, Class expectedUIClass) {
maybeInitialize();

// solve issue with ClassLoader not able to find classes
String uiClassname = (String)UIManager.get(component.getUIClassID());
try {
Class uiClass = Class.forName(uiClassname); // <<< HERE !!!
UIManager.put(uiClassname, uiClass);
} catch (ClassNotFoundException e) {
// we ignore the ClassNotFoundException
}
[/code]

JXMonthView has no problems with GUI editor.

Regards.

BTW this happends with IDE running with Windows L&F and Metal L&F.

Message was edited by: ssamayoa

ankitajain
Offline
Joined: 2008-04-18

Hi I am new to JAVA and Java swing.

I have been trying to use JXDatePicker.java in SwingX technology but I am not able to compile it. I have added the latest release of SwingX in my library still it doesn't work

Below is the error that I am getting:

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: org.jdesktop.swingx.calendar.JXMonthView cannot be cast to org.jdesktop.swingx.JXMonthView
at org.jdesktop.swingx.plaf.basic.BasicMonthViewUI.installUI(BasicMonthViewUI.java:156)
at javax.swing.JComponent.setUI(Unknown Source)
at org.jdesktop.swingx.calendar.JXMonthView.setUI(JXMonthView.java:296)
at org.jdesktop.swingx.calendar.JXMonthView.updateUI(JXMonthView.java:306)
at org.jdesktop.swingx.calendar.JXMonthView.(JXMonthView.java:262)
at org.jdesktop.swingx.calendar.JXMonthView.(JXMonthView.java:248)
at org.jdesktop.swingx.JXDatePicker.(JXDatePicker.java:130)
at org.jdesktop.swingx.JXDatePicker.(JXDatePicker.java:114)
at org.jdesktop.swingx.JXDatePicker$1.run(JXDatePicker.java:617)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Any idea what I am doing wrong ?? Any help would be appreciated .

Thanks in advance

Kleopatra

jdnc-interest@javadesktop.org schrieb:
> Below is the error that I am getting:
>
> Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: org.jdesktop.swingx.calendar.JXMonthView cannot be cast to org.jdesktop.swingx.JXMonthView
>

looks like a versioning problem: starting with 0.9.1 the JXMonthView was
moved from package *.swingx.calendar to *.swingx. There had been other
changes as well. Adjusting the imports should help.

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

ankitajain
Offline
Joined: 2008-04-18

Thanks, but now I am getting some different error :

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.jdesktop.swingx.event.DateSelectionEvent.(Ljava/lang/Object;Lorg/jdesktop/swingx/event/DateSelectionEvent$EventType;Z)V
at org.jdesktop.swingx.calendar.DefaultDateSelectionModel.fireValueChanged(DefaultDateSelectionModel.java:323)
at org.jdesktop.swingx.calendar.DefaultDateSelectionModel.setSelectionInterval(DefaultDateSelectionModel.java:122)
at org.jdesktop.swingx.JXMonthView.setSelectionInterval(JXMonthView.java:572)
at org.jdesktop.swingx.JXDatePicker.(JXDatePicker.java:132)
at org.jdesktop.swingx.JXDatePicker.(JXDatePicker.java:114)
at org.jdesktop.swingx.JXDatePicker$1.run(JXDatePicker.java:617)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Due you think it has something to do with the adjustments in imports that I have done .

Thanks
Ankita

Kleopatra

jdnc-interest@javadesktop.org schrieb:
> Due you think it has something to do with the adjustments in imports that I have done .
>
>

sure - in a way. The basic issue is that you are somehow mixing versions
of swingx or application code written against an older version. Be sure
that there's no oldish jar lying around somewhere and/or update the
application code to the api as appropriate for the swingx version you're
using. Can't help you from here, not seeing your setup (and wouldn't
touch Netbeans anyway )

CU
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Kleopatra

Still don't know what's happening (and can't really debug, nooo, I'm not
goint to try netbeans ) - but ...
> org.jdesktop.swingx.plaf.basic.BasicDatePickerUI.getEditorPreferredSize(BasicDatePickerUI.java:527)
> at

that's the place which subtly changed during the last couple of weeks or
so. The code (ashes on me ;.) is a dirty ol' trick around the editors
sub-optimal sizing on a null date:

[code]
/**
* Returns a preferred size for the editor. If the selected date
* is null, returns a reasonable minimal width.

*
* PENDING: how to find the "reasonable" width is open to discussion.
* This implementation creates another datePicker, feeds it with
* the formats and asks its prefWidth.
*
* @return the editor's preferred size
*/
private Dimension getEditorPreferredSize() {
Dimension dim = datePicker.getEditor().getPreferredSize();
if (datePicker.getDate() == null) {
// the editor tends to collapsing for empty values
// JW: better do this in a custom editor?
JXDatePicker picker = new JXDatePicker(new Date());
picker.setFormats(datePicker.getFormats());
dim.width = picker.getEditor().getPreferredSize().width;
}
return dim;
}

[/code]

What changed is the datePicker default date on init. Now it is null
(earlier it was today) so the if block is run always. Which might be
potentially unsafe, because a new picker is instantiated "early" in the
lifetime of the first. Could somebody experiencing the problem please
comment the lines and let me know if that helps? Crossing fingers ..

Thanks!
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

ssamayoa
Offline
Joined: 2005-02-22

> What changed is the datePicker default date on init.
> Now it is null
> (earlier it was today) so the if block is run always.
> Which might be
> potentially unsafe, because a new picker is
> instantiated "early" in the
> lifetime of the first. Could somebody experiencing
> the problem please
> comment the lines and let me know if that helps?
> Crossing fingers ..

Bingo!

I reverted the bean constructor from:

[code]
public JXDatePicker() {
this(null, null);
}
[/code]

to (as was in 0.9.1):

[code]
public JXDatePicker() {
this(System.currentTimeMillis());
}
[/code]

And now I can use in NB but a lot of properties (like UI, UIClassID, formats, etc) shown with "java.lang.ClassCastException@

".

Regards.

Regards.

Kleopatra

jdnc-interest@javadesktop.org schrieb:
> Bingo!
>
> I reverted the bean constructor from:
> [code]
> public JXDatePicker() {
> this(null, null);
> }
> [/code]
>
> to (as was in 0.9.1)
> [code]
> public JXDatePicker() {
> this(System.currentTimeMillis());
> }
> [/code]
>
> And now I can use in NB.
>

ooookay ...
> Now, which is the correct behaviour?
>

well, I think the correct thing to do is to have a null date by default
("today" is as arbitray as my birthdate ) I'll remove the prefsize
hack in the datepicker ui. Then we'll see if the null date blows
somethere else.

Will come back to you as soon as that's committed.

Thanks!
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Kleopatra

Kleopatra schrieb:
>
> well, I think the correct thing to do is to have a null date by
> default ("today" is as arbitray as my birthdate ) I'll remove the
> prefsize hack in the datepicker ui. Then we'll see if the null date
> blows somethere else.
>
> Will come back to you as soon as that's committed.
>
okay, done - as of build #882. Please let me know if that worked (with a
null default date in the picker!)

Thanks
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

baix
Offline
Joined: 2008-02-15

I have get the same Exception when I'm using the date picker in an applet and I press the reload button of the browser. The first time the applet is starting without any problems.

Regards.

Kleopatra

jdnc-interest@javadesktop.org schrieb:
> I have get the same Exception when I'm using the date picker in an applet and I press the reload button of the browser. The first time the applet is starting without any problems.
>
>

this is rather weird - can't reproduce in firefox/Vista :-(

opened an issue to not forget:

https://swingx.dev.java.net/issues/show_bug.cgi?id=763

A quick question: anybody recalls when exactly this started to happen?
Or the other way round: what was the last build without the exception?
(yeah, I know, asking much - but we all want to get this fixed ;-)

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Kleopatra

jdnc-interest@javadesktop.org schrieb:
> When I try to put a JXDatePicker in a form simply doesnt work.
>
> IDE log shows:
>
> java.lang.NullPointerException
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:169)
> at org.jdesktop.swingx.plaf.LookAndFeelAddons.getUI(LookAndFeelAddons.java:280)
> at org.jdesktop.swingx.JXMonthView.updateUI(JXMonthView.java:792)
> at org.jdesktop.swingx.JXMonthView.(JXMonthView.java:341)
> at org.jdesktop.swingx.JXMonthView.(JXMonthView.java:281)
> at org.jdesktop.swingx.JXDatePicker.initMonthView(JXDatePicker.java:272)
> at org.jdesktop.swingx.JXDatePicker.init(JXDatePicker.java:263)
> at org.jdesktop.swingx.JXDatePicker.(JXDatePicker.java:192)
> at org.jdesktop.swingx.JXDatePicker.(JXDatePicker.java:160)
> at org.jdesktop.swingx.plaf.basic.BasicDatePickerUI.getEditorPreferredSize(BasicDatePickerUI.java:527)
> at org.jdesktop.swingx.plaf.basic.BasicDatePickerUI.getPreferredSize(BasicDatePickerUI.java:502)
> at javax.swing.JComponent.getPreferredSize(JComponent.java:1632)
>

hmm ... you are not alone with those problems (we had other reports) -
but unfortunately we have no clue as to why that happens :-(

What's your LAF? What happens if you create a MonthView or a DatePicker
manually and add it to a frame and run? And/or could you please run the
JXDatePickerTest and see what happens. And/or the
JXDatePickerVisualCheck to see if anything shows up?

Thanks!
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

ssamayoa
Offline
Joined: 2005-02-22

> What's your LAF?

Windows's default.

> What happens if you create a MonthView or a DatePicker

I can create and use JXMonthView with GUI builder. The problem is JXDatePicker.

> manually and add it to a frame and run?
Works.

> JXDatePickerTest and see what happens. And/or the
> JXDatePickerVisualCheck to see if anything shows up?

Both passed.

Regards.