javax.swing.text.JTextComponent.getUI()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中javax.swing.text.JTextComponent.getUI()方法的一些代码示例,展示了JTextComponent.getUI()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.getUI()方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:getUI

JTextComponent.getUI介绍

暂无

代码示例

代码示例来源:origin: groovy/groovy-core

public void paint(Graphics g) {
  if (isVisible()) {
    try {
      JTextComponent component = getComponent();
      Rectangle r = component.getUI().modelToView(component, getDot());
      Color c = g.getColor();
      g.setColor(component.getBackground());
      g.setXORMode(component.getCaretColor());
      r.setBounds(r.x, r.y,
          g.getFontMetrics().charWidth('w'),
          g.getFontMetrics().getHeight());
      g.fillRect(r.x, r.y, r.width, r.height);
      g.setPaintMode();
      g.setColor(c);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

TextUI mapper = c.getUI();
Rectangle p0 = mapper.modelToView(c, offs0);
Rectangle p1 = mapper.modelToView(c, offs1);

代码示例来源:origin: net.java.abeille/abeille

private static int getIDImpl(JTextComponent c) {
  if (c == null) {
    return -1;
  }
  return ((BaseTextUI) c.getUI()).componentID;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

private static int getIDImpl(JTextComponent c) {
  if (c == null) {
    return -1;
  }
  return ((BaseTextUI)c.getUI()).componentID;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public static ExtEditorUI getExtEditorUI(JTextComponent target) {
  TextUI ui = target.getUI();
  return (ui instanceof BaseTextUI)
    ? (ExtEditorUI)((BaseTextUI)ui).getEditorUI()
    : null;
}

代码示例来源:origin: net.java.abeille/abeille

/**
 * Helper method to obtain editor kit class from existing JTextComponent.
 * This method is useful for example when dealing with Settings. The method
 * doesn't require any document locking.
 * 
 * @param target
 *            JTextComponent for which the editor kit should be obtained
 * @return editor kit class
 */
public static Class getKitClass(JTextComponent target) {
  return (target != null) ? target.getUI().getEditorKit(target).getClass() : null;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

/** Helper method to obtain instance of editor kit from existing JTextComponent.
* If the kit of the component is not an instance
* of the <tt>org.netbeans.editor.BaseKit</tt> the method returns null.
* The method doesn't require any document locking.
* @param target JTextComponent for which the editor kit should be obtained
* @return BaseKit instance or null
*/
public static BaseKit getKit(JTextComponent target) {
  if (target == null) return null; // #19574
  EditorKit ekit = target.getUI().getEditorKit(target);
  return (ekit instanceof BaseKit) ? (BaseKit)ekit : null;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

/** Helper method to obtain editor kit class from existing JTextComponent.
* This method is useful for example when dealing with Settings.
* The method doesn't require any document locking.
* @param target JTextComponent for which the editor kit should be obtained
* @return editor kit class
*/
public static Class getKitClass(JTextComponent target) {
  return (target != null) ? target.getUI().getEditorKit(target).getClass() : null;
}

代码示例来源:origin: net.java.abeille/abeille

/**
 * Helper method to obtain instance of EditorUI (extended UI) from the
 * existing JTextComponent. It doesn't require any document locking.
 * 
 * @param target
 *            JTextComponent for which the extended UI should be obtained
 * @return extended ui instance or null if the component.getUI() does not
 *         return BaseTextUI instance.
 */
public static EditorUI getEditorUI(JTextComponent target) {
  TextUI ui = target.getUI();
  return (ui instanceof BaseTextUI) ? ((BaseTextUI) ui).getEditorUI() : null;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

private BaseTextUI getBaseTextUI(){
  JTextComponent comp = getComponent();
  return (comp!=null)?(BaseTextUI)comp.getUI():null;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public static int getPreviousWord(JTextComponent c, int offset)
throws BadLocationException {
  int prevWordOffset = getPreviousWord((BaseDocument)c.getDocument(), offset);
  int nextVisualPosition = c.getUI().getNextVisualPositionFrom(c,
             prevWordOffset, null, javax.swing.SwingConstants.WEST, null);
  return (nextVisualPosition + 1 == prevWordOffset) ?  prevWordOffset : nextVisualPosition + 1;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public static int getNextWord(JTextComponent c, int offset)
throws BadLocationException {
  int nextWordOffset = getNextWord((BaseDocument)c.getDocument(), offset);
  int nextVisualPosition = c.getUI().getNextVisualPositionFrom(c,
             nextWordOffset, null, javax.swing.SwingConstants.EAST, null);
  return (nextVisualPosition - 1 == nextWordOffset) ?  nextWordOffset : nextVisualPosition - 1;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-lexer-editorbridge

private String updateColoringName(String coloringName) {
  EditorKit kit = component.getUI().getEditorKit(component);
  if (kit instanceof LexerEditorKit) {
    String updatedName = ((LexerEditorKit)kit).updateColoringName(coloringName);
    if (updatedName != null) {
      coloringName = updatedName;
    }
  }
  return coloringName;
}

代码示例来源:origin: net.java.abeille/abeille

public void mouseDragged(MouseEvent evt) {
  JTextComponent c = component;
  if (SwingUtilities.isLeftMouseButton(evt)) {
    if (c != null) {
      int offset = ((BaseTextUI) c.getUI()).viewToModel(c, evt.getX(), evt.getY());
      // fix for #15204
      if (offset == -1)
        offset = 0;
      moveDot(offset);
    }
  }
}

代码示例来源:origin: net.java.abeille/abeille

public void run() {
    if (component != null) {
      BaseTextUI ui = (BaseTextUI) component.getUI();
      ui.updateHeight();
      component.repaint();
    }
  }
});

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-lexer-editorbridge

public void tokenHierarchyChanged(TokenHierarchyEvent evt) {
  javax.swing.plaf.TextUI ui = (javax.swing.plaf.TextUI)component.getUI();
  int startRepaintOffset = evt.affectedStartOffset();
  int endRepaintOffset = Math.max(evt.affectedEndOffset(), startRepaintOffset + 1);
  ui.damageRange(component, startRepaintOffset, endRepaintOffset);
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-lexer-editorbridge

private String getMimeType(JTextComponent c) {
  Object mimeTypeProp = c.getDocument().getProperty("mimeType"); //NOI18N
  if (mimeTypeProp instanceof String) {
    return (String) mimeTypeProp;
  } else {
    return c.getUI().getEditorKit(c).getContentType();
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mylyn-util

private void makeCaretVisible(JTextComponent textComponent) {
  int pos = textComponent.getCaretPosition();
  try {
    Rectangle rec = textComponent.getUI().modelToView(textComponent, pos);
    if (rec != null) {
      Point p = SwingUtilities.convertPoint(textComponent, rec.x, rec.y, this);
      scrollRectToVisible(new Rectangle(p.x, p.y, rec.width, rec.height));
    }
  } catch (BadLocationException blex) {
    LOG.log(Level.INFO, blex.getMessage(), blex);
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public void focusGained(FocusEvent evt) {
    Registry.activate(getComponent());
    /* Fix of #25475 - copyAction's enabled flag
    * must be updated on focus change
    */
    stateChanged(null);
    if (component!=null){
     BaseTextUI ui = (BaseTextUI)component.getUI();
     if (ui!=null) ui.refresh();
    }
  }
};

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public void paint(Graphics g, Shape allocation) {
  super.paint(g, allocation);
  if (getContainer() instanceof javax.swing.text.JTextComponent){
    TextUI textUI = ((javax.swing.text.JTextComponent)getContainer()).getUI();
    if (textUI instanceof BaseTextUI){
      ((BaseTextUI) textUI).getEditorUI().paint(g);
    }
  }
}

相关文章

JTextComponent类方法