A collection of JScrollPane examples and tutorials
As a way of helping to organize this website, here is a collection of links to my current JScrollPane tutorials and examples:
As a way of helping to organize this website, here is a collection of links to my current JScrollPane tutorials and examples:
Continuing with the organization efforts again today, here is a collection of Java JButton tutorials and examples:
<< Back to "Java exec with ProcessBuilder and Process, part 1"
Now that you've seen that snippet of code, here's a complete Java class named ProcessBuilderExample that can execute a Unix/Linux system command:
I'm currently writing a customized text editor in Java, and as part of that, I want to make it easy for the user to increase or decrease the font size in the text editing area (technically a JTextPane). I didn't expect this to be easy, but I've been pleasantly surprised that the following approach seems to work just fine:
I don't know if this is the "proper" way to handle having multiple keystrokes for one action, but until I find a better approach I thought I'd share this here.
For my Java text editor application, on Mac OS X I want the user to be able to use any of the following keystrokes to increase the font size by one unit:
Each of those keystrokes might be interpreted by a user as being equivalent to [Apple][+], so I want to be sure I support all three of them.
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.
I wrote a longer Java/Mac/Swing tutorial yesterday titled "Handling the Java on Mac OS X About, Quit and Preferences menu events", but if you're just interested in handling the Mac OS X Preferences menu item in a Java/Swing application, here's a shorter version of that information.
Before I get too far away from all of the Java/Swing/Mac GUI code I've been working on lately, I thought I'd share this Mac Java ApplicationAdapter class implementation.
This class is an example implementation of Apple's ApplicationAdapter class, which itself is a stub implementation of their own ApplicationListener interface. If you want to write Java GUI code on Mac OS X, it's important to learn about the ApplicationAdapter class, so you can handle the About, Preferences, and Quit events properly.
I'm sorry that I don't have my other Java/Mac OS X tutorials moved into the Drupal CMS here, but I will try to get that corrected somewhere down the road. In the meantime, here are links to each section of my complete "How to make your Java application look and feel like a Mac OS X application tutorial":
Summary: A look at free Java software license managers.
To help supplement my income, I've been thinking about creating some Java-based shareware applications. As I started thinking about software to time-out my application after 10 or 15 days, and requiring a license to use the software after that initial trial period, I've started down the rabbit hole of Java software license managers.
Java/Mac OS X FAQ: Where are Java Preferences stored on Mac OS X?
The preferences you store from within a Java application on a Mac OS X system are saved in a file in the user's ~/Library/Preferences
directory. For instance, for a Mac user named Alvin
, and a Java class named com.devdaily.Foo
, preferences for that class will be stored in this file:
Just a quick note that if you happen to be looking for a license key generator (or "license key manager") for a Java desktop (Swing) application, I've been taking a look at the TrueLicense library on java.net, and although it is several years old now, it seems to work well, and the author certainly put a lot of time and thought into it.
Summary: Using True License as a Java license key manager.
I'm currently working on a plan to release four small software applications this year, and I'm going to try my hand at licensing them as shareware applications, written in Java. After digging around for a "Java license manager", I finally found a free, open source product named "True License" that I like, and I'm giving it a try.
Wow -- I just looked at the state of the "Java obfuscator" market, and all I can say is, well, wow. If you've written some Java code as commercial software (where you don't want your Java class files turned back into Java source files), and you haven't obfuscated that code, it looks like a Java obfuscator can turn your Java class files back into source code very easily (once again).
Java on Mac OS X Swing FAQ: I've written a Java/Swing application, and bundled it so it looks like a native Mac OS X application. When I run my application, if I am writing to System.out or System.err, where does this output go?
After taking a recent look at a Java decompiler, I decided to look again at the Java obfuscator market. I was going to put together a little list of Java obfuscators, but the people at ProGuard have already done that work for me.
So, here's a link to their list of Java obfuscators, which includes a simple tabular comparison of each obfuscator.
Java Swing FAQ: Can you provide a complete example of how to use the Java Action interface and the Java AbstractAction class?
The Java Action interface and AbstractAction class are terrific ways of encapsulating behaviors (logic), especially when an action can be triggered from more than one place in your Java/Swing application.
Java FAQ: Can you provide an example of the Java 5 autoboxing syntax?
Java directory FAQ: How do I walk a directory tree and do something with the files and directories I find?
I've done this recently by extending the DirectoryWalker class of the Jakarta Commons IO project.
It has taken me a little while to get used to the new Java for loop (foreach loop) syntax, but I've gotten a lot better with it by trying to read my for loops aloud. For instance, I would read the Java for loop below as "For each Pizza in the list of pizzas":