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


Java AWTException类代码示例

本文整理汇总了Java中java.awt.AWTException的典型用法代码示例。如果您正苦于以下问题:Java AWTException类的具体用法?Java AWTException怎么用?Java AWTException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test

import java.awt.AWTException; //导入依赖的package包/类
private static void test(GraphicsConfiguration gc) throws AWTException {
    final Window frame = new Frame(gc);
    try {
        frame.addMouseWheelListener(e -> {
            wheelX = e.getXOnScreen();
            wheelY = e.getYOnScreen();
            done = true;
        });
        frame.setSize(300, 300);
        frame.setVisible(true);

        final Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.setAutoWaitForIdle(true);
        mouseX = frame.getX() + frame.getWidth() / 2;
        mouseY = frame.getY() + frame.getHeight() / 2;

        robot.mouseMove(mouseX, mouseY);
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseWheel(10);

        validate();
    } finally {
        frame.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:MouseWheelAbsXY.java

示例2: startCrushing

import java.awt.AWTException; //导入依赖的package包/类
private void startCrushing() {
    message = messageET.getText();
    String mspStr= mpsET.getText();
    try{
        mps= Integer.parseInt(mspStr);
        delay= 1000/mps;
    }catch(Exception e){
        label.setText("Please Enter Message / sec Correctly.");
        return;
    }

    try {

        robot = new Robot();
        robot.mouseMove(x, y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

        Shivam shiv = new Shivam();
        shiv.start();

    } catch (AWTException ex) {
    }
}
 
开发者ID:shivam301296,项目名称:WhatsappCrush,代码行数:25,代码来源:WhatsappCrushGUI.java

示例3: setup

import java.awt.AWTException; //导入依赖的package包/类
@Override
public void setup() {
    // setup keyhook
    try {
        Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
        logger.setLevel(Level.OFF);
        GlobalScreen.registerNativeHook();
    } catch (NativeHookException ex) {
        System.err.println("There was a problem registering the native hook.");
        System.err.println(ex.getMessage());
        System.exit(1);
    }
    HKM = new KeyHook();
    HKM.addValidHotkey("Space");
    GlobalScreen.addNativeKeyListener(HKM);
    System.out.println("[KeyHook setup]");
    try {
        robot = new Robot();
    } catch (AWTException e) {
        System.out.println("Robot could not be created...");
    }
}
 
开发者ID:SlideKB,项目名称:SlideBar,代码行数:23,代码来源:AdobePremiere.java

示例4: createBackBuffer

import java.awt.AWTException; //导入依赖的package包/类
/**
 * Attempts to create an XDBE-based backbuffer for the given peer.  If
 * the requested configuration is not natively supported, an AWTException
 * is thrown.  Otherwise, if the backbuffer creation is successful, a
 * handle to the native backbuffer is returned.
 */
public long createBackBuffer(X11ComponentPeer peer,
                             int numBuffers, BufferCapabilities caps)
    throws AWTException
{
    if (!X11GraphicsDevice.isDBESupported()) {
        throw new AWTException("Page flipping is not supported");
    }
    if (numBuffers > 2) {
        throw new AWTException(
            "Only double or single buffering is supported");
    }
    BufferCapabilities configCaps = getBufferCapabilities();
    if (!configCaps.isPageFlipping()) {
        throw new AWTException("Page flipping is not supported");
    }

    long window = peer.getContentWindow();
    int swapAction = getSwapAction(caps.getFlipContents());

    return createBackBuffer(window, swapAction);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:X11GraphicsConfig.java

示例5: initSystemTray

import java.awt.AWTException; //导入依赖的package包/类
private static void initSystemTray() {
  // add system tray icon with popup menu
  if (SystemTray.isSupported()) {
    SystemTray tray = SystemTray.getSystemTray();
    PopupMenu menu = new PopupMenu();
    MenuItem exitItem = new MenuItem(Resources.get("menu_exit"));
    exitItem.addActionListener(a -> Game.terminate());
    menu.add(exitItem);

    trayIcon = new TrayIcon(RenderEngine.getImage("pixel-icon-utility.png"), Game.getInfo().toString(), menu);
    trayIcon.setImageAutoSize(true);
    try {
      tray.add(trayIcon);
    } catch (AWTException e) {
      log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
  }
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:19,代码来源:Program.java

示例6: keyReleased

import java.awt.AWTException; //导入依赖的package包/类
public void keyReleased(KeyEvent e) {
    // Fix (workaround) for issue #186557
    if (org.openide.util.Utilities.isWindows()) {
        if (Boolean.getBoolean("HintsUI.disable.AltEnter.hack")) { // NOI18N
            return;
        }

        if (altEnterPressed && e.getKeyCode() == KeyEvent.VK_ALT) {
            e.consume();
            altReleased = true;
        } else if (altEnterPressed && e.getKeyCode() == KeyEvent.VK_ENTER) {
            altEnterPressed = false;
            if (altReleased) {
                try {
                    java.awt.Robot r = new java.awt.Robot();
                    r.keyRelease(KeyEvent.VK_ALT);
                } catch (AWTException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:HintsUI.java

示例7: checkCreateImage

import java.awt.AWTException; //导入依赖的package包/类
private static void checkCreateImage(final Component comp,
                                     final boolean isNull) {
    if ((comp.createImage(10, 10) != null) == isNull) {
        throw new RuntimeException("Image is wrong");
    }
    if ((comp.createVolatileImage(10, 10) != null) == isNull) {
        throw new RuntimeException("Image is wrong");
    }
    try {
        if ((comp.createVolatileImage(10, 10, null) != null) == isNull) {
            throw new RuntimeException("Image is wrong");
        }
    } catch (final AWTException ignored) {
        // this check is not applicable
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:CreateImage.java

示例8: initialize

import java.awt.AWTException; //导入依赖的package包/类
/**
 * Starts the TrayIcon, if this is supported. If not, it should start a
 * simple JDialog, doing the same as independent Window.
 */
private void initialize() {

	switch (this.getTrayIconUsage()) {
	case TrayIcon:
		try {
			// --- System-Tray is supported ---------------------
			this.getSystemTray().add(this.getTrayIcon(true));
			
		} catch (AWTException e) {
			System.err.println("TrayIcon supported, but could not be added. => Use TrayDialog instead !");
			this.getAgentGUITrayDialog(true).setVisible(true);			
		}
		break;
		
	case TrayDialog:
		this.getAgentGUITrayDialog(true).setVisible(true);
		break;

	default:
		break;
	}
	
	// --- Refresh tray icon ------------------------------------
	this.getAgentGUITrayPopUp().refreshView();
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:30,代码来源:AgentGUITrayIcon.java

示例9: main

import java.awt.AWTException; //导入依赖的package包/类
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:bug7097771.java

示例10: execute

import java.awt.AWTException; //导入依赖的package包/类
@Override
public void execute(@NotNull String pattern) {

  try {
    Robot r = new Robot();
    r.keyPress(157);
    r.keyPress(90);

    r.keyRelease(90);
    r.keyRelease(157);

  } catch (AWTException e) {
    e.printStackTrace();
  }
  SelectionUtil.selectNode(_context.getEditorContext(), _context.getNode());
  SelectionUtil.selectCell(_context.getEditorContext(), _context.getNode(), SelectionManager.FIRST_ERROR_CELL + "|" + SelectionManager.FOCUS_POLICY_CELL + "|" + SelectionManager.FIRST_EDITABLE_CELL + "|" + SelectionManager.FIRST_CELL);

}
 
开发者ID:vaclav,项目名称:voicemenu,代码行数:19,代码来源:Event_TransformationMenu.java

示例11: checkDoubleClickEvent

import java.awt.AWTException; //导入依赖的package包/类
private void checkDoubleClickEvent(int eventToCheck) throws InterruptedException, InvocationTargetException, AWTException {
    events = eventToCheck;
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            actionsArea.setText("");
        }
    });
    driver = new JavaDriver();
    WebElement b = driver.findElement(By.name("click-me"));
    WebElement t = driver.findElement(By.name("actions"));

    Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
    Dimension size = EventQueueWait.call_noexc(button, "getSize");
    Robot r = new Robot();
    r.setAutoDelay(10);
    r.setAutoWaitForIdle(true);
    r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    Thread.sleep(50);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    new EventQueueWait() {
        @Override public boolean till() {
            return actionsArea.getText().contains("(2");
        }
    }.wait("Waiting for actionsArea failed?");
    String expected = t.getText();
    tclear();
    Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
    Dimension size2 = EventQueueWait.call_noexc(button, "getSize");
    r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);

    new Actions(driver).moveToElement(b).doubleClick().perform();
    AssertJUnit.assertEquals(expected, t.getText());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:39,代码来源:NativeEventsTest.java

示例12: main

import java.awt.AWTException; //导入依赖的package包/类
public static void main(String[] args) throws AWTException {
    robot = new Robot();
    // test escape after selection
    start();
    click(KeyEvent.VK_ESCAPE);
    robot.waitForIdle();
    // test double escape after editing
    start();
    click(KeyEvent.VK_1);
    click(KeyEvent.VK_0);
    click(KeyEvent.VK_ESCAPE);
    click(KeyEvent.VK_ESCAPE);
    robot.waitForIdle();
    // all windows should be closed
    for (Window window : Window.getWindows()) {
        if (window.isVisible()) {
            throw new Error("found visible window: " + window.getName());
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Test6541987.java

示例13: createBackBuffer

import java.awt.AWTException; //导入依赖的package包/类
/**
 * Attempts to create a GLX-based backbuffer for the given peer.  If
 * the requested configuration is not natively supported, an AWTException
 * is thrown.  Otherwise, if the backbuffer creation is successful, a
 * value of 1 is returned.
 */
@Override
public long createBackBuffer(X11ComponentPeer peer,
                             int numBuffers, BufferCapabilities caps)
    throws AWTException
{
    if (numBuffers > 2) {
        throw new AWTException(
            "Only double or single buffering is supported");
    }
    BufferCapabilities configCaps = getBufferCapabilities();
    if (!configCaps.isPageFlipping()) {
        throw new AWTException("Page flipping is not supported");
    }
    if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
        throw new AWTException("FlipContents.PRIOR is not supported");
    }

    // non-zero return value means backbuffer creation was successful
    // (checked in X11ComponentPeer.flip(), etc.)
    return 1;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:GLXGraphicsConfig.java

示例14: TakeScreenshot

import java.awt.AWTException; //导入依赖的package包/类
public static void TakeScreenshot(String filePath, String fileName) {
    try {
        Robot robot = new Robot();
        Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
        BufferedImage screenFullImage = robot.createScreenCapture(screenRect);
        ImageIO.write(screenFullImage, "jpg", new File(filePath + fileName + ".jpg"));
    } catch (AWTException | IOException ex) {
        System.out.println(ex.getMessage());
    }
}
 
开发者ID:tiagorlampert,项目名称:sAINT,代码行数:11,代码来源:Screenshot.java

示例15: attach

import java.awt.AWTException; //导入依赖的package包/类
@Attachment(type = "image/png", fileExtension = "png", value = "att")
public byte[] attach() {
    try {
        BufferedImage image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write(image, "png", baos);
        baos.flush();
        byte[] imageInByte = baos.toByteArray();
        baos.close();
        return imageInByte;
    } catch (AWTException | IOException e) {
        return null;
    }
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:15,代码来源:Stepdefs.java


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