Java Code Examples for java.awt.MenuBar

The following are top voted examples for showing how to use java.awt.MenuBar. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenDiabetes   File: DatabaseManager.java   View source code 6 votes vote down vote up
void addMenu(MenuBar b, String name, String[] items) {

        /* It's a very poor design to encapsulate menu creation this way.
         * Can't customize the menus this way (e.g. shortcut keys,
         * mnemonics, disabling, etc. */
        Menu menu = new Menu(name);

        if (name.equals("Tools") && !TT_AVAILABLE) {

            // Terrible place to do this.  Forced to due to method design.
            menu.setEnabled(false);
        }

        addMenuItems(menu, items);
        b.add(menu);
    }
 
Example 2
Project: sstore-soft   File: DatabaseManager.java   View source code 6 votes vote down vote up
void addMenu(MenuBar b, String name, String[] items) {

        /* It's a very poor design to encapsulate menu creation this way.
         * Can't customize the menus this way (e.g. shortcut keys,
         * mnemonics, disabling, etc. */
        Menu menu = new Menu(name);

        if (name.equals("Tools") && !TT_AVAILABLE) {

            // Terrible place to do this.  Forced to due to method design.
            menu.setEnabled(false);
        }

        addMenuItems(menu, items);
        b.add(menu);
    }
 
Example 3
Project: s-store   File: DatabaseManager.java   View source code 6 votes vote down vote up
void addMenu(MenuBar b, String name, String[] items) {

        /* It's a very poor design to encapsulate menu creation this way.
         * Can't customize the menus this way (e.g. shortcut keys,
         * mnemonics, disabling, etc. */
        Menu menu = new Menu(name);

        if (name.equals("Tools") && !TT_AVAILABLE) {

            // Terrible place to do this.  Forced to due to method design.
            menu.setEnabled(false);
        }

        addMenuItems(menu, items);
        b.add(menu);
    }
 
Example 4
Project: dev-courses   File: DatabaseManager.java   View source code 6 votes vote down vote up
void addMenu(MenuBar b, String name, String[] items) {

        /* It's a very poor design to encapsulate menu creation this way.
         * Can't customize the menus this way (e.g. shortcut keys,
         * mnemonics, disabling, etc. */
        Menu menu = new Menu(name);

        if (name.equals("Tools") && !TT_AVAILABLE) {

            // Terrible place to do this.  Forced to due to method design.
            menu.setEnabled(false);
        }

        addMenuItems(menu, items);
        b.add(menu);
    }
 
Example 5
Project: parabuild-ci   File: DatabaseManager.java   View source code 6 votes vote down vote up
void addMenu(MenuBar b, String name, String[] items) {

        /* It's a very poor design to encapsulate menu creation this way.
         * Can't customize the menus this way (e.g. shortcut keys,
         * mnemonics, disabling, etc. */
        Menu menu = new Menu(name);

        if (name.equals("Tools") && !TT_AVAILABLE) {

            // Terrible place to do this.  Forced to due to method design.
            menu.setEnabled(false);
        }

        addMenuItems(menu, items);
        b.add(menu);
    }
 
Example 6
Project: parabuild-ci   File: DatabaseManager.java   View source code 6 votes vote down vote up
void addMenu(MenuBar b, String name, String[] items) {

        /* It's a very poor design to encapsulate menu creation this way.
         * Can't customize the menus this way (e.g. shortcut keys,
         * mnemonics, disabling, etc. */
        Menu menu = new Menu(name);

        if (name.equals("Tools") && !TT_AVAILABLE) {

            // Terrible place to do this.  Forced to due to method design.
            menu.setEnabled(false);
        }

        addMenuItems(menu, items);
        b.add(menu);
    }
 
Example 7
Project: parabuild-ci   File: DatabaseManager.java   View source code 6 votes vote down vote up
/**
 * Method declaration
 *
 *
 * @param b
 * @param name
 * @param items
 */
void addMenu(MenuBar b, String name, String[] items) {

    /* It's a very poor design to encapsulate menu creation this way.
     * Can't customize the menus this way (e.g. shortcut keys,
     * mnemonics, disabling, etc. */
    Menu menu = new Menu(name);

    if (name.equals("Tools") && !TT_AVAILABLE) {

        // Terrible place to do this.  Forced to due to method design.
        menu.setEnabled(false);
    }

    addMenuItems(menu, items);
    b.add(menu);
}
 
