Mercurial > hg > release > thermostat-0.4
view dolphin/src/main/java/com/redhat/swing/laf/dolphin/showcase/MenuDemo.java @ 640:e3f026b1e200
Paint the menu bar
Replace a no-op implementation of update() with a real implementaton.
Reviewed-by: rkennke
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-September/003387.html
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Wed, 26 Sep 2012 19:36:51 -0400 |
parents | ee0b71f09846 |
children |
line wrap: on
line source
/* * Copyright 2012 Red Hat, Inc. * * This file is part of Thermostat. * * Thermostat is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2, or (at your * option) any later version. * * Thermostat is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Thermostat; see the file COPYING. If not see * <http://www.gnu.org/licenses/>. * * Linking this code with other modules is making a combined work * based on this code. Thus, the terms and conditions of the GNU * General Public License cover the whole combination. * * As a special exception, the copyright holders of this code give * you permission to link this code with independent modules to * produce an executable, regardless of the license terms of these * independent modules, and to copy and distribute the resulting * executable under terms of your choice, provided that you also * meet, for each linked independent module, the terms and conditions * of the license of that module. An independent module is a module * which is not derived from or based on this code. If you modify * this code, you may extend this exception to your version of the * library, but you are not obligated to do so. If you do not wish * to do so, delete this exception statement from your version. */ package com.redhat.swing.laf.dolphin.showcase; import java.awt.EventQueue; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import javax.swing.JFrame; import javax.swing.JMenuBar; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.KeyStroke; import javax.swing.UIManager; import com.redhat.swing.laf.dolphin.DolphinLookAndFeel; import javax.swing.JRadioButtonMenuItem; import javax.swing.JCheckBoxMenuItem; import javax.swing.JSeparator; public class MenuDemo { private JFrame frame; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel(new DolphinLookAndFeel()); MenuDemo window = new MenuDemo(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public MenuDemo() { initialize(); } /** * Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu mnNewMenu = new JMenu("New menu"); menuBar.add(mnNewMenu); mnNewMenu.addSeparator(); JMenu mnNewMenu_1 = new JMenu("New menu"); mnNewMenu.add(mnNewMenu_1); JMenuItem mntmNewMenuItem_2 = new JMenuItem("New menu item"); mnNewMenu_1.add(mntmNewMenuItem_2); JRadioButtonMenuItem rdbtnmntmNewRadioItem_1 = new JRadioButtonMenuItem("New radio item"); mnNewMenu_1.add(rdbtnmntmNewRadioItem_1); JMenuItem mntmNewMenuItem_3 = new JMenuItem("New menu item"); mnNewMenu_1.add(mntmNewMenuItem_3); JMenuItem mntmNewMenuItem = new JMenuItem("New menu item"); mntmNewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK)); mnNewMenu.add(mntmNewMenuItem); JMenuItem mntmNewMenuItem_1 = new JMenuItem("New menu item"); mnNewMenu.add(mntmNewMenuItem_1); JSeparator separator = new JSeparator(); mnNewMenu.add(separator); JRadioButtonMenuItem rdbtnmntmNewRadioItem = new JRadioButtonMenuItem("New radio item"); mnNewMenu.add(rdbtnmntmNewRadioItem); JCheckBoxMenuItem chckbxmntmNewCheckItem = new JCheckBoxMenuItem("New check item"); mnNewMenu.add(chckbxmntmNewCheckItem); JMenu mnNewMenu_2 = new JMenu("New menu"); menuBar.add(mnNewMenu_2); JMenu mnNewMenu_3 = new JMenu("New menu"); mnNewMenu_2.add(mnNewMenu_3); } }