日期:2014-05-20 浏览次数:20781 次
public class TMenBar extends JFrame{ /** * */ private static final long serialVersionUID = -6562446575658301591L; static JMenuBar createMenuBar(){ JMenu a = new JMenu("aa"); JMenu b = new JMenu("bb"); a.add(new JMenuItem("1....")); a.add(new JMenuItem("2....")); b.add(new JMenuItem("1....")); b.add(new JMenuItem("2....")); JMenuBar bar = new JMenuBar(); bar.add(a); bar.add(b); return bar; } public static void main(String[] args) { TMenBar tb = new TMenBar(); JLayeredPane pane = tb.getRootPane().getLayeredPane(); pane.setLayout(new BorderLayout()); pane.add(createMenuBar() , BorderLayout.SOUTH); pane.add(createMenuBar() , BorderLayout.CENTER); pane.add(createMenuBar() , BorderLayout.EAST); tb.setSize(800,400); tb.setLocationRelativeTo(null); tb.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); tb.setVisible(true); } }