Example usage for java.awt Menu Menu

List of usage examples for java.awt Menu Menu

Introduction

In this page you can find the example usage for java.awt Menu Menu.

Prototype

public Menu(String label) throws HeadlessException 

Source Link

Document

Constructs a new menu with the specified label.

Usage

From source file:ExTransform.java

public void initialize(String[] args) {
    // Initialize the window, menubar, etc.
    super.initialize(args);
    exampleFrame.setTitle("Java 3D Transform Example");

    // Add a menu to select among transform options

    Menu mt = new Menu("Transform");
    switchMenu = new CheckboxMenuItem[options.length];
    for (int i = 0; i < options.length; i++) {
        switchMenu[i] = new CheckboxMenuItem(options[i].name);
        switchMenu[i].addItemListener(this);
        switchMenu[i].setState(false);/*www. j av a2  s  .c o  m*/
        mt.add(switchMenu[i]);
    }
    exampleMenuBar.add(mt);

    currentSwitch = 0;
    switchMenu[currentSwitch].setState(true);
}

From source file:ExBackgroundColor.java

public void initialize(String[] args) {
    // Initialize the window, menubar, etc.
    super.initialize(args);
    exampleFrame.setTitle("Java 3D Background Color Example");

    ////from   ww  w .jav a2 s .c o m
    //  Add a menubar menu to change node parameters
    //    Color -->
    //

    Menu m = new Menu("Background");

    colorMenu = new CheckboxMenu("Color", colors, currentColor, this);
    m.add(colorMenu);

    exampleMenuBar.add(m);
}

From source file:ExBackgroundImage.java

public void initialize(String[] args) {
    // Initialize the window, menubar, etc.
    super.initialize(args);
    exampleFrame.setTitle("Java 3D Background Image Example");

    ///*from ww w  .  j  a v a2 s.c  o m*/
    //  Add a menubar menu to change node parameters
    //    Image -->
    //

    Menu m = new Menu("Background");

    imageMenu = new CheckboxMenu("Image", images, currentImage, this);
    m.add(imageMenu);

    exampleMenuBar.add(m);

    // Preload the background images
    //   Use the texture loading utility to read in the image
    //   files and process them into an ImageComponent2D
    //   for use in the Background node.
    if (debug)
        System.err.println("  background images...");
    TextureLoader texLoader = null;
    String value = null;
    imageComponents = new ImageComponent2D[images.length];

    for (int i = 0; i < images.length; i++) {
        value = (String) images[i].value;
        if (value == null) {
            imageComponents[i] = null;
            continue;
        }
        texLoader = new TextureLoader(value, this);
        imageComponents[i] = texLoader.getImage();
        // Component could be null if image couldn't be loaded
    }
}

From source file:ExLightScope.java

public void initialize(String[] args) {
    // Initialize the window, menubar, etc.
    super.initialize(args);
    exampleFrame.setTitle("Java 3D Light Scoping Example");

    ///*from  w  ww.ja v a2  s .co m*/
    //  Add a menubar menu to change node parameters
    //    Use bounding leaf
    //

    Menu m = new Menu("DirectionalLights");

    light1OnOffMenu = new CheckboxMenuItem("Red light with sphere set 1 scope", light1OnOff);
    light1OnOffMenu.addItemListener(this);
    m.add(light1OnOffMenu);

    light2OnOffMenu = new CheckboxMenuItem("Blue light with sphere set 2 scope", light2OnOff);
    light2OnOffMenu.addItemListener(this);
    m.add(light2OnOffMenu);

    light3OnOffMenu = new CheckboxMenuItem("White light with universal scope", light3OnOff);
    light3OnOffMenu.addItemListener(this);
    m.add(light3OnOffMenu);

    exampleMenuBar.add(m);
}

From source file:Unicode.java

/** Convenience routine to make a Menu */
public Menu mkMenu(ResourceBundle b, String name) {
    String menuLabel;/*from  w  w w  .  ja  v  a 2  s  .  c  o  m*/
    try {
        menuLabel = b.getString(name + ".label");
    } catch (MissingResourceException e) {
        menuLabel = name;
    }
    return new Menu(menuLabel);
}

From source file:ExLightBounds.java