Example 8
Project: jdk8u-jdk   File: CMenu.java   View source code 6 votes vote down vote up
@Override
long createModel() {
    CMenuComponent parent = (CMenuComponent)
        LWCToolkit.targetToPeer(getTarget().getParent());

    if (parent instanceof CMenu) {
        return parent.executeGet(this::nativeCreateSubMenu);
    }
    if (parent instanceof CMenuBar) {
        MenuBar parentContainer = (MenuBar)getTarget().getParent();
        boolean isHelpMenu = parentContainer.getHelpMenu() == getTarget();
        int insertionLocation = ((CMenuBar)parent).getNextInsertionIndex();
        return parent.executeGet(ptr -> nativeCreateMenu(ptr, isHelpMenu,
                                                         insertionLocation));
    }
    throw new InternalError("Parent must be CMenu or CMenuBar");
}
 
Example 9
Project: jdk8u-jdk   File: RemoveHelpMenu.java   View source code 6 votes vote down vote up
private static void test3(final MenuBar menuBar) {
    final Menu helpMenu1 = new Menu("Help Menu1");
    final Menu helpMenu2 = new Menu("Help Menu2");
    menuBar.setHelpMenu(helpMenu1);
    checkCurrentMenu(menuBar, helpMenu1);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu1, true);
    checkHelpMenu(helpMenu2, false);

    menuBar.setHelpMenu(helpMenu2);
    checkCurrentMenu(menuBar, helpMenu2);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu1, false);
    checkHelpMenu(helpMenu2, true);

    menuBar.remove(helpMenu2);
    checkCurrentMenu(menuBar, null);
    checkMenuCount(menuBar, 0);
    checkHelpMenu(helpMenu1, false);
    checkHelpMenu(helpMenu2, false);
}
 
Example 10
Project: openjdk-jdk10   File: CMenu.java   View source code 6 votes vote down vote up
@Override
long createModel() {
    CMenuComponent parent = (CMenuComponent)
        LWCToolkit.targetToPeer(getTarget().getParent());

    if (parent instanceof CMenu) {
        return parent.executeGet(this::nativeCreateSubMenu);
    }
    if (parent instanceof CMenuBar) {
        MenuBar parentContainer = (MenuBar)getTarget().getParent();
        boolean isHelpMenu = parentContainer.getHelpMenu() == getTarget();
        int insertionLocation = ((CMenuBar)parent).getNextInsertionIndex();
        return parent.executeGet(ptr -> nativeCreateMenu(ptr, isHelpMenu,
                                                         insertionLocation));
    }
    throw new InternalError("Parent must be CMenu or CMenuBar");
}
 
Example 11
Project: openjdk-jdk10   File: RemoveHelpMenu.java   View source code 6 votes vote down vote up
private static void test3(final MenuBar menuBar) {
    final Menu helpMenu1 = new Menu("Help Menu1");
    final Menu helpMenu2 = new Menu("Help Menu2");
    menuBar.setHelpMenu(helpMenu1);
    checkCurrentMenu(menuBar, helpMenu1);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu1, true);
    checkHelpMenu(helpMenu2, false);

    menuBar.setHelpMenu(helpMenu2);
    checkCurrentMenu(menuBar, helpMenu2);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu1, false);
    checkHelpMenu(helpMenu2, true);

    menuBar.remove(helpMenu2);
    checkCurrentMenu(menuBar, null);
    checkMenuCount(menuBar, 0);
    checkHelpMenu(helpMenu1, false);
    checkHelpMenu(helpMenu2, false);
}
 
Example 12
Project: openjdk9   File: RemoveHelpMenu.java   View source code 6 votes vote down vote up
private static void test3(final MenuBar menuBar) {
    final Menu helpMenu1 = new Menu("Help Menu1");
    final Menu helpMenu2 = new Menu("Help Menu2");
    menuBar.setHelpMenu(helpMenu1);
    checkCurrentMenu(menuBar, helpMenu1);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu1, true);
    checkHelpMenu(helpMenu2, false);

    menuBar.setHelpMenu(helpMenu2);
    checkCurrentMenu(menuBar, helpMenu2);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu1, false);
    checkHelpMenu(helpMenu2, true);

    menuBar.remove(helpMenu2);
    checkCurrentMenu(menuBar, null);
    checkMenuCount(menuBar, 0);
    checkHelpMenu(helpMenu1, false);
    checkHelpMenu(helpMenu2, false);
}
 
