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

📄 basictextui.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    textComponent.removeFocusListener(focuslistener);    textComponent.getDocument().removeDocumentListener(documentHandler);  }  /**   * Uninstalls all keyboard actions that have previously been installed by   * this UI.   */  protected void uninstallKeyboardActions()  {    // FIXME: Uninstall keyboard actions here.  }  /**   * Returns the property prefix by which the text component's UIDefaults   * are looked up.   *   * @return the property prefix by which the text component's UIDefaults   *     are looked up   */  protected abstract String getPropertyPrefix();  /**   * Returns the preferred size of the text component.   *   * @param c not used here   *   * @return the preferred size of the text component   */  public Dimension getPreferredSize(JComponent c)  {    View v = getRootView(textComponent);    float w = v.getPreferredSpan(View.X_AXIS);    float h = v.getPreferredSpan(View.Y_AXIS);    return new Dimension((int) w, (int) h);  }  /**   * Returns the maximum size for text components that use this UI.   *   * This returns (Integer.MAX_VALUE, Integer.MAX_VALUE).   *   * @param c not used here   *   * @return the maximum size for text components that use this UI   */  public Dimension getMaximumSize(JComponent c)  {    // Sun's implementation returns Integer.MAX_VALUE here, so do we.    return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);  }  /**   * Returns the minimum size for text components. This returns the size   * of the component's insets.   *   * @return the minimum size for text components   */  public Dimension getMinimumSize(JComponent c)  {    Insets i = c.getInsets();    return new Dimension(i.left + i.right, i.top + i.bottom);  }  /**   * Paints the text component.   *   * @param g the <code>Graphics</code> context to paint to   * @param c not used here   */  public final void paint(Graphics g, JComponent c)  {    paintSafely(g);  }  /**   * Actually performs the painting.   *   * @param g the <code>Graphics</code> context to paint to   */  protected void paintSafely(Graphics g)  {    Caret caret = textComponent.getCaret();    Highlighter highlighter = textComponent.getHighlighter();    if (textComponent.isOpaque())      paintBackground(g);    if (highlighter != null	&& textComponent.getSelectionStart() != textComponent.getSelectionEnd())      highlighter.paint(g);    rootView.paint(g, getVisibleEditorRect());    if (caret != null && textComponent.hasFocus())      caret.paint(g);  }  /**   * Paints the background of the text component.   *   * @param g the <code>Graphics</code> context to paint to   */  protected void paintBackground(Graphics g)  {    // This method does nothing. All the background filling is done by the    // ComponentUI update method. However, the method is called by paint    // to provide a way for subclasses to draw something different (e.g.    // background images etc) on the background.  }  /**   * Marks the specified range inside the text component's model as   * damaged and queues a repaint request.   *   * @param t the text component   * @param p0 the start location inside the document model of the range that   *        is damaged   * @param p1 the end location inside the document model of the range that   *        is damaged   */  public void damageRange(JTextComponent t, int p0, int p1)  {    damageRange(t, p0, p1, null, null);  }  /**   * Marks the specified range inside the text component's model as   * damaged and queues a repaint request. This variant of this method   * allows a {@link Position.Bias} object to be specified for the start   * and end location of the range.   *   * @param t the text component   * @param p0 the start location inside the document model of the range that   *        is damaged   * @param p1 the end location inside the document model of the range that   *        is damaged   * @param firstBias the bias for the start location   * @param secondBias the bias for the end location   */  public void damageRange(JTextComponent t, int p0, int p1,                          Position.Bias firstBias, Position.Bias secondBias)  {    // TODO: Implement me.  }  /**   * Returns the {@link EditorKit} used for the text component that is managed   * by this UI.   *   * @param t the text component   *   * @return the {@link EditorKit} used for the text component that is managed   *         by this UI   */  public EditorKit getEditorKit(JTextComponent t)  {    return kit;  }  /**   * Gets the next position inside the document model that is visible on   * screen, starting from <code>pos</code>.   *   * @param t the text component   * @param pos the start positionn   * @param b the bias for pos   * @param direction the search direction   * @param biasRet filled by the method to indicate the bias of the return   *        value   *   * @return the next position inside the document model that is visible on   *         screen   */  public int getNextVisualPositionFrom(JTextComponent t, int pos,                                       Position.Bias b, int direction,                                       Position.Bias[] biasRet)    throws BadLocationException  {    return 0; // TODO: Implement me.  }  /**   * Returns the root {@link View} of a text component.   *   * @return the root {@link View} of a text component   */  public View getRootView(JTextComponent t)  {    return rootView;  }  /**   * Maps a position in the document into the coordinate space of the View.   * The output rectangle usually reflects the font height but has a width   * of zero. A bias of {@link Position.Bias#Forward} is used in this method.   *   * @param t the text component   * @param pos the position of the character in the model   *   * @return a rectangle that gives the location of the document position   *         inside the view coordinate space   *   * @throws BadLocationException if <code>pos</code> is invalid   * @throws IllegalArgumentException if b is not one of the above listed   *         valid values   */  public Rectangle modelToView(JTextComponent t, int pos)    throws BadLocationException  {    return modelToView(t, pos, Position.Bias.Forward);  }  /**   * Maps a position in the document into the coordinate space of the View.   * The output rectangle usually reflects the font height but has a width   * of zero.   *   * @param t the text component   * @param pos the position of the character in the model   * @param bias either {@link Position.Bias#Forward} or   *        {@link Position.Bias#Backward} depending on the preferred   *        direction bias. If <code>null</code> this defaults to   *        <code>Position.Bias.Forward</code>   *   * @return a rectangle that gives the location of the document position   *         inside the view coordinate space   *   * @throws BadLocationException if <code>pos</code> is invalid   * @throws IllegalArgumentException if b is not one of the above listed   *         valid values   */  public Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias)    throws BadLocationException  {    return rootView.modelToView(pos, getVisibleEditorRect(), bias).getBounds();  }  /**   * Maps a point in the <code>View</code> coordinate space to a position   * inside a document model.   *   * @param t the text component   * @param pt the point to be mapped   *   * @return the position inside the document model that corresponds to   *     <code>pt</code>   */  public int viewToModel(JTextComponent t, Point pt)  {    return viewToModel(t, pt, null);  }  /**   * Maps a point in the <code>View</code> coordinate space to a position   * inside a document model.   *   * @param t the text component   * @param pt the point to be mapped   * @param biasReturn filled in by the method to indicate the bias of the   *        return value   *   * @return the position inside the document model that corresponds to   *     <code>pt</code>   */  public int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn)  {    return rootView.viewToModel(pt.x, pt.y, getVisibleEditorRect(), biasReturn);  }  /**   * Creates a {@link View} for the specified {@link Element}.   *   * @param elem the <code>Element</code> to create a <code>View</code> for   *   * @see ViewFactory   */  public View create(Element elem)  {    // Subclasses have to implement this to get this functionality.    return null;  }  /**   * Creates a {@link View} for the specified {@link Element}.   *   * @param elem the <code>Element</code> to create a <code>View</code> for   * @param p0 the start offset   * @param p1 the end offset   *   * @see ViewFactory   */  public View create(Element elem, int p0, int p1)  {    // Subclasses have to implement this to get this functionality.    return null;  }  /**   * Returns the allocation to give the root view.   *   * @return the allocation to give the root view   *   * @specnote The allocation has nothing to do with visibility. According   *           to the specs the naming of this method is unfortunate and   *           has historical reasons   */  protected Rectangle getVisibleEditorRect()  {    JTextComponent textComponent = getComponent();    int width = textComponent.getWidth();    int height = textComponent.getHeight();    if (width <= 0 || height <= 0)      return new Rectangle(0, 0, 0, 0);	    Insets insets = textComponent.getInsets();    return new Rectangle(insets.left, insets.top,			 width - insets.left - insets.right,			 height - insets.top - insets.bottom);  }  /**   * Sets the root view for the text component.   *   * @param view the <code>View</code> to be set as root view   */  protected final void setView(View view)  {    rootView.setView(view);    view.setParent(rootView);    textComponent.revalidate();    textComponent.repaint();  }  /**   * Indicates that the model of a text component has changed. This   * triggers a rebuild of the view hierarchy.   */  protected void modelChanged()  {    if (textComponent == null || rootView == null)       return;    ViewFactory factory = rootView.getViewFactory();    if (factory == null)       return;    Document doc = textComponent.getDocument();    if (doc == null)      return;    installDocumentListeners();    Element elem = doc.getDefaultRootElement();    if (elem == null)      return;    View view = factory.create(elem);    setView(view);  }  /**   * Receives notification whenever one of the text component's bound   * properties changes. This default implementation does nothing.   * It is a hook that enables subclasses to react to property changes   * on the text component.   *   * @param ev the property change event   */  protected void propertyChange(PropertyChangeEvent ev)  {    // The default implementation does nothing.  }}

⌨️ 快捷键说明

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