jframe

Using Scala with Java Swing classes is pretty seamless

If you ever wanted to use Scala with Java Swing classes (like JFrame, JTextArea, JScrollPane, etc.), the process is pretty seamless. Here’s an example of a simple Scala/Swing application where I show a text area in a JFrame:

How to cast a null value in Java

Until a little while ago I don’t think I had ever thought about intentionally casting a null value in Java, but then I ran into a problem and realized that the solution was to cast a null value, like this:

FileDialog d = new FileDialog((java.awt.Frame) null);

You have to do that in this case because FileDialog has several one-argument constructors, including one that takes a JFrame and another that takes a JDialog. If you just put null in the constructor the Java compiler or your favorite IDE will complain, so you have to cast the null value to one of those specific types, and this syntax shows how to do this. (My app uses multiple frames, and at the moment I’d rather put null in the FileDialog constructor than try to determine which frame is currently in the foreground.)

Java: JOptionPane showMessageDialog examples (part 1)

I’ve been working with the Java JOptionPane showMessageDialog a lot lately, so I thought I’d create a page here with a number of showMessageDialog examples, sort of a JOptionPane reference page.

I’ll walk you through some JOptionPane examples here, starting with a simple example and then increasing the level of difficulty as I go on.

JFrame examples and tutorials (collection)

Today is organization day for me, and in an effort to organize everything I've ever written about a Java JFrame, here is a collection of links to all my Java JFrame examples and tutorials.

Java on MacOS: A default Mac menubar without a JFrame

Yesterday I ran into a pretty obscure situation in my Imagen application where I needed to show a modified Mac menubar, even though I didn't have a Java JFrame displayed at the time. The way Imagen works is that I show a JFrame, then hide it, and the application then waits for the user to do something with the application icon in the Mac Dock, typically dropping an image onto that icon.

Transparent JFrame - How to make a JFrame transparent on Mac OS X

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.

Java xeyes - Follow the mouse cursor location outside a JFrame

A Java xeyes solution - I started working on my Java speech recognition app again today, and in the process I saw some source code I thought I should post here. When I was developing this app, I thought it would fun to put a GUI on it, and when I thought about what sort of GUI it should have, I thought of the old X-Windows xeyes app. I looked around to see if anyone had written a "Java xeyes" application, but from what I've seen, nobody has.

Hide Mac Desktop clutter with DesktopShield (free)

Update: I've taken the approach shown in this article and turned it into a much more robust Mac OS X app, which I'm selling for a whopping $0.99.

Follow this link for a free trial of my "Mac OS X Hide Your Desktop Icons" application.

I wrote a very small "Java on Mac OS X" application that I'd like to share here today. This one is a little different, so let me explain the problem.

I've found that using Mac OS X is different from using Windows, in that with Mac applications, I almost never use them in full-screen mode. Typically they occupy 1/2 or 2/3 of my over screen, and then I have to see my Mac Desktop behind the application window. I actually prefer everything about this approach except for one thing: My Desktop is usually very cluttered, and I don't like to see that clutter while I'm working.