Example 13
Project: jdk8u_jdk   File: CMenu.java   View source code 6 votes vote down vote up
@Override
long createModel() {
    CMenuComponent parent = (CMenuComponent)
        LWCToolkit.targetToPeer(getTarget().getParent());

    if (parent instanceof CMenu) {
        return parent.executeGet(this::nativeCreateSubMenu);
    }
    if (parent instanceof CMenuBar) {
        MenuBar parentContainer = (MenuBar)getTarget().getParent();
        boolean isHelpMenu = parentContainer.getHelpMenu() == getTarget();
        int insertionLocation = ((CMenuBar)parent).getNextInsertionIndex();
        return parent.executeGet(ptr -> nativeCreateMenu(ptr, isHelpMenu,
                                                         insertionLocation));
    }
    throw new InternalError("Parent must be CMenu or CMenuBar");
}
 
Example 14
Project: jdk8u_jdk   File: RemoveHelpMenu.java   View source code 6 votes vote down vote up
private static void test3(final MenuBar menuBar) {
    final Menu helpMenu1 = new Menu("Help Menu1");
    final Menu helpMenu2 = new Menu("Help Menu2");
    menuBar.setHelpMenu(helpMenu1);
    checkCurrentMenu(menuBar, helpMenu1);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu1, true);
    checkHelpMenu(helpMenu2, false);

    menuBar.setHelpMenu(helpMenu2);
    checkCurrentMenu(menuBar, helpMenu2);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu1, false);
    checkHelpMenu(helpMenu2, true);

    menuBar.remove(helpMenu2);
    checkCurrentMenu(menuBar, null);
    checkMenuCount(menuBar, 0);
    checkHelpMenu(helpMenu1, false);
    checkHelpMenu(helpMenu2, false);
}
 
Example 15
Project: lookaside_java-1.8.0-openjdk   File: CMenu.java   View source code 6 votes vote down vote up
@Override
long createModel() {
    CMenuComponent parent = (CMenuComponent)
        LWCToolkit.targetToPeer(getTarget().getParent());

    if (parent instanceof CMenu) {
        return parent.executeGet(this::nativeCreateSubMenu);
    }
    if (parent instanceof CMenuBar) {
        MenuBar parentContainer = (MenuBar)getTarget().getParent();
        boolean isHelpMenu = parentContainer.getHelpMenu() == getTarget();
        int insertionLocation = ((CMenuBar)parent).getNextInsertionIndex();
        return parent.executeGet(ptr -> nativeCreateMenu(ptr, isHelpMenu,
                                                         insertionLocation));
    }
    throw new InternalError("Parent must be CMenu or CMenuBar");
}
 
Example 16
Project: lookaside_java-1.8.0-openjdk   File: RemoveHelpMenu.java   View source code 6 votes vote down vote up
private static void test3(final MenuBar menuBar) {
    final Menu helpMenu1 = new Menu("Help Menu1");
    final Menu helpMenu2 = new Menu("Help Menu2");
    menuBar.setHelpMenu(helpMenu1);
    checkCurrentMenu(menuBar, helpMenu1);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu1, true);
    checkHelpMenu(helpMenu2, false);

    menuBar.setHelpMenu(helpMenu2);
    checkCurrentMenu(menuBar, helpMenu2);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu1, false);
    checkHelpMenu(helpMenu2, true);

    menuBar.remove(helpMenu2);
    checkCurrentMenu(menuBar, null);
    checkMenuCount(menuBar, 0);
    checkHelpMenu(helpMenu1, false);
    checkHelpMenu(helpMenu2, false);
}
 
Example 17
Project: javify   File: GtkMenuBarPeer.java   View source code 6 votes vote down vote up
/**
 * Adds a help menu to this MenuBar. Gnome styleguides say the help
 * menu is just the last item in the menubar (they are NOT right
 * justified).
 */
public void addHelpMenu (Menu menu)
{
  if (hasHelpMenu)
    {
      // Remove the (help) menu, which is after all the other items.
      delMenu(((MenuBar) awtWidget).getMenuCount());
      hasHelpMenu = false;
    }

  if (menu != null)
    {
      addMenu(menu);
      hasHelpMenu = true;
    }
}
 
