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

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

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

JTextField.setFont介绍

暂无

代码示例

代码示例来源:origin: deathmarine/Luyten

public JTextField getFontSizeTextField() {
  if (fontSizeTextField == null) {
    fontSizeTextField = new JTextField();
    fontSizeTextField.addFocusListener(new TextFieldFocusHandlerForTextSelection(fontSizeTextField));
    fontSizeTextField.addKeyListener(new TextFieldKeyHandlerForListSelectionUpDown(getFontSizeList()));
    fontSizeTextField.getDocument()
        .addDocumentListener(new ListSearchTextFieldDocumentHandler(getFontSizeList()));
    fontSizeTextField.setFont(DEFAULT_FONT);
  }
  return fontSizeTextField;
}

代码示例来源:origin: stackoverflow.com

import java.awt.*;
import javax.swing.*;

public class CopyTextNorthPanel2 extends JPanel {

  private static final long serialVersionUID = 1L;
  public JTextField northField;

  public CopyTextNorthPanel2() {
   northField = new JTextField("Welcome World");
   northField.setFont(new Font("Serif", Font.BOLD, 20));
   northField.setPreferredSize(new Dimension(300, 25));
   add(northField);
  }

  public String getNorthFieldText() {
   return northField.getText();
  }
}

代码示例来源:origin: stackoverflow.com

tf.setPlaceholder("All your base are belong to us!");
final Font f = tf.getFont();
tf.setFont(new Font(f.getName(), f.getStyle(), 30));
JOptionPane.showMessageDialog(null, tf);

代码示例来源:origin: geotools/geotools

title.setFont(new Font("Arial", Font.BOLD, 14));
c.gridx = 0;
c.gridy = 0;
description.setFont(new Font("Arial", Font.PLAIN, 11));
c.gridx = 0;
c.gridy = 1;
label1.setFont(new Font("Arial", Font.BOLD, 12));
c.gridx = 0;
c.gridy = 2;
page.add(processList);
descLabel = new JTextField(defaultDesc, 35);
descLabel.setEditable(false);
Border border = new LineBorder(this.getPanel().getBackground(), 0);
descLabel.setBorder(border);
descLabel.setFont(new Font("Arial", Font.PLAIN, 11));
c.gridx = 1;
c.gridy = 3;

代码示例来源:origin: deathmarine/Luyten

public JTextField getFontStyleTextField() {
  if (fontStyleTextField == null) {
    fontStyleTextField = new JTextField();
    fontStyleTextField.addFocusListener(new TextFieldFocusHandlerForTextSelection(fontStyleTextField));
    fontStyleTextField.addKeyListener(new TextFieldKeyHandlerForListSelectionUpDown(getFontStyleList()));
    fontStyleTextField.getDocument()
        .addDocumentListener(new ListSearchTextFieldDocumentHandler(getFontStyleList()));
    fontStyleTextField.setFont(DEFAULT_FONT);
  }
  return fontStyleTextField;
}

代码示例来源:origin: IanDarwin/javasrc

public void actionPerformed(ActionEvent evt) {
    JTextField jtf = (JTextField)evt.getSource();
    String fontName = jtf.getText();
    Font font = new Font(fontName, Font.BOLD, 18);
    tf.setFont(font);
  }
});

代码示例来源:origin: magefree/mage

jLabel3 = new JLabel();
title = new JTextField();
jScrollPane2 = new JScrollPane();
jLabel1.setFont(new Font("Times New Roman", 1, 18));
jLabel1.setForeground(textColor);
jLabel1.setText(message);
jLabel3.setText("Selected:");
title.setFont(new Font("Tahoma", 1, 11));
title.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
rows.setFont(new Font("Times New Roman", 1, 17));
rows.setBorder(BorderFactory.createEmptyBorder());
rows.addMouseWheelListener(this);

代码示例来源:origin: deathmarine/Luyten

public JTextField getFontFamilyTextField() {
  if (fontFamilyTextField == null) {
    fontFamilyTextField = new JTextField();
    fontFamilyTextField.addFocusListener(new TextFieldFocusHandlerForTextSelection(fontFamilyTextField));
    fontFamilyTextField.addKeyListener(new TextFieldKeyHandlerForListSelectionUpDown(getFontFamilyList()));
    fontFamilyTextField.getDocument()
        .addDocumentListener(new ListSearchTextFieldDocumentHandler(getFontFamilyList()));
    fontFamilyTextField.setFont(DEFAULT_FONT);
  }
  return fontFamilyTextField;
}

代码示例来源:origin: Var3D/var3dframe

public void setFontSize(int fontSize){
  textField.setFont(new Font(null,0,fontSize));
  textMessage.setFont(textField.getFont());
}

代码示例来源:origin: stackoverflow.com

JTextField textField = new JTextField();
textField.setFont(new Font("Verdana", 1, 12));
textField.setBorder(new LineBorder(Color.BLACK));
DefaultCellEditor dce = new DefaultCellEditor( textField );
myTable.getColumnModel().getColumn(1).setCellEditor(dce);

