Java Swing FAQ: How can I tell if my Java/Swing code is running on the Event Dispatch Thread (EDT)?
recent posts related to swing and java gui development
Summary: How to make a Java JFrame transparent (translucent) on Mac OS X.
A lot of people complain about a lot of things in regards to Java on Apple's Mac OS X platform, and okay, occasionally I'm one of them, but a very cool thing you can do on OS X is to create translucent (transparent) frames and windows with Java.
Lately I've been doing a lot of Java programming on Apple's Mac OS X platform, and my most recent effort has been to handle drag and drop events in my Java Swing application. Not satisfied to handle "simple" drag and drop events, I decided I wanted to take my application even farther, and let users drag files and images to my Java application icon in the Mac Dock.
Java Swing FAQ: How do I create a Java tooltip (also known as balloon or bubble help text)?
I'm often asked, "How do I center a JFrame on screen?", or, "Is there a method to center a JFrame?"
I always center my initial JFrame on screen using the
setLocationRelativeTo method, and pass it a
null reference. As the Javadoc for
setLocationRelativeTo method states:
I thought I'd share a collection of JOptionPane showInputDialog examples today. I'll start with the easiest example first, then try to add a little complexity as we go along.
First up, here's a simple JOptionPane showInputDialog example where I display a dialog that prompts a user to enter their name:
You want to implement a nice mouse rollover effect on the buttons (JButton instances) in your Java Swing application. This Java button rollover effect makes your application feel more "alive" and interactive.
You can see what this button rollover effect looks like in the following two images. First, here's what a Java button (
JButton) looks like normally:
Java/Swing FAQ: How do I set the help text (i.e., help text, balloon text, tooltip text) on a JButton?
Just call the
setToolTipText method on the
JButton. Here's a quick JButton tooltip display example:
// create a button with tooltip help text JButton button = new JButton("Click Me"); button.setToolTipText("Click this button to make something happen.");