- Swing Solutions: Java Swing and Menus
- Importing Swing Classes
- About Menus
- Menu Bars
- Popup Menus
- What's Next?
Importing Swing Classes
A quick note before we start: You are going to have to import the Swing classes into your application before you can compile and run them. Most of the Java Swing classes (including all of the ones included in these articles) are located in the javax.swing and javax.swing.event packages. You can import either specific classes or the entire packages by using one of the following commands:
// Import the entire Swing packages import javax.swing.*; import javax.swing.event.*;
Or:
// Import the Swing JMenu class import javax.swing.JMenu
Just add these statements to the beginning of your Swing applications, and you are good to go!