Monday September 17, 2007
Never Eat The Yellow Snow
My IDE is even more helpful than before, now. Because I've been playing with the IDE's JGlassPane (as a result of some questions about this), I am now ready for winter:
Don't say I didn't warn you. I have found Chet and Romain's book very helpful in this instance too. Somewhere I read that their book is supposedly aimed at advanced Swing developers. Well, if that's true, why is there a detailed section on Threading (amongst several other interesting intro topics) at the start of the book? And not just a paragraph or two, but really in detail. Anyway, read page 34 of their book, create a module installer (helpful wizard generates practically everything you need) and then fill out the restored() method as follows:
private MyGlassPane glassPane = new MyGlassPane();
@Override
public void restored() {
new Thread(new Runnable() {
public void run() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final JFrame mainWin = (JFrame) WindowManager.getDefault().getMainWindow();
mainWin.setGlassPane(glassPane);
glassPane.setVisible(true);
}
});
}
}).start();
}
The highlighted lines above come directly from the book, for posting nonblocking new tasks to the EDT. The bit in between the highlighted lines is... me grabbing the IDE's main window. And, from there, you can get the menu bar, the content pane, and, as in this case, the glass pane. Here, a TopComponent (yes! that tiny JTextField comes from a TopComponent) is set as the glass pane, with setOpaque(false) in its constructor, and, as you can see above, the typical call to setVisible on the glass pane. And, what does the TopComponent contain? Nothing but a JTextField, in the bottom right hand corner. So the TopComponent ends up being placed transparently over the surface of the IDE, with the JTextField fitting snugly into the bottom right corner.
And, remember, never eat the yellow snow.
In other news. I've been very slow in responding to several people over the last few days. I apologize! It's been a busy time in NetBeans land, what with the release of NetBeans IDE 6.0 Beta 1, and all the related loose ends that needed to be tied in the world of documentation (which is where I live). I hope to catch up with my correspondence in the next few days.
Sep 17 2007, 11:49:10 PM PDT Permalink


