Site Sponsors:
JDK Issues - JPanel 

X11 Errors


There I was - poised to release another version of "The Sierra Bible", when we noticed - yet again - that not all Java Implementations are equal. Each have their own problems.

In this case, a buglet we were stalking came down to how The Sun 1.6 JDK implemented their hooks into the platform window manger (in this case, X11.) While Open JDK was working just fine, Sun's implementation was proving to be - uh - exceptional.

Exception Situation


Be they hosted by JDialog or JFrame, more and more folks are using panels.

Here is a JDialog using a JPanel:


public jdlgPopUp(JFrame parent, JPanel pan, String sTitle) {
super(parent, false);
initComponents();
this.getContentPane().add(pan, "card");
setTitle(sTitle);
pack();
}


Again, all worked fine under Open JDK. Under Sun, however, we saw:


Exception in thread "AWT-EventQueue-0" sun.awt.X11.XException: Cannot write XdndAware property
at sun.awt.X11.XDnDDropTargetProtocol.registerDropTarget(XDnDDropTargetProtocol.java:79)
at sun.awt.X11.XDropTargetRegistry.registerDropSite(XDropTargetRegistry.java:554)
at sun.awt.X11.XWindowPeer.addDropTarget(XWindowPeer.java:1633)
at sun.awt.X11.XComponentPeer.addDropTarget(XComponentPeer.java:1509)
at java.awt.dnd.DropTarget.addNotify(DropTarget.java:493)
at java.awt.Component.addNotify(Component.java:6687)
at java.awt.Container.addNotify(Container.java:2567)
at javax.swing.JComponent.addNotify(JComponent.java:4685)
at java.awt.Container.addNotify(Container.java:2578)
at javax.swing.JComponent.addNotify(JComponent.java:4685)
at java.awt.Container.addNotify(Container.java:2578)
at javax.swing.JComponent.addNotify(JComponent.java:4685)
at java.awt.Container.addImpl(Container.java:1068)
at java.awt.Container.add(Container.java:927)
at com.soft9000.VerseWorker.jdlgPopUp.<init>(jdlgPopUp.java:41)

The above exception was obviously bumped into while negotiating the X11 interface ("Cannot write XdndAware property".) Some variation of the problem was the same no matter if we were using JDialog, or JFrame. The result was - on error - that only Suns' JDK fails to display the application. Without a UI, you've got to kill the zombie explicitly.

(Note: Many implementations can assist with Java 'zombie management' by providing a PID as the prefix for a process name:
ManagementFactory.getRuntimeMXBean().getName();
)

The Solution


The solution, however, was to have a little faith in the Java specification! Indeed, is as much as every other JRE we had was able to "pass the test", we decided to simply add - then remove - another container from jdlgPopUp:


public jdlgPopUp(JFrame parent, JPanel pan, String sTitle) {
super(parent, false);
initComponents();
this.getContentPane().removeAll();
this.getContentPane().add(pan, "card");
setTitle(sTitle);
pack();
}

-Adding another component insured that the dialog initially did what it takes to register another container (in this case, a mere JScrollPane,) properly.

Using .removeAll(), in-turn, then ensured that those same X11 Structures were in place. -All things attributed & properly ORed so that our JPanel can re-use them.

Conclusion


Of course it all works fine now. After the above, our beta-testing continues on-schedule.

Indeed, by laying our hands upon just about every pre-installed, de-facto, or add-on JRE we can lay think of (Windows, OS X, Ubuntu, Oracle, IBM, etc,) the mission is all about supporting our fellow software enthusiasts.

So far, this fix works on everything we can hum at it.

Enjoy,

-Rn


[ add comment ] ( 3347 views )   |  permalink  |  related link
Easier Hourly Rate Calculation - 2012 
I had a few moments today to update the "Reasonable Rate Calculator."

http://soft9000.com/CalcYouLater/

Note that we kept the PHP version in there for those who do not have Java.


Enjoy,

-Rn

[ add comment ] ( 6487 views )   |  permalink  |  related link

<<First <Back | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | Next> Last>>