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

📄 basicinternalframeui.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
              switch (e.getID())                {                case MouseEvent.MOUSE_PRESSED:                  if (pressCount++ == 0)                    pressedComponent = mouseEventTarget;                  break;                case MouseEvent.MOUSE_RELEASED:                  // Clear our memory of the original PRESSED event, only if                  // we're not expecting a CLICKED event after this. If                  // there is a CLICKED event after this, it will do clean up.                  if (--pressCount == 0 && mouseEventTarget != pressedComponent)                    pressedComponent = null;                  break;                }            }        }    }  }  /**   * This helper class listens for PropertyChangeEvents from the   * JInternalFrame.   */  public class InternalFramePropertyChangeListener implements      PropertyChangeListener, VetoableChangeListener  {    /**     * This method is called when one of the JInternalFrame's properties change.     * This method is to allow JInternalFrame to veto an attempt to close the     * internal frame. This allows JInternalFrame to honour its     * defaultCloseOperation if that is DO_NOTHING_ON_CLOSE.     */    public void vetoableChange(PropertyChangeEvent e)        throws PropertyVetoException    {      if (e.getPropertyName().equals(JInternalFrame.IS_CLOSED_PROPERTY))        {          if (frame.getDefaultCloseOperation() == JInternalFrame.HIDE_ON_CLOSE)            {              frame.setVisible(false);              frame.getDesktopPane().repaint();              throw new PropertyVetoException(                                              "close operation is HIDE_ON_CLOSE\n",                                              e);            }          else if (frame.getDefaultCloseOperation() == JInternalFrame.DISPOSE_ON_CLOSE)            closeFrame(frame);          else            throw new PropertyVetoException(                                            "close operation is DO_NOTHING_ON_CLOSE\n",                                            e);        }    }    /**     * This method is called when one of the JInternalFrame's properties change.     *      * @param evt     *          The PropertyChangeEvent.     */    public void propertyChange(PropertyChangeEvent evt)    {      if (evt.getPropertyName().equals(JInternalFrame.IS_MAXIMUM_PROPERTY))        {          if (frame.isMaximum())            maximizeFrame(frame);          else            minimizeFrame(frame);        }      else if (evt.getPropertyName().equals(JInternalFrame.IS_ICON_PROPERTY))        {          if (frame.isIcon())            iconifyFrame(frame);          else            deiconifyFrame(frame);        }      else if (evt.getPropertyName().equals(JInternalFrame.IS_SELECTED_PROPERTY))        {          if (frame.isSelected())            activateFrame(frame);          else            deactivateFrame(frame);        }      else if (evt.getPropertyName().equals(JInternalFrame.ROOT_PANE_PROPERTY)               || evt.getPropertyName().equals(                                               JInternalFrame.GLASS_PANE_PROPERTY))        {          Component old = (Component) evt.getOldValue();          old.removeMouseListener(glassPaneDispatcher);          old.removeMouseMotionListener(glassPaneDispatcher);          Component newPane = (Component) evt.getNewValue();          newPane.addMouseListener(glassPaneDispatcher);          newPane.addMouseMotionListener(glassPaneDispatcher);          frame.revalidate();        }      /*       * FIXME: need to add ancestor properties to JComponents. else if       * (evt.getPropertyName().equals(JComponent.ANCESTOR_PROPERTY)) { if       * (desktopPane != null)       * desktopPane.removeComponentListener(componentListener); desktopPane =       * frame.getDesktopPane(); if (desktopPane != null)       * desktopPane.addComponentListener(componentListener); }       */    }  }  /**   * This helper class is the border for the JInternalFrame.   */  private class InternalFrameBorder extends AbstractBorder implements      UIResource  {    /** The width of the border. */    private static final int bSize = 5;    /** The size of the corners. */    private static final int offset = 10;    /**     * This method returns whether the border is opaque.     *      * @return Whether the border is opaque.     */    public boolean isBorderOpaque()    {      return true;    }    /**     * This method returns the insets of the border.     *      * @param c     *          The Component to find border insets for.     * @return The border insets.     */    public Insets getBorderInsets(Component c)    {      return new Insets(bSize, bSize, bSize, bSize);    }    /**     * This method paints the border.     *      * @param c     *          The Component that owns the border.     * @param g     *          The Graphics object to paint with.     * @param x     *          The x coordinate to paint at.     * @param y     *          The y coordinate to paint at.     * @param width     *          The width of the Component.     * @param height     *          The height of the Component.     */    public void paintBorder(Component c, Graphics g, int x, int y, int width,                            int height)    {      g.translate(x, y);      Color saved = g.getColor();      Rectangle b = frame.getBounds();      Color d = c.getBackground();      g.setColor(d);      g.fillRect(0, 0, bSize, b.height);      g.fillRect(0, 0, b.width, bSize);      g.fillRect(0, b.height - bSize, b.width, bSize);      g.fillRect(b.width - bSize, 0, bSize, b.height);      int x1 = 0;      int x2 = bSize;      int x3 = b.width - bSize;      int x4 = b.width;      int y1 = 0;      int y2 = bSize;      int y3 = b.height - bSize;      int y4 = b.height;      g.setColor(Color.GRAY);      g.fillRect(0, 0, bSize, y4);      g.fillRect(0, 0, x4, bSize);      g.fillRect(0, y3, b.width, bSize);      g.fillRect(x3, 0, bSize, b.height);      g.fill3DRect(0, offset, bSize, b.height - 2 * offset, false);      g.fill3DRect(offset, 0, b.width - 2 * offset, bSize, false);      g.fill3DRect(offset, b.height - bSize, b.width - 2 * offset, bSize, false);      g.fill3DRect(b.width - bSize, offset, bSize, b.height - 2 * offset, false);      g.translate(-x, -y);      g.setColor(saved);    }  }  /**   * The MouseListener that is responsible for dragging and resizing the   * JInternalFrame in response to MouseEvents.   */  protected MouseInputAdapter borderListener;  /**   * The ComponentListener that is responsible for resizing the JInternalFrame   * in response to ComponentEvents from the JDesktopPane.   */  protected ComponentListener componentListener;  /**   * The MouseListener that is responsible for activating the JInternalFrame   * when the mouse press activates one of its descendents.   */  protected MouseInputListener glassPaneDispatcher;  /**   * The PropertyChangeListener that is responsible for listening to   * PropertyChangeEvents from the JInternalFrame.   */  protected PropertyChangeListener propertyChangeListener;  /**   * The VetoableChangeListener.  Listens to PropertyChangeEvents   * from the JInternalFrame and allows the JInternalFrame to    * veto attempts to close it.   */  private VetoableChangeListener internalFrameVetoableChangeListener;  /** The InternalFrameListener that listens to the JInternalFrame. */  private transient BasicInternalFrameListener internalFrameListener;  /** The JComponent placed at the east region of the JInternalFrame. */  protected JComponent eastPane;  /** The JComponent placed at the north region of the JInternalFrame. */  protected JComponent northPane;  /** The JComponent placed at the south region of the JInternalFrame. */  protected JComponent southPane;  /** The JComponent placed at the west region of the JInternalFrame. */  protected JComponent westPane;  /**   * The Keystroke bound to open the menu.   * @deprecated   */  protected KeyStroke openMenuKey;  /** The TitlePane displayed at the top of the JInternalFrame. */  protected BasicInternalFrameTitlePane titlePane;  /** The JInternalFrame this UI is responsible for. */  protected JInternalFrame frame;  /** The LayoutManager used in the JInternalFrame. */  protected LayoutManager internalFrameLayout;  /** The JDesktopPane that is the parent of the JInternalFrame. */  private transient JDesktopPane desktopPane;  /**   * Creates a new BasicInternalFrameUI object.   *   * @param b The JInternalFrame this UI will represent.   */  public BasicInternalFrameUI(JInternalFrame b)  {    // Nothing to do here.  }  /**   * This method will create a new BasicInternalFrameUI for the given   * JComponent.   *   * @param b The JComponent to create a BasicInternalFrameUI for.   *   * @return A new BasicInternalFrameUI.   */  public static ComponentUI createUI(JComponent b)  {    return new BasicInternalFrameUI((JInternalFrame) b);  }  /**   * This method installs a UI for the JInternalFrame.   *   * @param c The JComponent to install this UI on.   */  public void installUI(JComponent c)  {    if (c instanceof JInternalFrame)      {        frame = (JInternalFrame) c;        internalFrameLayout = createLayoutManager();        frame.setLayout(internalFrameLayout);        ((JComponent) frame.getRootPane().getGlassPane()).setOpaque(false);        frame.getRootPane().getGlassPane().setVisible(true);        installDefaults();        installListeners();        installComponents();        installKeyboardActions();        frame.setOpaque(true);        frame.invalidate();      }  }  /**   * This method reverses the work done by installUI.   *   * @param c The JComponent to uninstall this UI for.   */  public void uninstallUI(JComponent c)  {    uninstallKeyboardActions();    uninstallComponents();    uninstallListeners();    uninstallDefaults();    frame.setLayout(null);    ((JComponent) frame.getRootPane().getGlassPane()).setOpaque(true);    frame.getRootPane().getGlassPane().setVisible(false);    frame = null;  }  /**   * This method installs the defaults specified by the look and feel.   */  protected void installDefaults()    {      LookAndFeel.installBorder(frame, "InternalFrame.border");      frame.setFrameIcon(UIManager.getIcon("InternalFrame.icon"));      // InternalFrames are invisible by default.      frame.setVisible(false);  }  /**   * This method installs the keyboard actions for the JInternalFrame.   */  protected void installKeyboardActions()  {    // FIXME: Implement.  }  /**   * This method installs the Components for the JInternalFrame.   */  protected void installComponents()  {    setNorthPane(createNorthPane(frame));    setSouthPane(createSouthPane(frame));    setEastPane(createEastPane(frame));    setWestPane(createWestPane(frame));  }  /**   * This method installs the listeners for the JInternalFrame.   */  protected void installListeners()  {    glassPaneDispatcher = createGlassPaneDispatcher();    createInternalFrameListener();    borderListener = createBorderListener(frame);    componentListener = createComponentListener();    propertyChangeListener = createPropertyChangeListener();    internalFrameVetoableChangeListener = new InternalFramePropertyChangeListener();    frame.addMouseListener(borderListener);    frame.addMouseMotionListener(borderListener);    frame.addInternalFrameListener(internalFrameListener);    frame.addPropertyChangeListener(propertyChangeListener);    frame.addVetoableChangeListener(internalFrameVetoableChangeListener);    frame.getRootPane().getGlassPane().addMouseListener(glassPaneDispatcher);    frame.getRootPane().getGlassPane().addMouseMotionListener(glassPaneDispatcher);  }  /**   * This method uninstalls the defaults for the JInternalFrame.   */  protected void uninstallDefaults()  {    frame.setBorder(null);  }  /**   * This method uninstalls the Components for the JInternalFrame.   */  protected void uninstallComponents()  {    setNorthPane(null);    setSouthPane(null);    setEastPane(null);    setWestPane(null);  }  /**   * This method uninstalls the listeners for the JInternalFrame.   */  protected void uninstallListeners()  {    if (desktopPane != null)      desktopPane.removeComponentListener(componentListener);    frame.getRootPane().getGlassPane().removeMouseMotionListener(glassPaneDispatcher);    frame.getRootPane().getGlassPane().removeMouseListener(glassPaneDispatcher);    frame.removePropertyChangeListener(propertyChangeListener);    frame.removeInternalFrameListener(internalFrameListener);    frame.removeMouseMotionListener(borderListener);    frame.removeMouseListener(borderListener);    propertyChangeListener = null;    componentListener = null;    borderListener = null;    internalFrameListener = null;    glassPaneDispatcher = null;  }  /**   * This method uninstalls the keyboard actions for the JInternalFrame.   */  protected void uninstallKeyboardActions()  {    // FIXME: Implement.  }

⌨️ 快捷键说明

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