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

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

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

JTextComponent.setFont介绍

暂无

代码示例

代码示例来源:origin: wiztools/rest-client

@Override
public void setEditorFont(Font font) {
  se_response.getEditorComponent().setFont(font);
}

代码示例来源:origin: wiztools/rest-client

@Override
public void setEditorFont(Font font) {
  se_req_body.getEditorComponent().setFont(font);
}

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

@Override
protected void installDefaults() {
  super.installDefaults();
  JTextComponent editor = getComponent();
  editor.setFont(RTextAreaBase.getDefaultFont());
  // Nimbus (and possibly other Synth lafs) doesn't play by BasicLaf
  // rules and doesn't set properties needed by custom BasicTextAreaUI's.
  correctNimbusDefaultProblems(editor);
  editor.setTransferHandler(DEFAULT_TRANSFER_HANDLER);
}

代码示例来源:origin: raydac/netbeans-mmd-plugin

public void fillByTextAndFont(@Nonnull final JTextComponent compo) {
 compo.setFont(this.font);
 compo.setText(this.text);
}

代码示例来源:origin: de.sciss/prefuse-core

/**
 * Sets the font used by this Display. This determines the font used
 * by this Display's text editor and in any debugging text.
 * @param f the Font to use
 */
public void setFont(Font f) {
  super.setFont(f);
  m_editor.setFont(f);
}

代码示例来源:origin: fcrepo3/fcrepo

@Override
public void init(String type, InputStream data, boolean viewOnly)
    throws IOException {
  if (type.endsWith("xml")) {
    m_xml = true;
  }
  m_editor = new JTextArea();
  m_editor.setFont(new Font("monospaced", Font.PLAIN, 12));
  setContent(data);
  m_editor.setEditable(!viewOnly);
  m_component = new JScrollPane(m_editor);
}

代码示例来源:origin: com.l2fprod.common/l2fprod-common-shared

public static void makeMultilineLabel(JTextComponent area) {
 area.setFont(UIManager.getFont("Label.font"));
 area.setEditable(false);
 area.setOpaque(false);    
 if (area instanceof JTextArea) {
  ((JTextArea)area).setWrapStyleWord(true);
  ((JTextArea)area).setLineWrap(true);
 }
}

代码示例来源:origin: SKCraft/Launcher

textComponent.setFont(new JLabel().getFont());
textComponent.setEditable(false);
textComponent.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);

代码示例来源:origin: com.l2fprod.common/l2fprod-common-shared

public BannerPanel() {
 setBorder(
  new CompoundBorder(new EtchedBorder(), LookAndFeelTweaks.PANEL_BORDER));
 setOpaque(true);
 setBackground(UIManager.getColor("Table.background"));
 titleLabel = new JLabel();
 titleLabel.setOpaque(false);
 subtitleLabel = new JEditorPane("text/html", "<html>");
 subtitleLabel.setFont(titleLabel.getFont());
 LookAndFeelTweaks.makeBold(titleLabel);
 LookAndFeelTweaks.makeMultilineLabel(subtitleLabel);
 LookAndFeelTweaks.htmlize(subtitleLabel);
 iconLabel = new JLabel();
 iconLabel.setPreferredSize(new Dimension(50, 50));
 setLayout(new BorderLayout());
 JPanel nestedPane = new JPanel(new BorderLayout());
 nestedPane.setOpaque(false);
 nestedPane.add("North", titleLabel);
 nestedPane.add("Center", subtitleLabel);
 add("Center", nestedPane);
 add("East", iconLabel);
}

代码示例来源:origin: de.sciss/prefuse-core

/**
 * Edit text for the given VisualItem and attribute. Presents a text
 * editing widget spanning the item's bounding box. Use stopEditing()
 * to hide the text widget. When stopEditing() is called, the data field
 * will automatically be updated with the VisualItem.
 * @param item the VisualItem to edit
 * @param attribute the attribute to edit
 */
public void editText(VisualItem item, String attribute) {
  if ( m_editing ) { stopEditing(); }
  Rectangle2D b = item.getBounds();
  Rectangle r = m_transform.createTransformedShape(b).getBounds();
  
  // hacky placement code that attempts to keep text in same place
  // configured under Windows XP and Java 1.4.2b
  if ( m_editor instanceof JTextArea ) {
    r.y -= 2; r.width += 22; r.height += 2;
  } else {
    r.x += 3; r.y += 1; r.width -= 5; r.height -= 2;
  }
  
  Font f = getFont();
  int size = (int)Math.round(f.getSize()*m_transform.getScaleX());
  Font nf = new Font(f.getFontName(), f.getStyle(), size);
  m_editor.setFont(nf);
  
  editText(item, attribute, r);
}

代码示例来源:origin: Spoutcraft/LegacyLauncher

/**
 * Build the interface.
 */
