Java Code Examples for javax.swing.JWindow#addMouseListener()
The following examples show how to use
javax.swing.JWindow#addMouseListener() .
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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: RoarPanel.java From Spark with Apache License 2.0 | 4 votes |
/** * Creates a popupwindow with specified items, displays it for given time, * and notifies its owner on closure * * @param owner * , the owner of this Panel * @param icon * , the icon to display * @param head * , the header * @param text * , the message body * @param x * , the x locaiton on screen * @param y * , the y location on screen * @param duration * , the display duration * @param backgroundcolor * , the background color * @param headercolor * , the headertext color * @param textcolor * , the messagebody color */ public static void popupWindow(final RoarDisplayType owner, Icon icon, String head, String text, int x, int y, int duration, Color backgroundcolor, Color headercolor, Color textcolor, final Action action) { final JWindow window = createWindow(icon, head, text, x, y, backgroundcolor, headercolor, textcolor); fadein(window); if (duration > 0) { TimerTask closeTimer = new TimerTask() { public void run() { closePanel(owner, window); } }; Timer t = new Timer(); t.schedule(closeTimer, duration); } window.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { action.actionPerformed(null); closePanel(owner, window); } }); }