Example 18
Project: javify   File: QtFramePeer.java   View source code 6 votes vote down vote up
public void setMenuBar(MenuBar mb)
{
  if( mb != null )
    {
      QtMenuBarPeer mbpeer = (QtMenuBarPeer)mb.getPeer();
      if( mbpeer == null )
        {
          mb.addNotify();
          mbpeer = (QtMenuBarPeer)mb.getPeer();
          if( mbpeer == null )
            throw new IllegalStateException("No menu bar peer.");
        }
      mbpeer.addMenus();
      setMenu( mbpeer );
    }
  else
    setMenu( null );
}
 
Example 19
Project: jvm-stm   File: GtkMenuBarPeer.java   View source code 6 votes vote down vote up
/**
 * Adds a help menu to this MenuBar. Gnome styleguides say the help
 * menu is just the last item in the menubar (they are NOT right
 * justified).
 */
public void addHelpMenu (Menu menu)
{
  if (hasHelpMenu)
    {
      // Remove the (help) menu, which is after all the other items.
      delMenu(((MenuBar) awtWidget).getMenuCount());
      hasHelpMenu = false;
    }

  if (menu != null)
    {
      addMenu(menu);
      hasHelpMenu = true;
    }
}
 
Example 20
Project: jvm-stm   File: QtFramePeer.java   View source code 6 votes vote down vote up
public void setMenuBar(MenuBar mb)
 {
   if( mb != null )
     {
QtMenuBarPeer mbpeer = (QtMenuBarPeer)mb.getPeer();
if( mbpeer == null )
  {
    mb.addNotify();
    mbpeer = (QtMenuBarPeer)mb.getPeer();
    if( mbpeer == null )
      throw new IllegalStateException("No menu bar peer.");
  }
mbpeer.addMenus();
setMenu( mbpeer );
     } 
   else
     setMenu( null );
 }
 
Example 21
Project: VoltDB   File: DatabaseManager.java   View source code 6 votes vote down vote up
void addMenu(MenuBar b, String name, String[] items) {

        /* It's a very poor design to encapsulate menu creation this way.
         * Can't customize the menus this way (e.g. shortcut keys,
         * mnemonics, disabling, etc. */
        Menu menu = new Menu(name);

        if (name.equals("Tools") && !TT_AVAILABLE) {

            // Terrible place to do this.  Forced to due to method design.
            menu.setEnabled(false);
        }

        addMenuItems(menu, items);
        b.add(menu);
    }
 
Example 22
Project: Pegasus   File: DatabaseManager.java   View source code 6 votes vote down vote up
void addMenu(MenuBar b, String name, String[] items) {

        /* It's a very poor design to encapsulate menu creation this way.
         * Can't customize the menus this way (e.g. shortcut keys,
         * mnemonics, disabling, etc. */
        Menu menu = new Menu(name);

        if (name.equals("Tools") && !TT_AVAILABLE) {

            // Terrible place to do this.  Forced to due to method design.
            menu.setEnabled(false);
        }

        addMenuItems(menu, items);
        b.add(menu);
    }
 
Example 23
Project: JamVM-PH   File: GtkMenuBarPeer.java   View source code 6 votes vote down vote up
/**
 * Adds a help menu to this MenuBar. Gnome styleguides say the help
 * menu is just the last item in the menubar (they are NOT right
 * justified).
 */
public void addHelpMenu (Menu menu)
{
  if (hasHelpMenu)
    {
      // Remove the (help) menu, which is after all the other items.
      delMenu(((MenuBar) awtWidget).getMenuCount());
      hasHelpMenu = false;
    }

  if (menu != null)
    {
      addMenu(menu);
      hasHelpMenu = true;
    }
}
 
Example 24
Project: JamVM-PH   File: QtFramePeer.java   View source code 6 votes vote down vote up
public void setMenuBar(MenuBar mb)
 {
   if( mb != null )
     {
QtMenuBarPeer mbpeer = (QtMenuBarPeer)mb.getPeer();
if( mbpeer == null )
  {
    mb.addNotify();
    mbpeer = (QtMenuBarPeer)mb.getPeer();
    if( mbpeer == null )
      throw new IllegalStateException("No menu bar peer.");
  }
mbpeer.addMenus();
setMenu( mbpeer );
     } 
   else
     setMenu( null );
 }
 