public void initialize(String[] args) {
    // Initialize the window, menubar, etc.
    super.initialize(args);
    exampleFrame.setTitle("Java 3D Light Bounds Example");

    ///*from w w w  . j  a  va  2 s.  co m*/
    //  Add a menubar menu to change node parameters
    //    Use bounding leaf
    //    Bounds size -->
    //    Bounding leaf position -->
    //

    Menu m = new Menu("DirectionalLight");

    boundingLeafOnOffMenu = new CheckboxMenuItem("Use bounding leaf", boundingLeafOnOff);
    boundingLeafOnOffMenu.addItemListener(this);
    m.add(boundingLeafOnOffMenu);

    boundsMenu = new CheckboxMenu("Bounds size", bounds, currentBounds, this);
    m.add(boundsMenu);

    positionMenu = new CheckboxMenu("Bounding leaf position", positions, currentPosition, this);
    if (boundingLeafOnOff)
        // Bounding leaf on
        positionMenu.setEnabled(true);
    else
        // Bounding leaf off
        positionMenu.setEnabled(false);
    m.add(positionMenu);

    exampleMenuBar.add(m);
}

From source file:ExExponentialFog.java

public void initialize(String[] args) {
    // Initialize the window, menubar, etc.
    super.initialize(args);
    exampleFrame.setTitle("Java 3D ExponentialFog Example");

    ////from   www. ja v  a2 s. c o  m
    //  Add a menubar menu to change node parameters
    //    Coupled background color
    //    Background color -->
    //    Fog color -->
    //    Fog density -->
    //

    Menu m = new Menu("ExponentialFog");

    coupledBackgroundOnOffMenu = new CheckboxMenuItem("Couple background color", coupledBackgroundOnOff);
    coupledBackgroundOnOffMenu.addItemListener(this);
    m.add(coupledBackgroundOnOffMenu);

    backgroundColorMenu = new CheckboxMenu("Background color", colors, currentBackgroundColor, this);
    m.add(backgroundColorMenu);
    backgroundColorMenu.setEnabled(!coupledBackgroundOnOff);

    colorMenu = new CheckboxMenu("Fog color", colors, currentColor, this);
    m.add(colorMenu);

    densityMenu = new CheckboxMenu("Fog density", densities, currentDensity, this);
    m.add(densityMenu);

    exampleMenuBar.add(m);
}

From source file:MonitorSaurausRex.MainMenu.java

