增加的菜单栏效果图如下:
eclipse 中调整到 swt的design视图下
控件区域选择Menu Controls
将Menu Bar拖动到窗口标题栏
将Cascaded Menu拖动到Menu Bar
依次将多个Menu Item加入到New SubMenu
Separator是分隔符
也可以再放入Cascaded Menu级联菜单
好友列表窗口的代码如下:
package com.swift.frame; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.FlowLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JTabbedPane; import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class FriendsDialog extends JDialog { public static void