Example 25
Project: classpath   File: GtkMenuBarPeer.java   View source code 6 votes vote down vote up
/**
 * Adds a help menu to this MenuBar. Gnome styleguides say the help
 * menu is just the last item in the menubar (they are NOT right
 * justified).
 */
public void addHelpMenu (Menu menu)
{
  if (hasHelpMenu)
    {
      // Remove the (help) menu, which is after all the other items.
      delMenu(((MenuBar) awtWidget).getMenuCount());
      hasHelpMenu = false;
    }

  if (menu != null)
    {
      addMenu(menu);
      hasHelpMenu = true;
    }
}
 
Example 26
Project: classpath   File: QtFramePeer.java   View source code 6 votes vote down vote up
public void setMenuBar(MenuBar mb)
{
  if( mb != null )
    {
      QtMenuBarPeer mbpeer = (QtMenuBarPeer)mb.getPeer();
      if( mbpeer == null )
        {
          mb.addNotify();
          mbpeer = (QtMenuBarPeer)mb.getPeer();
          if( mbpeer == null )
            throw new IllegalStateException("No menu bar peer.");
        }
      mbpeer.addMenus();
      setMenu( mbpeer );
    }
  else
    setMenu( null );
}
 
Example 27
Project: Mobile-Network-LTE   File: DatabaseManager.java   View source code 6 votes vote down vote up
void addMenu(MenuBar b, String name, String[] items) {

        /* It's a very poor design to encapsulate menu creation this way.
         * Can't customize the menus this way (e.g. shortcut keys,
         * mnemonics, disabling, etc. */
        Menu menu = new Menu(name);

        if (name.equals("Tools") && !TT_AVAILABLE) {

            // Terrible place to do this.  Forced to due to method design.
            menu.setEnabled(false);
        }

        addMenuItems(menu, items);
        b.add(menu);
    }
 
Example 28
Project: jago   File: OpenPartnerFrame.java   View source code 6 votes vote down vote up
public OpenPartnerFrame (Go go)
{
	super(Global.resourceString("Open_Partners"));
	G = go;
	MenuBar mb = new MenuBar();
	setMenuBar(mb);
	Menu m = new MyMenu(Global.resourceString("Options"));
	m.add(new MenuItemAction(this, Global.resourceString("Close")));
	mb.add(m);
	setLayout(new BorderLayout());
	L = new java.awt.List();
	L.setFont(Global.SansSerif);
	refresh();
	add("Center", L);
	JPanel bp = new MyPanel();
	bp.add(new ButtonAction(this, Global.resourceString("Connect")));
	bp.add(new ButtonAction(this, Global.resourceString("Refresh")));
	bp.add(new MyLabel(" "));
	bp.add(new ButtonAction(this, Global.resourceString("Close")));
	add("South", bp);
	Global.setwindow(this, "openpartner", 300, 200);
	seticon("ijago.gif");
	setVisible(true);
	OPFU = new OpenPartnerFrameUpdate(this);
}
 
Example 29
Project: OpenJSharp   File: XFramePeer.java   View source code 5 votes vote down vote up
public void setMenuBar(MenuBar mb) {
    // state_lock should always be the second after awt_lock
    XToolkit.awtLock();
    try {
        synchronized(getStateLock()) {
            if (mb == menubar) return;
            if (mb == null) {
                if (menubar != null) {
                    menubarPeer.xSetVisible(false);
                    menubar = null;
                    menubarPeer.dispose();
                    menubarPeer = null;
                }
            } else {
                menubar = mb;
                menubarPeer = (XMenuBarPeer) mb.getPeer();
                if (menubarPeer != null) {
                    menubarPeer.init((Frame)target);
                }
            }
        }
    } finally {
        XToolkit.awtUnlock();
    }

    reshapeMenubarPeer();
}
 
Example 30
Project: parabuild-ci   File: QueryTool.java   View source code 5 votes vote down vote up
/**
 * Method declaration
 *
 *
 * @param arg
 */
