📄 swingcomponentpeer.java
字号:
* @param width the width of the damaged rectangle * @param height the height of the damaged rectangle */ public void repaint(long tm, int x, int y, int width, int height) { if (swingComponent != null) swingComponent.getJComponent().repaint(tm, x, y, width, height); else { PaintEvent ev = new PaintEvent(awtComponent, PaintEvent.UPDATE, new Rectangle(x, y, width, height)); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ev); } } /** * Requests that this component receives the focus. This is called from * {@link Component#requestFocus()}. * * This calls requestFocus() on the Swing component. * * @specnote Part of the earlier 1.1 API, apparently replaced by argument * form of the same method. */ public void requestFocus() { if (swingComponent != null) swingComponent.getJComponent().requestFocus(); } /** * Requests that this component receives the focus. This is called from * {@link Component#requestFocus()}. * * This calls requestFocus() on the Swing component. * * @param source TODO * @param bool1 TODO * @param bool2 TODO * @param x TODO * * @return TODO */ public boolean requestFocus(Component source, boolean bool1, boolean bool2, long x) { if (swingComponent != null) swingComponent.getJComponent().requestFocus(); return swingComponent != null; } /** * Notifies the peer that the bounds of this component have changed. This * is called by {@link Component#reshape(int, int, int, int)}. * * This is implemented to call setBounds() on the Swing component. * * @param x the X coordinate of the upper left corner of the component * @param y the Y coordinate of the upper left corner of the component * @param width the width of the component * @param height the height of the component */ public void reshape(int x, int y, int width, int height) { if (swingComponent != null) swingComponent.getJComponent().setBounds(x, y, width, height); } /** * Sets the background color of the component. This is called by * {@link Component#setBackground(Color)}. * * This is implemented to call setBackground() on the Swing component. * * @param color the background color to set */ public void setBackground(Color color) { if (swingComponent != null) swingComponent.getJComponent().setBackground(color); } /** * Notifies the peer that the bounds of this component have changed. This * is called by {@link Component#setBounds(int, int, int, int)}. * * This is implemented to call setBounds() on the Swing component. * * @param x the X coordinate of the upper left corner of the component * @param y the Y coordinate of the upper left corner of the component * @param width the width of the component * @param height the height of the component */ public void setBounds(int x, int y, int width, int height) { if (swingComponent != null) swingComponent.getJComponent().setBounds(x, y, width, height); } /** * Sets the cursor of the component. This is called by * {@link Component#setCursor(Cursor)}. * * This is implemented to call setCursor() on the Swing component. * * @specnote Part of the earlier 1.1 API, apparently no longer needed. */ public void setCursor(Cursor cursor) { if (swingComponent != null) swingComponent.getJComponent().setCursor(cursor); } /** * Sets the enabled/disabled state of this component. This is called by * {@link Component#setEnabled(boolean)}. * * This is implemented to call setEnabled() on the Swing component. * * @param enabled <code>true</code> to enable the component, * <code>false</code> to disable it */ public void setEnabled(boolean enabled) { if (swingComponent != null) swingComponent.getJComponent().setEnabled(enabled); } /** * Sets the font of the component. This is called by * {@link Component#setFont(Font)}. * * This is implemented to call setFont() on the Swing component. * * @param font the font to set */ public void setFont(Font font) { if (swingComponent != null) swingComponent.getJComponent().setFont(font); } /** * Sets the foreground color of the component. This is called by * {@link Component#setForeground(Color)}. * * This is implemented to call setForeground() on the Swing component. * * @param color the foreground color to set */ public void setForeground(Color color) { if (swingComponent != null) swingComponent.getJComponent().setForeground(color); } /** * Sets the visibility state of the component. This is called by * {@link Component#setVisible(boolean)}. * * This is implemented to call setVisible() on the Swing component. * * @param visible <code>true</code> to make the component visible, * <code>false</code> to make it invisible */ public void setVisible(boolean visible) { if (swingComponent != null) swingComponent.getJComponent().setVisible(visible); } /** * Makes the component visible. This is called by {@link Component#show()}. * * This is implemented to call setVisible(true) on the Swing component. */ public void show() { if (swingComponent != null) swingComponent.getJComponent().setVisible(true); } /** * Get the graphics configuration of the component. The color model * of the component can be derived from the configuration. * * This is implemented to return the GraphicsConfiguration of the parent * component. This will eventually call the toplevel component peer, which * is expected to provide a real implementation. * * @return the graphics configuration of the component */ public GraphicsConfiguration getGraphicsConfiguration() { Component parent = awtComponent.getParent(); ComponentPeer parentPeer = parent.getPeer(); return parentPeer.getGraphicsConfiguration(); } /** * Part of an older API, no longer needed. */ public void setEventMask(long mask) { // Nothing to do here. } /** * Returns <code>true</code> if this component has been obscured, * <code>false</code> otherwise. This will only work if * {@link #canDetermineObscurity()} also returns <code>true</code>. * * This is not yet implemented. * * @return <code>true</code> if this component has been obscured, * <code>false</code> otherwise. */ public boolean isObscured() { return false; } /** * Returns <code>true</code> if this component peer can determine if the * component has been obscured, <code>false</code> otherwise. * * This is not yet implemented. * * @return <code>true</code> if this component peer can determine if the * component has been obscured, <code>false</code> otherwise */ public boolean canDetermineObscurity() { return false; } /** * Coalesces the specified paint event. * * @param e the paint event */ public void coalescePaintEvent(PaintEvent e) { // Nothing to do here yet. } /** * Updates the cursor. This is not yet implemented. */ public void updateCursorImmediately() { // Nothing to do here yet. } /** * Returns true, if this component can handle wheel scrolling, * <code>false</code> otherwise. * * This is not yet implemented and returns <code>false</code>. * * @return true, if this component can handle wheel scrolling, * <code>false</code> otherwise */ public boolean handlesWheelScrolling() { return false; } /** * A convenience method that creates a volatile image. The volatile * image is created on the screen device on which this component is * displayed, in the device's current graphics configuration. * * This is implemented to let the parent component peer create an image. * This eventually ends up in the toplevel component peer, which is then * responsible for creating the real image. * * @param width width of the image * @param height height of the image * * @see VolatileImage * * @since 1.2 */ public VolatileImage createVolatileImage(int width, int height) { Component parent = awtComponent.getParent(); ComponentPeer parentPeer = parent.getPeer(); return parentPeer.createVolatileImage(width, height); } /** * Create a number of image buffers that implement a buffering * strategy according to the given capabilities. * * This is implemented to forward to the parent component peer. Eventually * this ends up in the top level component peer, which is then responsible * for doing the real work. * * @param numBuffers the number of buffers * @param caps the buffering capabilities * * @throws AWTException if the specified buffering strategy is not * implemented * * @since 1.2 */ public void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException { Component parent = awtComponent.getParent(); ComponentPeer parentPeer = parent.getPeer(); parentPeer.createBuffers(numBuffers, caps); } /** * Return the back buffer of this component. * * This is implemented to forward to the parent. Eventually this ends * up in the toplevel component, which is then responsible for providing * a back buffer. * * @return the back buffer of this component. * * @since 1.2 */ public Image getBackBuffer() { Component parent = awtComponent.getParent(); ComponentPeer parentPeer = parent.getPeer(); return parentPeer.getBackBuffer(); } /** * Perform a page flip, leaving the contents of the back buffer in * the specified state. * * This is implemented to forward to the parent. Eventually this ends * up in the toplevel component, which is then responsible for doing the real * work. * * @param contents the state in which to leave the back buffer * * @since 1.2 */ public void flip(FlipContents contents) { Component parent = awtComponent.getParent(); ComponentPeer parentPeer = parent.getPeer(); parentPeer.flip(contents); } /** * Destroy the resources created by createBuffers. * * This is implemented to forward to the parent component peer. Eventually * this ends up in the top level component peer, which is then responsible * for doing the real work. * * @since 1.2 */ public void destroyBuffers() { Component parent = awtComponent.getParent(); ComponentPeer parentPeer = parent.getPeer(); parentPeer.destroyBuffers(); } /** * Get the bounds of this component peer. * * This is implemented to forward to the Swing component. * * @return component peer bounds * @since 1.5 */ public Rectangle getBounds() { Rectangle retVal; if (swingComponent != null) retVal = swingComponent.getJComponent().getBounds(); else retVal = new Rectangle(); return retVal; } /** * Reparent this component under another container. * * @param parent * @since 1.5 */ public void reparent(ContainerPeer parent) { // Nothing to do here. } /** * Set the bounds of this component peer. * * This is implemented to forward to the swing component. * * @param x the new x co-ordinate * @param y the new y co-ordinate * @param width the new width * @param height the new height * @param z the new stacking level * @since 1.5 */ public void setBounds(int x, int y, int width, int height, int z) { if (swingComponent != null) swingComponent.getJComponent().setBounds(x, y, width, height); // FIXME: Somehow handle the Z order. } /** * Check if this component supports being reparented. * * @return true if this component can be reparented, * false otherwise. * @since 1.5 */ public boolean isReparentSupported() { return true; } /** * Layout this component peer. * * @since 1.5 */ public void layout() { if (swingComponent != null) swingComponent.getJComponent().doLayout(); } /** * Triggers 'heavyweight' painting of the components. This usually calls * paint() on the Swing component. * * @param g the graphics context to use for painting */ protected void peerPaint(Graphics g) { if (swingComponent != null) swingComponent.getJComponent().paint(g); } /** * Handles mouse events on the component. This is usually forwarded to the * SwingComponent's processMouseEvent() method. * * @param e the mouse event */ protected void handleMouseEvent(MouseEvent e) { if (swingComponent != null) swingComponent.handleMouseEvent(e); } /** * Handles mouse motion events on the component. This is usually forwarded * to the SwingComponent's processMouseMotionEvent() method. * * @param e the mouse motion event */ protected void handleMouseMotionEvent(MouseEvent e) { if (swingComponent != null) swingComponent.handleMouseMotionEvent(e); } /** * Handles key events on the component. This is usually forwarded to the * SwingComponent's processKeyEvent() method. * * @param e the key event */ protected void handleKeyEvent(KeyEvent e) { if (swingComponent != null) swingComponent.handleKeyEvent(e); } /** * Returns the AWT component for this peer. * * @return the AWT component for this peer */ public Component getComponent() { return awtComponent; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -