determine

Java - get the number of mouse buttons

Java mouse buttons FAQ: How do I determine the number of mouse buttons in a Java application?

I'm working on a Java Swing application, and I'd like to be able to determine the number of mouse buttons on the current system (Mac, Linux, Windows).

Ant FAQ: How to determine the platform operating system in an Ant build script

Problem

You're creating an Ant build script, and you need to determine the operating system the script is running on, so you can make conditional decisions within the build script. You typically want/need to do this if you're going to run tasks/targets that are different for each operating system (Mac, Windows, Unix, etc.).

How to determine the directory your Java application was started in (user.dir)

If you ever need to determine what directory your Java code is being run from (essentially the current working directory), you can get this information from the system properties, specifically the System.getProperty or System.getProperties methods.

The following line of Java code shows how to determine what directory your Java application was started in. This information is stored in the user.dir system property, which you access like this:

AppleScript tip: getting the current time

A quick note about getting the current time in AppleScript in two different formats. This command

set t to (time string of (current date))

yields something like this result (depending on the time of day):

"12:48:35 PM"

but this command

set t to (time of (current date))

yields something like this result:

46218

(That's the number of seconds since midnight, in case you were wondering.)