Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

I just learned how to create a ButtonGroup using JFormDesigner, and it's pretty easy and pretty cool.

First, add all the related buttons you want on your JFormDesigner form. Next, click all the buttons while holding down the [Control] or [Apple] key, depending on your platform, so the all the buttons are selected at one time. Then right-click one of the buttons, then select the "Group Buttons" option from the popup menu.

I just noticed that you can set the preferred size of a column in a JTable using JFormDesigner. If you're looking at a JTable in the normal JFormDesigner view, click the ellipsis button for the model property in the Properties list. This brings up the JTable model editor.

Next, click a cell in the column you want to modify. Then on the bottom-right of this dialog you'll see a few fields labeled "Pref. Width", "Min. Width", and "Max. Width". Just type in a value you want for the preferred width of your column.

AppleScript iTunes search FAQ: How do I search for an iTunes song using AppleScript?

AppleScript iTunes song search and play example

I'm not sure if the following AppleScript example is the best way to search for an iTunes song and then play that song using AppleScript, but it is one way that I discovered recently while working on my AppleScript alarm clock application.

AppleScript iTunes FAQ: Can you demonstrate an AppleScript iTunes example (such as an AppleScript iTunes alarm clock)?

For a little while now I've been creating an AppleScript iTunes alarm clock application (an AppleScript alarm that would work with iTunes). The basic idea of the application was to do the following:

AppleScript time subroutine FAQ: Can you share an example of an AppleScript subroutine (function) that returns te current time?

Here's an example AppleScript subroutine (also known as a function or method) that returns the current time as hours and minutes, along with the AM/PM modifier. For the purposes of creating an alarm clock AppleScript program, I didn't like the default format of the AppleScript current date command, so I use this method to extract the current time information I want.

Still reading Calculus Made Easy, they note that 'e' (the natural logarithm, or natural log) is the limit of the following series:

1 + 1/1! + 1/2! + 1/3! ...

To test this I created the following Ruby natural log program.

AppleScript result output FAQ: How can I display the output of my AppleScript script (the AppleScript result)?

Cool, I just learned how to get AppleScript output to show up in the ScriptEditor Result tab. In short, just leave a string at the end of your AppleScript script, and it is printed in the ScriptEditor Result tab.

ScriptEditor Result output: An AppleScript output "Hello world" example

Here's a quick AppleScript result example that puts "Hello world" in the ScriptEditor Result tab:

AppleScript dialog list FAQ: How can I display a list in an AppleScript dialog?

I couldn't find an example showing how to display a list of strings in an AppleScript dialog, so I created the following simple example. First I create a list (in this case a short list of voices on Mac OS/X that can be used with the say command), and then I display the list in a dialog the user can use to select one of the items in the list.

AppleScript alarm clock: Creating a time-based trigger.

I'm still working on my AppleScript iTunes alarm clock program, and looking for a way to set the alarm clock wake up time from the script itself. Earlier I was thinking about doing this using the Mac crontab facility, but somehow I don't think that's going to work for everyone. :)

Mac text to speech voices: What do you know about Mac OS X text to speech voice capabilities, including using AppleScript to convert text to speech?

I'm goofing around currently, using the very cool Mac text to speech capability. Okay, really, what I'm doing is writing an AppleScript iTunes alarm clock program to wake me up in the morning, and in the process I started digging into this Mac text to speech stuff, using AppleScript.

A couple of us were just working on a Java application that uses a JDialog, and were wondering how to change the icon image of a JDialog (a Java dialog).

Changing the JDialog icon image doesn't seem to be too hard, though it's not quite as simple as you might think. It turns out that the JDialog inherits the icon image from it's parent, which in my case is a JFrame. So in the code sample below I'm showing two different ways to do this.

I just ran into a situation where I needed to import some CSV data into a MySQL database table. I already had the data I needed in a CSV file format, and I needed to import the data in that file into my MySQL database table.

A few more specifics about the problem and the solution:

Secrets of Apple design: A Steve Wozniak quote on designing products to work the way humans work.

I wrote recently that for some areas of design, we need to get away from thinking like humans -- with our inherent physical limitations -- if we're going to make the next great inventions. (That article is no longer available, but it consisted of excercises like getting down on the floor, and looking at the world from the perspective of a child or a small animal; or standing on a desk, and seeing what things would look like if you were 10' tall.)

A friend of mine mentioned something the other day that has resonated with me quite a bit. I don't remember who he was talking about -- a person in the military I think -- but he mentioned that this person went through interesting lengths to remind himself each day that we see the world through a narrow lens.

If you ever see the following error message when running a Ruby mail script that uses the IMAP library it may not be as bad as it seems:

Here is the source code for a Ruby mail program I wrote that looks through my INBOX and finds all the email messages I have a) read but b) have not replied to.

This Ruby script comes in very handy on a project I'm working on now where we exchange 50-75 email messages per day. After a little while there are so many messages I can't remember if I replied to the important messages, so this program helps whittle down the list and just shows the ones I have read, but have not replied to. (The ones I haven't read are a lot easier to spot.)

Here's a Ruby mail program that I use to read my inbox, and move mail messages from a group of people that I have read to an IMAP folder that I have setup specifically for those people. The beauty of this is that I don't move the email messages I haven't read yet -- I just move the messages I have read.

Mac Java FAQ: Where is Java installed on my Mac OS X system?

On Mac OS X 10.10 (Yosemite), you can find Java installations under this directory:

/Library/Java/JavaVirtualMachines

I currently have versions of Java 7 and Java 8 installed under that directory.

On much older versions of Mac OS X — like 10.4 — Java versions used to be installed here:

/System/Library/Frameworks/JavaVM.framework/Versions

I was recently reminded of the danger of leaving less-experienced software developers alone to create new functionality in a technical area where they have no prior experience. For instance, suppose you have one or more good but less-experienced developers, and you ask them to work in a technical where they have no prior experience. These aren't totally inexperienced developers; they may each have at least five years experience. Given that their are other people on the team with experience in this area, how do you think this should be handled? Choices include:

tar gzip FAQ: Can you show how to extract (un-tar) a tar archive that has been created with tar and gzip?

Say you have a file (archive) named myfile.tar.gz, and you want to unzip it and unpack (un-tar) it in one command. This "tar extract" command should do the trick for you:

tar xzf myfile.tar.gz

That tar command can be read as "use tar and gzip (the 'z' option) to extract the contents of the file (archive) named myfile.tar.gz.