Posts in the “java” category

Java font size - how to change the JTextArea, JTextPane, JEditorPane font size

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:

A Java KeyStroke, KeyEvent, Action, InputMap, and ActionMap example

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:

  • [Apple][=]
  • [Apple][Shift][=]
  • [Apple][+]

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.

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.

A Mac Java ApplicationAdapter class example

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.

Java software license manager libraries

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.

Where are Java preferences stored on Mac OS X?

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:

Free license key generator for Java applications

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.

True License as a Java license key manager

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.

Java decompilers and obfuscators (Oh my!)

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).

A Java Action, ActionListener, and AbstractAction example

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.

Reading a Java for loop helps me remember the syntax

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":