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:
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.)
If you ever wanted to see how easy it is to create a form using the JGoodies
FormLayout, this code shows a simple example:
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.
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.
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.
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.
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.
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.
Java Swing FAQ: How do I create a menubar (and menu and menuitems) in Java?
As I was working on a Java/Swing problem last week, I was scouring through the Mac OS X Java-Dev mailing list, and along the way I ran into some really nice source code I thought I could modify into a decent Java Menubar example. After a little rewriting, here is that "Java Menubar" example.