private static void createAndShowGUI() {
    //Check the SystemTray support
    if (!SystemTray.isSupported()) {
        System.out.println("SystemTray is not supported");
        return;//from www.  j  a v  a2s  . c om
    }
    final PopupMenu popup = new PopupMenu();
    final TrayIcon trayIcon = new TrayIcon(createImage("Logo.png", "tray icon"));
    final SystemTray tray = SystemTray.getSystemTray();
    trayIcon.setImageAutoSize(true);
    // Create a popup menu components
    MenuItem aboutItem = new MenuItem("About");
    CheckboxMenuItem cb1 = new CheckboxMenuItem("Menu");
    CheckboxMenuItem cb2 = new CheckboxMenuItem("Quarantine!");
    Menu displayMenu = new Menu("Actions");
    MenuItem errorItem = new MenuItem("Cut Connections");
    MenuItem warningItem = new MenuItem("Send Reports");
    MenuItem infoItem = new MenuItem("Kill Processes");
    MenuItem exitItem = new MenuItem("Exit");

    //Add components to popup menu
    popup.add(aboutItem);
    popup.addSeparator();
    popup.add(cb1);
    popup.add(cb2);
    popup.addSeparator();
    popup.add(displayMenu);
    displayMenu.add(errorItem);
    displayMenu.add(warningItem);
    displayMenu.add(infoItem);
    popup.add(exitItem);

    trayIcon.setPopupMenu(popup);

    try {
        tray.add(trayIcon);
    } catch (AWTException e) {
        System.out.println("TrayIcon could not be added.");
        return;
    }

    trayIcon.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null, "This dialog box is run from System Tray");
        }
    });

    aboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null,
                    "MonitorSaurausRex, Designed for sec203 group project. The program was designed to be piece of software to combat Ransomware"
                            + " in a corparate enviroment. The Project was created by Luke Barlow, Dayan Patel, Rob Shire and Sian Skiggs.");
        }
    });

    cb1.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            int cb1Id = e.getStateChange();
            trayIcon.setImageAutoSize(true);
            if (cb1Id == ItemEvent.SELECTED) {
                trayIcon.setImageAutoSize(true);
            } else {
                trayIcon.setImageAutoSize(true);
            }
        }
    });

    cb2.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            int cb2Id = e.getStateChange();
            if (cb2Id == ItemEvent.SELECTED) {
                trayIcon.setToolTip("Sun TrayIcon");
            } else {
                trayIcon.setToolTip(null);
            }
        }
    });

    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            MenuItem item = (MenuItem) e.getSource();
            //TrayIcon.MessageType type = null;
            System.out.println(item.getLabel());
            if ("Error".equals(item.getLabel())) {
                //type = TrayIcon.MessageType.ERROR;
                trayIcon.displayMessage("Sun TrayIcon Demo", "This is an error message",
                        TrayIcon.MessageType.ERROR);

            } else if ("Warning".equals(item.getLabel())) {
                //type = TrayIcon.MessageType.WARNING;
                trayIcon.displayMessage("Sun TrayIcon Demo", "This is a warning message",
                        TrayIcon.MessageType.WARNING);

            } else if ("Info".equals(item.getLabel())) {
                //type = TrayIcon.MessageType.INFO;
                trayIcon.displayMessage("Sun TrayIcon Demo", "This is an info message",
                        TrayIcon.MessageType.INFO);

            } else if ("None".equals(item.getLabel())) {
                //type = TrayIcon.MessageType.NONE;
                trayIcon.displayMessage("Sun TrayIcon Demo", "This is an ordinary message",
                        TrayIcon.MessageType.NONE);
            }
        }
    };

    errorItem.addActionListener(listener);
    warningItem.addActionListener(listener);
    infoItem.addActionListener(listener);

    exitItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tray.remove(trayIcon);
            System.exit(0);
        }
    });
}

From source file:ExLinearFog.java

public void initialize(String[] args) {
    // Initialize the window, menubar, etc.
    super.initialize(args);
    exampleFrame.setTitle("Java 3D LinearFog Example");

    ///*from w ww.j  av a  2 s  . c om*/
    //  Add a menubar menu to change node parameters
    //    Coupled background color
    //    Background color -->
    //    Fog color -->
    //    Fog front distance -->
    //    Fog back distance -->
    //

    Menu m = new Menu("LinearFog");

    coupledBackgroundOnOffMenu = new CheckboxMenuItem("Couple background color", coupledBackgroundOnOff);
    coupledBackgroundOnOffMenu.addItemListener(this);
    m.add(coupledBackgroundOnOffMenu);

    backgroundColorMenu = new CheckboxMenu("Background color", colors, currentBackgroundColor, this);
    m.add(backgroundColorMenu);
    backgroundColorMenu.setEnabled(!coupledBackgroundOnOff);

    colorMenu = new CheckboxMenu("Fog color", colors, currentColor, this);
    m.add(colorMenu);

    frontMenu = new CheckboxMenu("Fog front distance", fronts, currentFront, this);
    m.add(frontMenu);

    backMenu = new CheckboxMenu("Fog back distance", backs, currentBack, this);
    m.add(backMenu);

    exampleMenuBar.add(m);
}

From source file:de.codesourcery.gittimelapse.MyFrame.java

private MenuBar createMenuBar() {
    final MenuBar menuBar = new MenuBar();
    final Menu menu = new Menu("File");

    final MenuItem item1 = new MenuItem("About...");
    item1.addActionListener(new ActionListener() {

        @Override/*from w  w  w .j a  v  a  2s . c  om*/
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null, "GIT timelapse V0.1\n\n(C) 2014 tobias.gierke@code-sourcery.de",
                    "About", JOptionPane.PLAIN_MESSAGE);
        }
    });

    menu.add(item1);

    final MenuItem item2 = new MenuItem("Quit");
    item2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });

    menu.add(item2);
    menuBar.add(menu);
    return menuBar;
}