private void buildUI() {
  if (colorEnabled) {
    JTextPane text = new JTextPane();
    this.textComponent = text;
  } else {
    JTextArea text = new JTextArea();
    this.textComponent = text;
    text.setLineWrap(true);
  }
  textComponent.addMouseListener(this);
  textComponent.setFont(getMonospaceFont());
  textComponent.setEditable(false);
  DefaultCaret caret = (DefaultCaret) textComponent.getCaret();
  caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
  document = textComponent.getDocument();
  document.addDocumentListener(new LimitLinesDocumentListener(numLines, true));
  JScrollPane scrollText = new JScrollPane(textComponent);
  scrollText.setBorder(null);
  scrollText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  add(scrollText, BorderLayout.CENTER);
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

logView.setFont(new JLabel().getFont().deriveFont(12f));
logView.setEditable(false);

代码示例来源:origin: SKCraft/SKMCLauncher

textComponent.setFont(new JLabel().getFont());
textComponent.setEditable(false);
textComponent.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);

代码示例来源:origin: hneemann/Digital

private void init(Window parent, String str, boolean html) {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    JTextComponent textComp;
    if (html) {
      textComp = new JEditorPane("text/html", str);
      textComp.setCaretPosition(0);
      textComp.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
      textComp.setPreferredSize(Screen.getInstance().scale(new Dimension(600, 800)));
    } else {
      textComp = new JTextArea(str);
      textComp.setFont(new JLabel().getFont());
    }
    textComp.setEditable(false);
    textComp.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    getContentPane().add(new JScrollPane(textComp));

    pack();
    setLocationRelativeTo(parent);
  }
}

代码示例来源:origin: com.fifesoft/rsyntaxtextarea

@Override
protected void installDefaults() {
  super.installDefaults();
  JTextComponent editor = getComponent();
  editor.setFont(RTextAreaBase.getDefaultFont());
  // Nimbus (and possibly other Synth lafs) doesn't play by BasicLaf
  // rules and doesn't set properties needed by custom BasicTextAreaUI's.
  correctNimbusDefaultProblems(editor);
  editor.setTransferHandler(DEFAULT_TRANSFER_HANDLER);
}

代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea

protected void installDefaults() {
  super.installDefaults();
  JTextComponent editor = getComponent();
  editor.setFont(RTextAreaBase.getDefaultFont());
  // Nimbus (and possibly other Synth lafs) doesn't play by BasicLaf
  // rules and doesn't set properties needed by custom BasicTextAreaUI's.
  correctNimbusDefaultProblems(editor);
  editor.setTransferHandler(defaultTransferHandler);
}

代码示例来源:origin: hneemann/Digital

final TextLineNumber textLineNumber = new TextLineNumber(text, 3);
scrollPane.setRowHeaderView(textLineNumber);
text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, Screen.getInstance().getFontSize()));

代码示例来源:origin: io.ultreia.java4all.i18n/i18n-editor

private void updateTitle() {
  editor.setFont(editorFont);
  editor.setForeground(editorColor);
  setTitleFont(titleFont);
  setTitleForeground(titleColor);
  setTitle(titleText);
  setRightDecoration(model.isGlobalModified() ? rightDecoration : null);
}

代码示例来源:origin: atarw/material-ui-swing

private void installMyDefaults() {
  this.activeBackground = UIManager.getColor("TextField.selectionBackground");
  this.activeForeground = UIManager.getColor("TextField.selectionForeground");
  this.inactiveBackground = UIManager.getColor("TextField.inactiveBackground");
  this.inactiveForeground = UIManager.getColor("TextField.inactiveForeground");
  getComponent().setFont(MaterialFonts.REGULAR);
  getComponent().setSelectionColor(getComponent().hasFocus() && getComponent().isEnabled() ? activeBackground : inactiveBackground);
  getComponent().setSelectedTextColor(getComponent().hasFocus() && getComponent().isEnabled() ? activeForeground : inactiveForeground);
  getComponent().setForeground(getComponent().hasFocus() && getComponent().isEnabled() ? activeForeground : inactiveForeground);
  getComponent().setBorder(BorderFactory.createEmptyBorder(3, 5, 2,5));
}
@Override

代码示例来源:origin: threerings/tripleplay

/** Re-applies the current Field styles to the text component. */
public void validateStyles () {
  Font font = _element.resolveStyle(Style.FONT);
  _textComp.setFont(new java.awt.Font(font.name, awtFontStyle(font.style),
                    FloatMath.round(font.size)));
  Color col = new Color(_element.resolveStyle(Style.COLOR));
  _textComp.setForeground(col);
  _textComp.setCaretColor(col);
  if (isField()) {
    switch (_element.resolveStyle(Style.HALIGN)) {
    case CENTER:
      asField().setHorizontalAlignment(JTextField.CENTER);
      break;
    case LEFT:
      asField().setHorizontalAlignment(JTextField.LEFT);
      break;
    case RIGHT:
      asField().setHorizontalAlignment(JTextField.RIGHT);
      break;
    }
  }
  // TODO: Keyboard.TextType textType = resolveStyle(Field.TEXT_TYPE);
}

相关文章

JTextComponent类方法