public static void main(String arg[]) {

    fMain = new Frame("Query Tool");

    QueryTool q = new QueryTool();

    q.bApplication = true;

    for (int i = 0; i < arg.length; i++) {
        String p = arg[i];

        if (p.equals("-?")) {
            printHelp();
        }

        if (p.charAt(0) == '-') {
            pProperties.put(p.substring(1), arg[i + 1]);

            i++;
        }
    }

    q.init();
    q.start();
    fMain.add("Center", q);

    MenuBar menu = new MenuBar();
    Menu    file = new Menu("File");

    file.add("Exit");
    file.addActionListener(q);
    menu.add(file);
    fMain.setMenuBar(menu);
    fMain.setSize(500, 400);
    fMain.show();
    fMain.addWindowListener(q);
}
 
Example 31
Project: parabuild-ci   File: QueryTool.java   View source code 5 votes vote down vote up
/**
 * Method declaration
 *
 *
 * @param arg
 */
public static void main(String[] arg) {

    fMain = new Frame("Query Tool");

    QueryTool q = new QueryTool();

    q.bApplication = true;

    for (int i = 0; i < arg.length; i++) {
        String p = arg[i];

        if (p.equals("-?")) {
            printHelp();
        }

        if (p.charAt(0) == '-') {
            pProperties.put(p.substring(1), arg[i + 1]);

            i++;
        }
    }

    q.init();
    q.start();
    fMain.add("Center", q);

    MenuBar menu = new MenuBar();
    Menu    file = new Menu("File");

    file.add("Exit");
    file.addActionListener(q);
    menu.add(file);
    fMain.setMenuBar(menu);
    fMain.setSize(500, 400);
    fMain.show();
    fMain.addWindowListener(q);
}
 
Example 32
Project: parabuild-ci   File: QueryTool.java   View source code 5 votes vote down vote up
/**
 * Method declaration
 *
 *
 * @param arg
 */
public static void main(String[] arg) {

    fMain = new Frame("Query Tool");

    QueryTool q = new QueryTool();

    q.bApplication = true;

    for (int i = 0; i < arg.length; i++) {
        String p = arg[i];

        if (p.equals("-?")) {
            printHelp();
        }

        if (p.charAt(0) == '-') {
            pProperties.put(p.substring(1), arg[i + 1]);

            i++;
        }
    }

    q.init();
    q.start();
    fMain.add("Center", q);

    MenuBar menu = new MenuBar();
    Menu    file = new Menu("File");

    file.add("Exit");
    file.addActionListener(q);
    menu.add(file);
    fMain.setMenuBar(menu);
    fMain.setSize(500, 400);
    fMain.show();
    fMain.addWindowListener(q);
}
 
Example 33
Project: parabuild-ci   File: QueryTool.java   View source code 5 votes vote down vote up
/**
 * Method declaration
 *
 *
 * @param arg
 */
public static void main(String[] arg) {

    fMain = new Frame("Query Tool");

    QueryTool q = new QueryTool();

    q.bApplication = true;

    for (int i = 0; i < arg.length; i++) {
        String p = arg[i];

        if (p.equals("-?")) {
            printHelp();
        }

        if (p.charAt(0) == '-') {
            pProperties.put(p.substring(1), arg[i + 1]);

            i++;
        }
    }

    q.init();
    q.start();
    fMain.add("Center", q);

    MenuBar menu = new MenuBar();
    Menu    file = new Menu("File");

    file.add("Exit");
    file.addActionListener(q);
    menu.add(file);
    fMain.setMenuBar(menu);
    fMain.setSize(500, 400);
    fMain.show();
    fMain.addWindowListener(q);
}
 
Example 34
Project: jdk8u-jdk   File: XFramePeer.java   View source code 5 votes vote down vote up
public void setMenuBar(MenuBar mb) {
    // state_lock should always be the second after awt_lock
    XToolkit.awtLock();
    try {
        synchronized(getStateLock()) {
            if (mb == menubar) return;
            if (mb == null) {
                if (menubar != null) {
                    menubarPeer.xSetVisible(false);
                    menubar = null;
                    menubarPeer.dispose();
                    menubarPeer = null;
                }
            } else {
                menubar = mb;
                menubarPeer = (XMenuBarPeer) mb.getPeer();
                if (menubarPeer != null) {
                    menubarPeer.init((Frame)target);
                }
            }
        }
    } finally {
        XToolkit.awtUnlock();
    }

    reshapeMenubarPeer();
}
 
