类java.awt.Event源码实例Demo

下面列出了怎么用java.awt.Event的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jintellitype   文件: JIntellitypeDemo.java
/**
 * Method to register a hotkey using the RegisterHotKey Windows API call.
 * <p>
 * 
 * @param aEvent the ActionEvent fired.
 */
private void btnRegisterHotKey_actionPerformed(ActionEvent aEvent) {
	// assign the WINDOWS+A key to the unique id 88 for identification
	JIntellitype.getInstance().registerHotKey(WINDOWS_A, JIntellitype.MOD_WIN, 'A');
	JIntellitype.getInstance().registerHotKey(ALT_SHIFT_B, JIntellitype.MOD_ALT + JIntellitype.MOD_SHIFT, 'B');
	JIntellitype.getInstance().registerSwingHotKey(CTRL_SHIFT_C, Event.CTRL_MASK + Event.SHIFT_MASK, 'C');

	// use a 0 for the modifier if you just want a single keystroke to be a
	// hotkey
	JIntellitype.getInstance().registerHotKey(PRINT_SCREEN, 0, 44);
	JIntellitype.getInstance().registerHotKey(F11, "F11");
	JIntellitype.getInstance().registerHotKey(F12, JIntellitype.MOD_ALT, 123);
	JIntellitype.getInstance().registerHotKey(SEMICOLON, 0, 186);
	JIntellitype.getInstance().registerHotKey(TICK, 0, 192);
	// clear the text area
	textArea.setText("");
	output("RegisterHotKey WINDOWS+A was assigned uniqueID 88");
	output("RegisterHotKey ALT+SHIFT+B was assigned uniqueID 89");
	output("RegisterHotKey CTRL+SHIFT+C was assigned uniqueID 90");
	output("RegisterHotKey PRINT_SCREEN was assigned uniqueID 91");
	output("RegisterHotKey F9 was assigned uniqueID 92");
	output("RegisterHotKey F12 was assigned uniqueID 93");
	output("RegisterHotKey SEMICOLON was assigned uniqueID 94");
	output("Press WINDOWS+A or ALT+SHIFT+B or CTRL+SHIFT+C in another application and you will see the debug output in the textarea.");
}
 
源代码2 项目: netbeans   文件: UI.java
private void processKey(char key) {
//out("select: '" + key);
            if (((int) key) == Event.BACK_SPACE) {
                init();
                return;
            }
            myPrefix += key;
            myPrefix = myPrefix.toLowerCase();

//out("prefix: " + myPrefix);
            for (int i = myIndex; i < getItemCount(); i++) {
                String item = getItemAt(i).toString().toLowerCase();
//out("  see: " + item);

                if (item.startsWith(myPrefix)) {
                    myIndex = i;
                    return;
                }
            }
        }
 
源代码3 项目: evosql   文件: Tree.java
/**
     * Method declaration
     *
     *
     * @param e
     */

// [email protected] 20020130 - comment by fredt
// to remove this deprecated method we need to rewrite the Tree class as a
// ScrollPane component
    public boolean handleEvent(Event e) {

        switch (e.id) {

            case Event.SCROLL_LINE_UP :
            case Event.SCROLL_LINE_DOWN :
            case Event.SCROLL_PAGE_UP :
            case Event.SCROLL_PAGE_DOWN :
            case Event.SCROLL_ABSOLUTE :
                iX = sbHoriz.getValue();
                iY = iRowHeight * sbVert.getValue();

                repaint();

                return true;
        }

        return super.handleEvent(e);
    }
 
源代码4 项目: evosql   文件: Grid.java
/**
 * Method declaration
 *
 *
 * @param e
 */

// [email protected] 20020130 - comment by fredt
// to remove this deprecated method we need to rewrite the Grid class as a
// ScrollPane component
// sqlbob:  I believe that changing to the JDK1.1 event handler
// would require browsers to use the Java plugin.
public boolean handleEvent(Event e) {

    switch (e.id) {

        case Event.SCROLL_LINE_UP :
        case Event.SCROLL_LINE_DOWN :
        case Event.SCROLL_PAGE_UP :
        case Event.SCROLL_PAGE_DOWN :
        case Event.SCROLL_ABSOLUTE :
            iX = sbHoriz.getValue();
            iY = iRowHeight * sbVert.getValue();

            repaint();

            return true;
    }

    return super.handleEvent(e);
}
 
