当前位置: 首页>>代码示例>>Java>>正文


Java JWindow.addMouseListener方法代码示例

本文整理汇总了Java中javax.swing.JWindow.addMouseListener方法的典型用法代码示例。如果您正苦于以下问题:Java JWindow.addMouseListener方法的具体用法?Java JWindow.addMouseListener怎么用?Java JWindow.addMouseListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JWindow的用法示例。


在下文中一共展示了JWindow.addMouseListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import javax.swing.JWindow; //导入方法依赖的package包/类
/** Start the bot. */
public void start() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    int xSize = ((int) tk.getScreenSize().getWidth());
    int ySize = ((int) tk.getScreenSize().getHeight());
    window = new JWindow();
    window.setSize(xSize, ySize);
    window.setOpacity(0.0f);
    window.setVisible(true);
    window.setAlwaysOnTop(true);
    window.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (clicks < _numberOfLocations) {
                location[clicks] = getLocation();
                window.setVisible(false);
                sleep();
                click();
                sleep();
                window.setVisible(true);
                sleep();
                clicks += 1;
            }
            if (clicks == _numberOfLocations) {
                window.setVisible(false);
                process();
            }
        }
    });
}
 
开发者ID:jenyeu,项目名称:clickbot,代码行数:31,代码来源:Bot.java

示例2: main

import javax.swing.JWindow; //导入方法依赖的package包/类
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.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:GrabOnUnfocusableToplevel.java

示例3: popupWindow

import javax.swing.JWindow; //导入方法依赖的package包/类
/**
    * 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);


final TimerTask closeTimer = new TimerTask() {
    @Override
    public void run() {
	if (window != null) {
	    owner.closingRoarPanel(window.getX(),window.getY());
	    window.dispose();   
	}
    }
};

Timer t = new Timer();
t.schedule(closeTimer, duration);

window.addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent e) {
	action.actionPerformed(null);
	closeTimer.run();
    }
});
   }
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:53,代码来源:RoarPanel.java


注:本文中的javax.swing.JWindow.addMouseListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。