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 ] ( 3476 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 ] ( 6575 views )   |  permalink  |  related link
Easy Backgrounds for Android 
I have developed a great respect for the developers of the Android Graphics Framework. Why? Because it is obvious that the developers like to use their classes, themselves.

It's Ragu!


Indeed, from doing complex things like affine transforms, to even simple things like measuring a Canvas or a Bitmap, Android has the data we need, when-we-need-it. -From splits to splines, it all seems to be "in there"! (The Company that makes Ragu Spaghetti Sauce had a commercial a few years back - many take the expression it's ragu to mean ''it's in there''!)

Vista


Such was thee case of having what we needed "in there" when we set our paws to spruce-up a little ditty we wrote for the Android Marketplace. When it came time to spread a tile image all over a background, we had what we needed. -So much so that we feel confident that what we wrote will be able to work across hand-held devices of infinite screen size. All because members are ragu, where & when they should be... and more:

public void draw(Canvas can) {
if (bmpBack != null) {
PixelCellMap map = new PixelCellMap(can.getWidth(), can.getHeight(), bmpBack.getWidth(), bmpBack.getHeight());
int iCells = map.getCellCount();
for (int ss = 0; ss < iCells; ss++) {
Point pt = map.getActual(ss);
can.drawBitmap(bmpBack, pt.x, pt.y, paintPaper);
}
} else {
can.drawColor(paintPaper.getColor());
}
}

Note that the PixelCellMap class is part of a forthcoming Open Source Toolkit. One we are creating for cross-platform Android / Swing / AWT portability. -If you want to learn more about it (the code-named for the graphical part of the framework is Vista (sorry - but that moniker just made the most sense at the moment)), then give us a holler.


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

<<First <Back | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | Next> Last>>