源代码5 项目: evosql   文件: Grid.java
/**
 * Method declaration
 *
 *
 * @param e
 * @param x
 * @param y
 */
public boolean mouseDrag(Event e, int x, int y) {

    if (bDrag && x < iWidth) {
        int w = x - iXDrag;

        if (w < 0) {
            w = 0;
        }

        iColWidth[iColDrag] = w;

        adjustScroll();
        repaint();
    }

    return true;
}
 
源代码6 项目: Raccoon   文件: ResultView.java
public void actionPerformed(ActionEvent event) {
	Object src = event.getSource();
	if (src == download) {
		DownloadView d = DownloadView.create(searchView.getArchive(), doc);
		searchView.doDownload(d);
	}
	if (src == details) {
		if ((event.getModifiers() & Event.SHIFT_MASK) == Event.SHIFT_MASK) {
			// This is indented for debugging!
			entry.setContentType("text/plain"); //$NON-NLS-1$
			entry.setText(doc.toString());
		}
		else {
			doToggleDetails();
		}
	}
	if (src == gplay) {
		BrowseUtil.openUrl(doc.getShareUrl());
		SwingUtilities.invokeLater(searchView); // Re - focus
	}
	if (src == permissions) {
		doTogglePermissions();
	}
}
 
源代码7 项目: dragonwell8_jdk   文件: AppletFrame.java
@Override
public void processEvent(AWTEvent e) {
    // Window Destroy event
    if (e.getID() == Event.WINDOW_DESTROY) {
        // exit the program
        System.exit(0);
    }
}
 
源代码8 项目: dragonwell8_jdk   文件: CPopupMenu.java
@Override
public void show(Event e) {
    Component origin = (Component)e.target;
    if (origin != null) {
        Point loc = origin.getLocationOnScreen();
        e.x += loc.x;
        e.y += loc.y;
        execute(ptr -> nativeShowPopupMenu(ptr, e.x, e.y));
    }
}
 
源代码9 项目: ghidra   文件: KitchenSinkPlugin.java
private void setupActions() {
    DockingAction action = new DockingAction("Hello World", getName() ) {
        @Override
        public void actionPerformed( ActionContext context ) {
            Msg.info(this, "Hello World:: action");
            announce("Hello World");
        }
    };
    action.setEnabled( true );
    String helloGroup = "Hello";
    ImageIcon prevImage = ResourceManager.loadImage(PREV_IMAGE);
    action.setMenuBarData( new MenuData( new String[] {"Misc", "Hello World"}, prevImage, helloGroup ) );
    action.setPopupMenuData( new MenuData( new String[] {"Hello World"}, prevImage, helloGroup ) );
    action.setKeyBindingData( new KeyBindingData( KeyStroke.getKeyStroke('H', Event.CTRL_MASK ) ) );
    action.setToolBarData( new ToolBarData( prevImage, helloGroup ) );
    action.setDescription("Hello World");
    action.setHelpLocation(new HelpLocation("SampleHelpTopic", "KS_Hello_World"));

    tool.addAction(action);

    action = new DockingAction("Hello Program", getName() ) {
        @Override
        public void actionPerformed( ActionContext context ) {
            Msg.info(this, "Hello Program:: action");
            sayHelloProgram();        
        }
    };
    action.setEnabled(false);
    ImageIcon nextImage = ResourceManager.loadImage(NEXT_IMAGE);
    action.setMenuBarData( new MenuData( new String[]{"Misc", "Hello Program"}, nextImage, helloGroup ) );
    action.setKeyBindingData( new KeyBindingData( KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK ) ) );
    action.setToolBarData( new ToolBarData( nextImage, helloGroup ) );
    action.setDescription("Hello Program");
    action.setHelpLocation(new HelpLocation("SampleHelpTopic", "KS_Hello_Program"));
    tool.addAction(action);

    // remember this action so I can enable/disable it later
    helloProgramAction = action;
}
 
源代码10 项目: TencentKona-8   文件: CPopupMenu.java
@Override
public void show(Event e) {
    Component origin = (Component)e.target;
    if (origin != null) {
        Point loc = origin.getLocationOnScreen();
        e.x += loc.x;
        e.y += loc.y;
        execute(ptr -> nativeShowPopupMenu(ptr, e.x, e.y));
    }
}
 
