Wednesday, November 18, 2026

Thinking I have found a bug in Java Swing...

 Swing has been around a long time. I started using it in 1999. Yeah, that's right, an entirely different millenium.

So you'd think there wouldn't be any bugs left...but i think I found one.

Try this:


JFileChooser jfc = new JFileChooser(); // home folder ?

int result = jfc.showSaveDialog((JButton)ev.getSource());

if (result == JFileChooser.APPROVE_OPTION == false) return;

File otherKey = jfc.getSelectedFile();

jfc.setCurrentDirectory(null); // null means homedir

jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);


Now, double-click on your "downloads" folder. Click OK without selecting anything. You would expect to get this:

/Users/<YOURNAME>/Downloads/

but instead you get:

/Users/<YOURNAME>/Downloads/Downloads/

because there's a FRICKIN BUG!


The solution isn't hard:

File folderToSaveInto = jfc.getSelectedFile();

//this should resolve things.

if (folderToSaveInto.getName().equals(folderToSaveInto.getParentFile().getName()))

folderToSaveInto = folderToSaveInto.getParentFile();


BUT I SHOULDN'T HAVE TO DO THIS!

Well, unsurprisingly, that specific fix has its own problem, ON WINDOWS!

OSX doesn't do the wrong thing here, because you don't actually get access to the actual top-level root folder, for anything anywhere. Windows, however, DOES allow it, because drive roots are a unique thing.

OSX root, at the command line, is "/", but in the dialog that doesn't exist. If. you need to get to specific drives, the are findable/selectable as /Volumes/Macintosh HD/ or /Volumes/ThunbDrive/ or whatever...so the above fix can't make a mistake.

On windows, drive roots are separate. C:\ doesn't have a higher thing, D:\ doesn't either, and you can't get from one to the other. And they then look different inside Java.

This seems better:

JFileChooser jfc = new JFileChooser("/Volumes" ); // home folder ?

jfc.setCurrentDirectory(null); // null means homedir

jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

File folderToSaveInto = jfc.getSelectedFile();

//this should resolve things.

if (folderToSaveInto.getParentFile() == null) {

//leave it alone, it's a root

} else

//well, it didn't, not completely, because of how Windows (feh!) handles drives, top-level folders, and sub-folders.

if (folderToSaveInto.getName().equals(folderToSaveInto.getParentFile().getName()))

folderToSaveInto = folderToSaveInto.getParentFile();


I'm not sure about that. It is clearly an OSX example, just remove "/Volumes" to test elsewhere.

Monday, November 09, 2026

Migrating OSX Monterey Stickies on an old Mac to Mac Tahoe

 I probably went about this wrong. Again.

Anyway, this post is about migrating ONE THING: the Stickies data, without doing a pile of new-sticky/copy/paste. Yeesh. This was painful last time...

Am migrating from Monterey to Tahoe. Reason: Monterey machine has been crashing a bunch. HARD crash that reboots. i.e., time for a new machine.

Found a great one on EBay, 60 miles away, so I drove to pick it up.

This project doesn't have a standard export/import behavior, which is stupid.

So where are the Stickies notes on Monterey?

~/Library/Containers/Stickies/Data/Library/Stickies/*


You need to archive that folder. OSX really does not want to let you see that folder.

Get to Finder, then command-shift-G, enter Library, which gets you started. You can find Containers in the list, then Stickies, etc.

Click right on "Stickies" and then "Compress Stickies" in the popup. Now drag the resulting Stickies.zip files over to a location like "DropBox" where you can do a casual share.

Copy that zip to the new machine (Tahoe, in my case).

cd ~/Library/Containers/com.apple.Stickies/Data/Library

(I don't know why that background turned black there)

copy Stickies.zip into the current folder, then

unzip Stickies.zip

Now you can open the Stickies app and poof! All your stickies notes are back, just like you had them before.