Java example: JMenuBar + KeyStroke + AbstractAction

As a brief note, here’s some source code that I used to create a JMenuBar in a Java application. First, I defined some fields in my main class:

private static final KeyStroke fileOpenKeystroke = KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.META_MASK);
private Action fileOpenAction;
private JMenuBar menuBar;

Later in the same class I defined this method:

How to type smart quotes on Ubuntu Linux

Table of Contents1 - Background: Switching from MacOS to Ubuntu2 - Background: AltGr and Compose keys3 - Step 1: Figure out what the Compose key is4 - How to type smart quotes on Ubuntu (the hard way)5 - Note: You can stop here6 - Using Ubuntu macros to make it easier7 - Mapping keystrokes to xdotool commands8 - Summary

Note: I don’t know why, but all of the images for this article have been lost. I’ll replace them when I have some free time (but free time is scarce these days).

There seem to be a few different ways to type “smart quotes” on Ubuntu Linux, including using keys (keystrokes) like AltGr and Compose. In this tutorial I’ll document an approach that works best for me: creating macros I can assign to simple keystrokes rather than having to use more-complicated keystrokes.

How to display the lock screen on an Android device emulator (keystroke)

As a quick note, if you want to show the “lock screen” on an Android device emulator, press the F7 key twice. I’m currently working on an Android notifications app, so I want to see what the notifications look like on the lock screen, and I just discovered this approach.

How to add a keystroke to a Java Swing application

If you ever need to add a keystroke to a Java Swing application (or Scala Swing), this code may help. It shows how to add the [Command][M] keystroke on a Mac OS X system to a Swing application. It makes the keystroke available in a “Window” menu:

macOS: How to put keyboard focus on the Mac menubar

For a long time I've read that you could use your Apple/Mac keyboard to access the menubar on MacOS systems using the [Control][F2] keystroke. That never actually worked, so I logically assumed that everyone else was insane.

Well, it turns out that what really happened is that silly me was using Apple keyboards ... and as I was trying to figure this out again today, I looked over at that [fn] key on the keyboard, and thought, "No, surely I wouldn't have to press that too ..."

Mac Safari shortcuts

Mac Safari shortcuts FAQ: What are the most common Mac Safari shortcuts (Mac Safari keyboard shortcuts)?

Here's a quick list of the most common Mac Safari shortcuts (Mac Safari keyboard shortcuts):

Mac Finder 'new folder' keystroke bug

While replying to a comment on an earlier Mac Finder new folder keystroke article, I found a bug in the Mac OS X Finder that I thought I'd mention here as well to make it easier for people to find. In short, the keystroke you can normally use to create a new Finder folder is:

[Shift] [Command] n