源代码11 项目: jdk8u60   文件: AppletFrame.java
@Override
public void processEvent(AWTEvent e) {
    // Window Destroy event
    if (e.getID() == Event.WINDOW_DESTROY) {
        // exit the program
        System.exit(0);
    }
}
 
源代码12 项目: SikuliX1   文件: PreferencesUser.java
private int defaultStopHotkeyModifiers() {
  int mod = Event.SHIFT_MASK + Event.META_MASK;
  if (!Settings.isMac()) {
    mod = Event.SHIFT_MASK + Event.ALT_MASK;
  }
  return mod;
}
 
源代码13 项目: trygve   文件: InputStreamClass.java
@Override public void checkIOIntegration(final Event e) {
try {
    queue.put(e.key);
} catch (InterruptedException ex) {
    Logger.getLogger(Console.class.getName()).
            log(Level.SEVERE, null, ex);
}
  }
 
源代码14 项目: openjdk-jdk8u   文件: AppletFrame.java
@Override
public void processEvent(AWTEvent e) {
    // Window Destroy event
    if (e.getID() == Event.WINDOW_DESTROY) {
        // exit the program
        System.exit(0);
    }
}
 
源代码15 项目: trygve   文件: RTEventObject.java
public static RTObject ctor1(final Event e) {
	final Type intType = StaticScope.globalScope().lookupTypeDeclaration("int");
	final StaticScope intScope = intType.enclosedScope();
	final RTType rTIntType = InterpretiveCodeGenerator.scopeToRTTypeDeclaration(intScope);
	
	final Type stringType = StaticScope.globalScope().lookupTypeDeclaration("String");
	final StaticScope stringScope = stringType.enclosedScope();
	final RTType rTStringType = InterpretiveCodeGenerator.scopeToRTTypeDeclaration(stringScope);
	
	final Type eventType = StaticScope.globalScope().lookupTypeDeclaration("Event");
	final StaticScope eventScope = eventType.enclosedScope();
	final RTType rTEventType = InterpretiveCodeGenerator.scopeToRTTypeDeclaration(eventScope);
	
	final RTObject theEventObject = new RTObjectCommon(rTEventType);
	theEventObject.addObjectDeclaration("id", rTIntType);
	theEventObject.addObjectDeclaration("key", rTIntType);
	theEventObject.addObjectDeclaration("keyString", rTStringType);
	theEventObject.addObjectDeclaration("x", rTIntType);
	theEventObject.addObjectDeclaration("y", rTIntType);
	
	theEventObject.setObject("x", new RTIntegerObject(e.x));
	theEventObject.setObject("y", new RTIntegerObject(e.y));
	theEventObject.setObject("id", new RTIntegerObject(e.id));
	theEventObject.setObject("key", new RTIntegerObject(e.key));
	final char cKey = (char)e.key;
	final String keyAsString = "" + cKey;
	theEventObject.setObject("keyString", new RTStringObject(keyAsString));
	
	return theEventObject;
}
 
源代码16 项目: marathonv5   文件: JavaElementPropertyAccessor.java
public String getMenuKey() {
    int menuShortcutKeyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    if ((menuShortcutKeyMask & Event.CTRL_MASK) == Event.CTRL_MASK) {
        return "Control";
    }
    if ((menuShortcutKeyMask & Event.META_MASK) == Event.META_MASK) {
        return "Meta";
    }
    return "";
}
 
源代码17 项目: marathonv5   文件: OSUtils.java
public static Keys getMenuKey() {
    int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    if (keyMask == Event.CTRL_MASK) {
        return Keys.CONTROL;
    }
    if (keyMask == Event.META_MASK) {
        return Keys.META;
    }
    if (keyMask == Event.ALT_MASK) {
        return Keys.ALT;
    }
    throw new WebDriverException("Unable to find the keymask... not control or meta?");
}
 
private void resourceResolverShouldBeIgnoredWhenResolverFactoryIsExecutedInMethodFromDifferentClass(
    Event event, List<String> attributesList) {
  if (attributesList.containsAll(ATTRIBUTES)) {
    String path = (String) event.getProperty(SlingConstants.PROPERTY_PATH);
    try {
      SlingHelper.operate(resolverFactory, resolver -> processPackage(resolver, path));
    } catch (OperateException e) {
      System.out.println("something went wrong");
    }
  }
}
 