Example 35
Project: jdk8u-jdk   File: RemoveHelpMenu.java   View source code 5 votes vote down vote up
private static void test2(final MenuBar menuBar) {
    final Menu helpMenu = new Menu("Help Menu");
    menuBar.setHelpMenu(helpMenu);
    checkCurrentMenu(menuBar, helpMenu);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu, true);

    menuBar.remove(helpMenu);
    checkCurrentMenu(menuBar, null);
    checkMenuCount(menuBar, 0);
    checkHelpMenu(helpMenu, false);
}
 
Example 36
Project: jdk8u-jdk   File: RemoveHelpMenu.java   View source code 5 votes vote down vote up
private static void test4(final MenuBar menuBar) {
    final Menu helpMenu = new Menu("Help Menu");
    menuBar.setHelpMenu(helpMenu);
    checkCurrentMenu(menuBar, helpMenu);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu, true);

    menuBar.setHelpMenu(null);
    checkCurrentMenu(menuBar, null);
    checkMenuCount(menuBar, 0);
    checkHelpMenu(helpMenu, false);
}
 
Example 37
Project: openjdk-jdk10   File: XFramePeer.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
public void setMenuBar(MenuBar mb) {
    // state_lock should always be the second after awt_lock
    XToolkit.awtLock();
    try {
        synchronized(getStateLock()) {
            if (mb == menubar) return;
            if (mb == null) {
                if (menubar != null) {
                    menubarPeer.xSetVisible(false);
                    menubar = null;
                    menubarPeer.dispose();
                    menubarPeer = null;
                }
            } else {
                menubar = mb;
                menubarPeer = AWTAccessor.getMenuComponentAccessor()
                                         .getPeer(mb);
                if (menubarPeer != null) {
                    menubarPeer.init((Frame)target);
                }
            }
        }
    } finally {
        XToolkit.awtUnlock();
    }

    reshapeMenubarPeer();
}
 
Example 38
Project: openjdk-jdk10   File: RemoveHelpMenu.java   View source code 5 votes vote down vote up
private static void test2(final MenuBar menuBar) {
    final Menu helpMenu = new Menu("Help Menu");
    menuBar.setHelpMenu(helpMenu);
    checkCurrentMenu(menuBar, helpMenu);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu, true);

    menuBar.remove(helpMenu);
    checkCurrentMenu(menuBar, null);
    checkMenuCount(menuBar, 0);
    checkHelpMenu(helpMenu, false);
}
 
Example 39
Project: openjdk-jdk10   File: RemoveHelpMenu.java   View source code 5 votes vote down vote up
private static void test4(final MenuBar menuBar) {
    final Menu helpMenu = new Menu("Help Menu");
    menuBar.setHelpMenu(helpMenu);
    checkCurrentMenu(menuBar, helpMenu);
    checkMenuCount(menuBar, 1);
    checkHelpMenu(helpMenu, true);

    menuBar.setHelpMenu(null);
    checkCurrentMenu(menuBar, null);
    checkMenuCount(menuBar, 0);
    checkHelpMenu(helpMenu, false);
}
 
Example 40
Project: openjdk-jdk10   File: ActionEventTest.java   View source code 5 votes vote down vote up
public ActionEventTest() {
    menuBar = new MenuBar();
    Menu menu = new Menu("Menu1");
    MenuItem menuItem = new MenuItem("MenuItem");

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            System.out.println("actionPerformed");
            int md = ae.getModifiers();
            int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
                    | ActionEvent.SHIFT_MASK;

            isProgInterruption = true;
            mainThread.interrupt();
            if ((md & expectedMask) != expectedMask) {
                throw new RuntimeException("Action Event modifiers are not"
                    + " set correctly.");
            }
        }
    });
    menu.add(menuItem);
    menuBar.add(menu);
    setMenuBar(menuBar);

    instructions = new TextArea(10, 50);
    instructions.setText(
    " This is a manual test\n" +
    " Keep the Alt, Shift & Ctrl Keys pressed while doing next steps\n" +
    " Click 'Menu1' Menu from the Menu Bar\n" +
    " It will show 'MenuItem'\n" +
    " Left mouse Click the 'MenuItem'\n" +
    " Test exits automatically after mouse click.");
    add(instructions);

    setSize(400, 400);
    setVisible(true);
    validate();
}