use of java.awt.event.MouseAdapter in project jdk8u_jdk by JetBrains.
the class MissingEventsOnModalDialogTest method showModalDialog.
private static void showModalDialog(Frame targetFrame) {
Dialog dialog = new Dialog(targetFrame, true);
dialog.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
passed = true;
dialog.dispose();
}
});
dialog.setSize(400, 300);
dialog.setTitle("Modal Dialog!");
clickOnModalDialog(dialog);
dialog.setVisible(true);
}
use of java.awt.event.MouseAdapter in project jdk8u_jdk by JetBrains.
the class MultimonFullscreenTest method actionPerformed.
public void actionPerformed(ActionEvent ae) {
GraphicsDevice dev = deviceMap.get(ae.getSource());
System.err.println("Setting FS on device:" + dev);
final Window fsWindow;
if (useFSWindow) {
fsWindow = new Window(this, dev.getDefaultConfiguration()) {
public void paint(Graphics g) {
renderDimensions(g, getBounds(), this.getGraphicsConfiguration());
}
};
} else if (useFSDialog) {
fsWindow = new Dialog((Frame) null, "FS Dialog on device " + dev, false, dev.getDefaultConfiguration());
fsWindow.add(new Component() {
public void paint(Graphics g) {
renderDimensions(g, getBounds(), this.getGraphicsConfiguration());
}
});
} else {
fsWindow = new Frame("FS Frame on device " + dev, dev.getDefaultConfiguration()) {
public void paint(Graphics g) {
renderDimensions(g, getBounds(), this.getGraphicsConfiguration());
}
};
if (addHWChildren) {
fsWindow.add("South", new Panel() {
public void paint(Graphics g) {
g.setColor(Color.red);
g.fillRect(0, 0, getWidth(), getHeight());
}
});
fsWindow.add("North", new Button("Button, sucka!"));
}
}
fsWindow.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
done = true;
fsWindow.dispose();
}
}
});
fsWindow.addWindowListener(new WindowHandler());
dev.setFullScreenWindow(fsWindow);
if (dmChange && dev.isDisplayChangeSupported()) {
DisplayMode[] dms = dev.getDisplayModes();
DisplayMode myDM = null;
for (DisplayMode dm : dms) {
if (dm.getWidth() == 800 && dm.getHeight() == 600 && (dm.getBitDepth() >= 16 || dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) && (dm.getRefreshRate() >= 60 || dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN)) {
myDM = dm;
break;
}
}
if (myDM != null) {
System.err.println("Setting Display Mode: " + myDM.getWidth() + "x" + myDM.getHeight() + "x" + myDM.getBitDepth() + "@" + myDM.getRefreshRate() + "Hz on device" + dev);
dev.setDisplayMode(myDM);
} else {
System.err.println("Can't find suitable display mode.");
}
}
done = false;
if (runRenderLoop) {
Thread updateThread = new Thread(new Runnable() {
public void run() {
BufferStrategy bs = null;
if (useBS) {
fsWindow.createBufferStrategy(2);
bs = fsWindow.getBufferStrategy();
}
while (!done) {
if (useBS) {
Graphics g = bs.getDrawGraphics();
renderDimensions(g, fsWindow.getBounds(), fsWindow.getGraphicsConfiguration());
bs.show();
} else {
fsWindow.repaint();
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
if (useBS) {
bs.dispose();
}
}
});
updateThread.start();
}
}
use of java.awt.event.MouseAdapter in project jdk8u_jdk by JetBrains.
the class ExtraMouseClick method init.
public void init() {
this.setLayout(new BorderLayout());
frame.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
System.out.println("MousePressed");
pressed = true;
}
public void mouseReleased(MouseEvent e) {
System.out.println("MouseReleased");
released = true;
}
public void mouseClicked(MouseEvent e) {
System.out.println("MouseClicked!!!!");
clicked = true;
}
});
frame.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
System.out.println("MouseDragged--" + e);
dragged = true;
}
public void mouseMoved(MouseEvent e) {
}
});
}
use of java.awt.event.MouseAdapter in project jdk8u_jdk by JetBrains.
the class GrabOnUnfocusableToplevel method main.
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.");
}
use of java.awt.event.MouseAdapter in project jdk8u_jdk by JetBrains.
the class JPEGsNotAcceleratedTest method showRes.
private static void showRes(String desc, final BufferedImage src) {
final int w = src.getWidth();
final int h = src.getHeight();
Frame f = new Frame(desc + ": dbl-click to exit");
Component c;
f.add(c = new Component() {
public Dimension getPreferredSize() {
return new Dimension(w, h);
}
public void paint(Graphics g) {
g.clearRect(0, 0, getWidth(), getHeight());
g.drawImage(src, 0, 0, null);
}
});
c.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
System.exit(0);
}
}
});
f.pack();
synchronized (JPEGsNotAcceleratedTest.class) {
f.setLocation(frameX, frameY);
frameX += f.getWidth();
if ((frameX + f.getWidth()) > f.getGraphicsConfiguration().getBounds().width) {
frameY += TEST_H;
if ((frameY + f.getHeight()) > f.getGraphicsConfiguration().getBounds().height) {
startY += 30;
startX += 30;
frameY = startY;
}
frameX = startX;
}
}
;
f.setVisible(true);
}
Aggregations