源代码19 项目: openjdk-jdk8u-backup   文件: CPopupMenu.java
@Override
public void show(Event e) {
    Component origin = (Component)e.target;
    if (origin != null) {
        Point loc = origin.getLocationOnScreen();
        e.x += loc.x;
        e.y += loc.y;
        execute(ptr -> nativeShowPopupMenu(ptr, e.x, e.y));
    }
}
 
源代码20 项目: openjdk-8-source   文件: AppletFrame.java
@Override
public void processEvent(AWTEvent e) {
    // Window Destroy event
    if (e.getID() == Event.WINDOW_DESTROY) {
        // exit the program
        System.exit(0);
    }
}
 
源代码21 项目: iBioSim   文件: CloseTabPaneUI.java
/**
 * Adds the specified mnemonic at the specified index.
 */
private void addMnemonic(int index, int mnemonic) {
	if (mnemonicToIndexMap == null) {
		initMnemonics();
	}
	mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, Event.ALT_MASK), "setSelectedIndex");
	mnemonicToIndexMap.put(new Integer(mnemonic), new Integer(index));
}
 
源代码22 项目: openjdk-jdk9   文件: AppletFrame.java
@Override
public void processEvent(AWTEvent e) {
    // Window Destroy event
    if (e.getID() == Event.WINDOW_DESTROY) {
        // exit the program
        System.exit(0);
    }
}
 
源代码23 项目: jdk8u_jdk   文件: CPopupMenu.java
@Override
public void show(Event e) {
    Component origin = (Component)e.target;
    if (origin != null) {
        Point loc = origin.getLocationOnScreen();
        e.x += loc.x;
        e.y += loc.y;
        execute(ptr -> nativeShowPopupMenu(ptr, e.x, e.y));
    }
}
 
源代码24 项目: openjdk-jdk9   文件: CPopupMenu.java
@Override
@SuppressWarnings("deprecation")
public void show(Event e) {
    Component origin = (Component)e.target;
    if (origin != null) {
        Point loc = origin.getLocationOnScreen();
        e.x += loc.x;
        e.y += loc.y;
        execute(ptr -> nativeShowPopupMenu(ptr, e.x, e.y));
    }
}
 
源代码25 项目: jdk8u-jdk   文件: AppletFrame.java
@Override
public void processEvent(AWTEvent e) {
    // Window Destroy event
    if (e.getID() == Event.WINDOW_DESTROY) {
        // exit the program
        System.exit(0);
    }
}
 
源代码26 项目: evosql   文件: Grid.java
/**
 * Method declaration
 *
 *
 * @param e
 * @param x
 * @param y
 */
public boolean mouseMove(Event e, int x, int y) {

    if (y <= iRowHeight) {
        int xb = x;

        x += iX - iGridWidth;

        int i = iColCount - 1;

        for (; i >= 0; i--) {
            if (x > -7 && x < 7) {
                break;
            }

            x += iColWidth[i];
        }

        if (i >= 0) {
            if (!bDrag) {
                setCursor(new Cursor(Cursor.E_RESIZE_CURSOR));

                bDrag    = true;
                iXDrag   = xb - iColWidth[i];
                iColDrag = i;
            }

            return true;
        }
    }

    return mouseExit(e, x, y);
}
 
源代码27 项目: evosql   文件: Grid.java
/**
 * Method declaration
 *
 *
 * @param e
 * @param x
 * @param y
 */
public boolean mouseExit(Event e, int x, int y) {

    if (bDrag) {
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

        bDrag = false;
    }

    return true;
}
 
源代码28 项目: jdk8u-jdk   文件: AppletFrame.java
@Override
public void processEvent(AWTEvent e) {
    // Window Destroy event
    if (e.getID() == Event.WINDOW_DESTROY) {
        // exit the program
        System.exit(0);
    }
}
 
源代码29 项目: jdk8u-jdk   文件: CPopupMenu.java
@Override
public void show(Event e) {
    Component origin = (Component)e.target;
    if (origin != null) {
        Point loc = origin.getLocationOnScreen();
        e.x += loc.x;
        e.y += loc.y;
        execute(ptr -> nativeShowPopupMenu(ptr, e.x, e.y));
    }
}
 
源代码30 项目: openjdk-8   文件: AppletFrame.java
@Override
public void processEvent(AWTEvent e) {
    // Window Destroy event
    if (e.getID() == Event.WINDOW_DESTROY) {
        // exit the program
        System.exit(0);
    }
}