當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。