JToolBar and Actions
We've improved the address book application with the addition of JTabbedPane, JTable, and (if you did the exercises) JTree. Still, something's missing.
In the early days of Java there was no Swing, and AWT didn't have a toolbar. This meant that most developers used panels, which is what I did in the address book application. I had two reasons for this: to show how JPanel and the BorderLayout layout manager work and to avoid introducing actions.
Actions
We can avoid actions no longer. Any introduction to JToolBar has to include them. I held off until now because actions are a higher abstraction than components, and I thought you should have a good grip on components first.
Think of an action as a command. An item on a menu ...
Get Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.