⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 window.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            lastClickButton == button) {            //Toolkit.getEventQueue().postEvent(new MouseEvent (this, MouseEvent.MOUSE_CLICKED, when, modifiers, x, y, clickCount, popupTrigger));            SunToolkit.postEvent(appContext,new MouseEvent (this, MouseEvent.MOUSE_CLICKED, when, modifiers, x, y, clickCount, popupTrigger));            lastClickTime = when;        }    }    /** Posts mouse events, other than button presses or releases, to the event queue for this     window. This method is called from native code when a mouse event is received. It could also     be called from Robot implementations if it is not possible to generate mouse events at     the native level (that is why it has been made package protected and not private). */    void postMouseEvent(int id, int modifiers, int x, int y) {        //Toolkit.getEventQueue().postEvent(new MouseEvent (this, id, System.currentTimeMillis(), modifiers, x, y, 0, false));        SunToolkit.postEvent(appContext, new MouseEvent (this, id, System.currentTimeMillis(), modifiers, x, y, 0, false));    }    void postKeyEvent(int id, int modifiers,                               int keyCode, char keyChar) {            long when = System.currentTimeMillis();        // get the current focus owner. if one exists then dispatch the        // key events to the owner's event queue. If not check if the        // window is focusable and dispatch it to the window's event queue        // not using getFocusOwner() since we will incur a appcontext         // check and not get the focus owner, so use getGlobalFocusOwner()        Component focusOwner =             KeyboardFocusManager.getCurrentKeyboardFocusManager().            getGlobalFocusOwner();        sun.awt.AppContext context = this.appContext ;        if ( focusOwner != null )            context = focusOwner.appContext;        SunToolkit.postEvent(context,            new KeyEvent (this, id, when, modifiers, keyCode, keyChar));    }    /**     * Returns the child component of this Window which has focus if and     * only if this Window is active.     * @return the component with focus, or null if no children have focus     * assigned to them.     */    public Component getFocusOwner() {        return (isFocused()) ?             KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()            : null;    }    /**     * Checks if this Window is showing on screen.     * @see java.awt.Component#setVisible(boolean)     */    public boolean isShowing() {        return visible;    }    /**     * The window serialized data version.     *     * @serial     */    private int windowSerializedDataVersion = 1;    /**     * Writes default serializable fields to stream.  Writes     * a list of serializable ItemListener(s) as optional data.     * The non-serializable ItemListener(s) are detected and     * no attempt is made to serialize them. Write a list of     * child Windows as optional data.     *     * @serialData Null terminated sequence of 0 or more pairs.     *             The pair consists of a String and Object.     *             The String indicates the type of object and     *             is one of the following :     *             itemListenerK indicating an ItemListener object.     * @serialData Null terminated sequence of 0 or more pairs.     *             The pair consists of a String and Object.     *             The String indicates the type of object and     *             is one of the following :     *             ownedWindowK indicating a child Window object.     *     * @see AWTEventMulticaster.save(ObjectOutputStream, String, EventListener)     * @see java.awt.Component.itemListenerK     * @see java.awt.Component.ownedWindowK     */    private void writeObject(ObjectOutputStream s)        throws IOException {}    /**     * Read the default ObjectInputStream, a possibly null listener to     * receive item events fired by the Window, and a possibly null     * list of child Windows.     * Unrecognised keys or values will be Ignored.     *     * @see removeActionListener()     * @see addActionListener()     */    private void readObject(ObjectInputStream s)        throws ClassNotFoundException, IOException {}    /**     * Update the cursor is decided by the dispatcher     * This method is used when setCursor on a lightweight     */    void updateCursor(Component comp) {        // 6229858 - if this component is the toplevel frame, change the         // cursor here instead of deferring to the LightweightDispatcher        if (comp instanceof Window) {            Cursor cursor = comp.getCursor();            changeCursor(cursor);        }        else {            dispatcher.updateCursor(comp);        }    }    /* Native wrapper for changing cursor bitmap */    private native void pChangeCursor(int cursorType);    /*      * 6221221     * Native method for setting the warning string     */    private native int pSetWarningString(String warningString);        /**     * Changes the cursor displayed in this frame to the supplied cursor.     * This is used for lightweight components. It does not affect the     * return value for getCursor on this frame.     * @see LightweightDispatcher     */    void changeCursor(Cursor cursor) {        pChangeCursor(cursor.type);    }    public Graphics getGraphics() {        Graphics g = null;        if (displayable) {            if (this.visible)                g = getToolkit().getGraphics(this);            else                g = new NullGraphics(this);        }        return g;    }    /**     * This method returns the GraphicsConfiguration used by this Window.     */    public GraphicsConfiguration getGraphicsConfiguration() {        return graphicsConfig;    }    /** The time the last mouse click event ocurred at. */    private long lastClickTime;    /** The click count used for mouse events. */    private int clickCount = 1;    /** Position of last mouse click. */    private int lastClickX, lastClickY;    /** Modifiers used the last time the mouse was clicked. */    //private int lastClickModifiers;    /** The button number that was last clicked. */    private int lastClickButton;// Focus-related functionality added //-------------------------------------------------------------------------    private transient Component temporaryLostComponent;    transient WindowFocusListener windowFocusListener;    private boolean focusableWindowState = true;    public synchronized void addWindowFocusListener(WindowFocusListener l) {        if (l == null) {            return;        }        windowFocusListener = AWTEventMulticaster.add(windowFocusListener, l);    }//    public synchronized WindowFocusListener[] getWindowFocusListeners() {//        return (WindowFocusListener[])(getListeners(WindowFocusListener.class));//    }    public synchronized void removeWindowFocusListener(WindowFocusListener l) {        if (l == null) {            return;        }        windowFocusListener = AWTEventMulticaster.remove(windowFocusListener, l);    }    /**     * Returns an array of all the window focus listeners     * registered on this window.     *     * @return all of this window's <code>WindowFocusListener</code>s     *         or an empty array if no window focus     *         listeners are currently registered     *     * @see #addWindowFocusListener     * @see #removeWindowFocusListener     * @since 1.4     */    public synchronized WindowFocusListener[] getWindowFocusListeners() {        return (WindowFocusListener[]) AWTEventMulticaster.getListeners(                                       (EventListener)windowFocusListener,                                        WindowFocusListener.class);    }    public final boolean isFocusableWindow() {        // If a Window/Frame was made non-focusable,        // then it is always non-focusable.        if (!getFocusableWindowState()) {            return false;        }        // All other tests apply only to Windows.        if (this instanceof Frame) {            return true;        }        // A Window must have at least one Component in its root focus        // traversal cycle to be focusable.        if (getFocusTraversalPolicy().getDefaultComponent(this) == null) {            return false;        }        // A Window's nearest owning Frame or Dialog must be showing        // on the screen.        for (Window owner = getOwner(); owner != null;             owner = owner.getOwner()) {            if (owner instanceof Frame) {                return owner.isShowing();            }        }        return false;    }    public boolean getFocusableWindowState() {        return focusableWindowState;    }    public void setFocusableWindowState(boolean focusableWindowState) {        boolean oldFocusableWindowState;        synchronized (this) {            oldFocusableWindowState = this.focusableWindowState;            this.focusableWindowState = focusableWindowState;        }        firePropertyChange("focusableWindowState",                            new Boolean(oldFocusableWindowState),                           new Boolean(focusableWindowState));        if (oldFocusableWindowState && !focusableWindowState && isFocused()) {            for (Window owner = (Window)getParent(); owner != null;                owner = (Window)owner.getParent()) {                Component toFocus =                    KeyboardFocusManager.getMostRecentFocusOwner(owner);                if (toFocus != null && toFocus.requestFocus(false)) {                    return;                }            }            KeyboardFocusManager.getCurrentKeyboardFocusManager().                clearGlobalFocusOwner();        }    }    protected void processWindowFocusEvent(WindowEvent e) {        WindowFocusListener listener = windowFocusListener;        if (listener != null) {            switch (e.getID()) {            case WindowEvent.WINDOW_GAINED_FOCUS:                listener.windowGainedFocus(e);                break;            case WindowEvent.WINDOW_LOST_FOCUS:                listener.windowLostFocus(e);                break;            default:                break;            }        }    }    public Component getMostRecentFocusOwner() {        if (isFocused()) {            return getFocusOwner();        } else {            Component mostRecent =            KeyboardFocusManager.getMostRecentFocusOwner(this);            if (mostRecent != null) {                return mostRecent;            } else {                return (isFocusableWindow()) ?                    getFocusTraversalPolicy().getInitialComponent(this) : null;            }        }    }    /**     * Returns whether this Window is active. Only a Frame or a Dialog may be     * active. The native windowing system may denote the active Window or its     * children with special decorations, such as a highlighted title bar. The     * active Window is always either the focused Window, or the first Frame or     * Dialog that is an owner of the focused Window.     *     * @return whether this is the active Window.     * @see #isFocused     * @since 1.4     */    public boolean isActive() {        return (KeyboardFocusManager.getCurrentKeyboardFocusManager().                getActiveWindow() == this);    }    public boolean isFocused() {        return (KeyboardFocusManager.getCurrentKeyboardFocusManager().            getGlobalFocusedWindow() == this);    }    public Set getFocusTraversalKeys(int id) {        if (id < 0 || id >= KeyboardFocusManager.TRAVERSAL_KEY_LENGTH) {            throw new IllegalArgumentException("invalid focus traversal key identifier");        }        // Okay to return Set directly because it is an unmodifiable view        Set keystrokes = (focusTraversalKeys != null) ?             focusTraversalKeys[id] : null;        if (keystrokes != null) {            return keystrokes;        } else {            return KeyboardFocusManager.getCurrentKeyboardFocusManager().                getDefaultFocusTraversalKeys(id);        }    }    public final void setFocusCycleRoot(boolean focusCycleRoot) {    }    public final boolean isFocusCycleRoot() {        return true;    }    public final Container getFocusCycleRootAncestor() {        return null;    }    Component getTemporaryLostComponent() {        return temporaryLostComponent;    }    Component setTemporaryLostComponent(Component component) {        Component previousComp = temporaryLostComponent;        // Check that "component" is an acceptable focus owner and don't store it otherwise         // - or later we will have problems with opposite while handling  WINDOW_GAINED_FOCUS        if (component == null ||            (component.isDisplayable() && component.isVisible() &&              component.isEnabled() && component.isFocusable())) {            temporaryLostComponent = component;        } else {            temporaryLostComponent = null;        }        return previousComp;    }    private Window getOwner() {        return (Window)parent;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -