Still organizing things around here, and here is a list of JDialog tutorials and examples I have created:
JDialog FAQ: How do I capture the JDialog close event?
To get the event when a JDialog is closed, you can add a window listener using addWindowListener to your JDialog, or add a component listener, using addComponentListener.
Java/Swing FAQ: How do I center a JDialog?
Answer: The answer here really depends on what you mean by "center". If you really want to center a JDialog on screen, you can use code like this:
// center a jdialog on screen JDialog d = new JDialog(); d.setSize(400, 300); d.setLocationRelativeTo(null); d.setVisible(true);
By calling setLocationRelativeTo with
null, the JDialog will be centered.
The running program
JSheet effect is very nice, it works as advertised. My only problem with it currently is that it does something to distort the image when the
JSheet is displayed. You can see this problem in the image shown below, where the coffee cup image that sits on top of the caution image does not look very good:
I'm always looking for ways to make my Java Swing applications on Mac OS X look more and more like native Mac applications, and when a co-worker mentioned the name Quaqua, I decided to take a look at that library/framework one more time. I had looked at it before, but this time, looking at it with a new mindset, I noticed it offers a
I just solved a problem I was having in a Java Swing application getting input focus on a JDialog in a homemade text editor I use on my Mac OS X systems. Using my initial Java code the JDialog was properly getting input focus the first time it was displayed, but it was not properly getting input focus when it was displayed a second (or any subsequent) time.
Here's a link to a new tutorial I've published titled "How to get Swing components to grow and fill using the JGoodies FormLayout".
While I'm in the neighborhood, here are a couple of quick links to go with that tutorial:
A couple of us were just working on a Java application that uses a JDialog, and were wondering how to change the icon image of a JDialog (a Java dialog).
Changing the JDialog icon image doesn't seem to be too hard, though it's not quite as simple as you might think. It turns out that the JDialog inherits the icon image from it's parent, which in my case is a JFrame. So in the code sample below I'm showing two different ways to do this.
Ouch ... here's a quick little ditty on how to properly size a JDialog to fit the size of a wide/large JTable that it contains.
(From a recent email.) Help, I have a 13-column JTable, inside of a jscroll pane, inside of a borderlayout, inside a JDialog. Ideally, I would like the dialog to initially open up to the correct width needed to display the 13 columns without horizontal scrolling.
Setting the preferred width of each column (only) does not work very well. Setting the minWidth gets the columns to open up to the correct width, but then the last 7 or so columns fall off the right hand side of the dialog.