Java Code Examples for javax.swing.JPopupMenu#isVisible()

The following examples show how to use javax.swing.JPopupMenu#isVisible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GrabOnUnfocusableToplevel.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 2
Source File: GrabOnUnfocusableToplevel.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 3
Source File: GrabOnUnfocusableToplevel.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 4
Source File: GrabOnUnfocusableToplevel.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 5
Source File: GrabOnUnfocusableToplevel.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 6
Source File: GrabOnUnfocusableToplevel.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 7
Source File: GrabOnUnfocusableToplevel.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 8
Source File: GrabOnUnfocusableToplevel.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 9
Source File: GrabOnUnfocusableToplevel.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 10
Source File: GrabOnUnfocusableToplevel.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 11
Source File: GrabOnUnfocusableToplevel.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 12
Source File: GrabOnUnfocusableToplevel.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 13
Source File: GrabOnUnfocusableToplevel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example 14
Source File: CorefEditor.java    From gate-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ae) {
  int index = -1;
  if (highlightedChainAnnotsOffsets != null) {
    for (int i = 0; i < highlightedChainAnnotsOffsets.length; i += 2) {
      if (textLocation >= highlightedChainAnnotsOffsets[i] &&
          textLocation <= highlightedChainAnnotsOffsets[i + 1]) {
        index = (i == 0) ? i : i / 2;
        break;
      }
    }
  }

  // yes it is put on highlighted so show the annotationType
  if (highlightedChainAnnotsOffsets != null &&
      index < highlightedChainAnnotsOffsets.length && index >= 0) {
    return;
  }

  if (highlightedTypeAnnotsOffsets != null) {
    for (int i = 0; i < highlightedTypeAnnotsOffsets.length; i += 2) {
      if (textLocation >= highlightedTypeAnnotsOffsets[i] &&
          textLocation <= highlightedTypeAnnotsOffsets[i + 1]) {
        index = (i == 0) ? i : i / 2;
        break;
      }
    }
  }

  // yes it is put on highlighted so show the annotationType
  if (highlightedTypeAnnotsOffsets != null &&
      index < highlightedTypeAnnotsOffsets.length && index >= 0) {
    textPane.removeAll();
    annotToConsiderForChain = highlightedTypeAnnots.get(index);
    // now check if this annotation is already linked with something
    CorefTreeNode headNode = findOutTheChainHead(annotToConsiderForChain, (String) annotSets.getSelectedItem());
    if (headNode != null) {
      popup1 = new JPopupMenu();
      popup1.setBackground(UIManager.getLookAndFeelDefaults().
                           getColor("ToolTip.background"));
      JLabel label1 = new JLabel("Annotation co-referenced to : \"" +
                                 headNode.toString() + "\"");
      popup1.setLayout(new FlowLayout());
      popup1.add(label1);
      if (popupWindow != null && popupWindow.isVisible()) {
        popupWindow.setVisible(false);
      }
      popup1.setVisible(true);
      popup1.show(textPane, (int) mousePoint.getX(), (int) mousePoint.getY());
    }
    else {
      popupWindow.setVisible(false);
      List<String> set = new ArrayList<String>(currentSelections.keySet());
      Collections.sort(set);
      set.add(0, "[New Chain]");
      model = new DefaultComboBoxModel<String>(set.toArray(new String[set.size()]));
      list.setModel(model);
      listEditor.setItem("");
      label.setText("Add \"" + getString(annotToConsiderForChain) +
                    "\" to ");
      Point topLeft = textPane.getLocationOnScreen();
      int x = topLeft.x + (int) mousePoint.getX();
      int y = topLeft.y + (int) mousePoint.getY();
      popupWindow.setLocation(x, y);
      if (popup1.isVisible()) {
        popup1.setVisible(false);
      }
      popupWindow.pack();
      popupWindow.setVisible(true);
      listEditor.requestFocus();

      if (firstTime) {
        firstTime = false;
        popupWindow.pack();
        popupWindow.repaint();
        listEditor.requestFocus();
      }
    }
  }
}