Example usage for java.awt Menu addSeparator

List of usage examples for java.awt Menu addSeparator

Introduction

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

Prototype

public void addSeparator() 

Source Link

Document

Adds a separator line, or a hypen, to the menu at the current position.

Usage

From source file:ExText.java

/**
 * Builds the example AWT Frame menubar. Standard menus and their options
 * are added. Applications that subclass this class should build their
 * menubar additions within their initialize method.
 * /*from  www .  ja  v  a  2s.  c o  m*/
 * @return a MenuBar for the AWT Frame
 */
private MenuBar buildMenuBar() {
    // Build the menubar
    MenuBar menuBar = new MenuBar();

    // File menu
    Menu m = new Menu("File");
    m.addActionListener(this);

    m.add("Exit");

    menuBar.add(m);

    // View menu
    m = new Menu("View");
    m.addActionListener(this);

    m.add("Reset view");

    m.addSeparator();

    walkMenuItem = new CheckboxMenuItem("Walk");
    walkMenuItem.addItemListener(this);
    m.add(walkMenuItem);

    examineMenuItem = new CheckboxMenuItem("Examine");
    examineMenuItem.addItemListener(this);
    m.add(examineMenuItem);

    if (navigationType == Walk) {
        walkMenuItem.setState(true);
        examineMenuItem.setState(false);
    } else {
        walkMenuItem.setState(false);
        examineMenuItem.setState(true);
    }

    m.addSeparator();

    headlightMenuItem = new CheckboxMenuItem("Headlight on/off");
    headlightMenuItem.addItemListener(this);
    headlightMenuItem.setState(headlightOnOff);
    m.add(headlightMenuItem);

    menuBar.add(m);

    return menuBar;
}

From source file:ExBluePrint.java

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

    ///*from  w  w  w. j  a  va 2s . c  o m*/
    //  Add a menubar menu to change parameters
    //    (images)
    //    --------
    //    Wireframe
    //    Shaded
    //

    // Add a menu to select among background and shading options
    Menu m = new Menu("Options");

    imageMenu = new CheckboxMenuItem[images.length];
    for (int i = 0; i < images.length; i++) {
        imageMenu[i] = new CheckboxMenuItem(images[i].name);
        imageMenu[i].addItemListener(this);
        imageMenu[i].setState(false);
        m.add(imageMenu[i]);
    }
    imageMenu[currentImage].setState(true);

    m.addSeparator();

    appearanceMenu = new CheckboxMenuItem[2];
    appearanceMenu[0] = new CheckboxMenuItem("Wireframe");
    appearanceMenu[0].addItemListener(this);
    appearanceMenu[0].setState(false);
    m.add(appearanceMenu[0]);

    appearanceMenu[1] = new CheckboxMenuItem("Shaded");
    appearanceMenu[1].addItemListener(this);
    appearanceMenu[1].setState(true);
    m.add(appearanceMenu[1]);

    exampleMenuBar.add(m);

    // Preload background images
    TextureLoader texLoader = null;
    imageComponents = new ImageComponent2D[images.length];
    String value = null;
    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();
    }
}