本文整理匯總了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();
}
}
});
}
示例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.");
}
示例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();
}
});
}