代码示例来源:origin: JetBrains/ideavim

myParent = editor.getContentComponent();
myLabel = new JLabel(prompt);
myEntry = new JTextField();
myEntry.setFont(font);

代码示例来源:origin: protegeproject/protege

public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
  Font f = table.getCellRenderer(row, column).getTableCellRendererComponent(table,
                                       "",
                                       false,
                                       false,
                                       row,
                                       column).getFont();
  textField.setFont(new Font(f.getName(), f.getStyle(), f.getSize()));
  textField.setText(value.toString());
  return textField;
}

代码示例来源:origin: semuxproject/semux-core

/**
 * Generates a text field with copy-paste-cut popup menu.
 *
 * @return
 */
public static JTextField textFieldWithCopyPastePopup() {
  JTextField textField = new JTextField();
  textField.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13));
  addTextContextMenu(textField, Arrays.asList(COPY, PASTE, CUT));
  addTextMouseClickFocusListener(textField);
  return textField;
}

代码示例来源:origin: nodebox/nodebox

protected JTextComponent createField() {
  JTextField textField = new JTextField();
  textField.putClientProperty("JComponent.sizeVariant", "small");
  textField.setFont(Theme.SMALL_BOLD_FONT);
  textField.addActionListener(this);
  textField.addFocusListener(new FocusAdapter() {
    public void focusLost(FocusEvent e) {
      commitTextFieldValue();
    }
  });
  return textField;
}

代码示例来源:origin: edu.stanford.protege/protege-editor-owl

public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
  Font f = table.getCellRenderer(row, column).getTableCellRendererComponent(table,
                                       "",
                                       false,
                                       false,
                                       row,
                                       column).getFont();
  textField.setFont(new Font(f.getName(), f.getStyle(), f.getSize()));
  textField.setText(value.toString());
  return textField;
}

代码示例来源:origin: org.apache.geronimo.daytrader/daytrader-wsappclient

/**
   * This method initializes jTextField12
   *
   * @return JTextField
   */
  private JTextField getJTextField12() {
    if(jTextField12 == null) {
      jTextField12 = new JTextField();
      jTextField12.setBounds(138, 16, 202, 16);
      jTextField12.setFont(new java.awt.Font("sansserif", 1, 10));
      jTextField12.setText(ClientScenario.getServicePort());
    }
    return jTextField12;
  }
} //  @jve:visual-info  decl-index=0 visual-constraint="0,0"

代码示例来源:origin: nodebox/nodebox

public FileControl(String nodePath, Port port) {
  super(nodePath, port);
  setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
  fileField = new JTextField();
  fileField.putClientProperty("JComponent.sizeVariant", "small");
  fileField.setPreferredSize(new Dimension(150, 19));
  fileField.setEditable(false);
  fileField.setFont(Theme.SMALL_BOLD_FONT);
  chooseButton = new JButton("...");
  chooseButton.putClientProperty("JButton.buttonType", "gradient");
  chooseButton.setPreferredSize(new Dimension(30, 27));
  chooseButton.addActionListener(this);
  add(fileField);
  add(chooseButton);
  setValueForControl(port.getValue());
}

代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl

public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
  Font f = table.getCellRenderer(row, column).getTableCellRendererComponent(table,
                                       "",
                                       false,
                                       false,
                                       row,
                                       column).getFont();
  textField.setFont(new Font(f.getName(), f.getStyle(), f.getSize()));
  textField.setText(value.toString());
  return textField;
}

代码示例来源:origin: org.apache.geronimo.samples.daytrader.modules/wsappclient

/**
   * This method initializes jTextField12
   *
   * @return JTextField
   */
  private JTextField getJTextField12() {
    if(jTextField12 == null) {
      jTextField12 = new JTextField();
      jTextField12.setBounds(138, 16, 202, 16);
      jTextField12.setFont(new java.awt.Font("sansserif", 1, 10));
      jTextField12.setText(ClientScenario.getServicePort());
    }
    return jTextField12;
  }
} //  @jve:visual-info  decl-index=0 visual-constraint="0,0"

代码示例来源:origin: nodebox/nodebox

public TextControl(String nodePath, Port port) {
  super(nodePath, port);
  setLayout(new BorderLayout(0, 0));
  textField = new JTextField();
  textField.putClientProperty("JComponent.sizeVariant", "small");
  textField.setFont(Theme.SMALL_BOLD_FONT);
  textField.addActionListener(this);
  externalWindowButton = new JButton("...");
  externalWindowButton.putClientProperty("JComponent.sizeVariant", "small");
  externalWindowButton.putClientProperty("JButton.buttonType", "gradient");
  externalWindowButton.setFont(Theme.SMALL_BOLD_FONT);
  externalWindowButton.addActionListener(this);
  add(textField, BorderLayout.CENTER);
  add(externalWindowButton, BorderLayout.EAST);
  setValueForControl(port.getValue());
}

相关文章

JTextField类方法