protected void assembleSystemMenu() {
    systemMenu = new JPopupMenu();
    JMenuItem mi = (JMenuItem) systemMenu.add(new JMenuItem(restoreAction));
    mi.setMnemonic('R');
    mi = (JMenuItem) systemMenu.add(new JMenuItem(moveAction));
    mi.setMnemonic('M');
    mi = (JMenuItem) systemMenu.add(new JMenuItem(sizeAction));
    mi.setMnemonic('S');
    mi = (JMenuItem) systemMenu.add(new JMenuItem(iconifyAction));
    mi.setMnemonic('n');
    mi = (JMenuItem) systemMenu.add(new JMenuItem(maximizeAction));
    mi.setMnemonic('x');
    systemMenu.add(new JSeparator());
    mi = (JMenuItem) systemMenu.add(new JMenuItem(closeAction));
    mi.setMnemonic('C');

    systemButton = new SystemButton();
    systemButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            systemMenu.show(systemButton, 0, BUTTON_SIZE);
          }
        });

    systemButton.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent evt) {
            try {
              frame.setSelected(true);
            } catch (PropertyVetoException pve) {
            }
            if ((evt.getClickCount() == 2)) {
              closeAction.actionPerformed(
                  new ActionEvent(
                      evt.getSource(), ActionEvent.ACTION_PERFORMED, null, evt.getWhen(), 0));
              systemMenu.setVisible(false);
            }
          }
        });
  }
 protected void hideSystemMenu() {
   systemMenu.setVisible(false);
 }
 protected void showSystemMenu() {
   systemMenu.show(systemButton, 0, BUTTON_SIZE);
 }