Summary: A Java “Command Pattern” example is demonstrated.
If you've ever seen Java source code that looks like this:
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.
Continuing with the organization efforts again today, here is a collection of Java JButton tutorials and examples:
Java Swing FAQ: How do I create a menubar (and menu and menuitems) in Java?
As I was working on a Java/Swing problem last week, I was scouring through the Mac OS X Java-Dev mailing list, and along the way I ran into some really nice source code I thought I could modify into a decent Java Menubar example. After a little rewriting, here is that "Java Menubar" example.
I need to work on this JList ListSelectionListener example some more, but I thought I'd share it in its current state, in case it will help anyone get started.
JButton listener FAQ: A common Java
JButton question is "How do I add a listener to a JButton?", or the equivalent, "How can I tell when a JButton is pressed?"
JButton listener solution
In short, you typically want to add an
ActionListener to a
JButton, as shown in the following source code snipet:
Here's another one of those postings that are just here to help my bad memory. I currently travel a fair amount, work on different systems and projects, and can't remember the Java syntax for adding a Java ActionListener to a JButton, so here's a little sample code to help me remember: