精华内容
下载资源
问答
  • 本文整理匯總了Java中javax.swing.JTextField.setFont方法典型用法代碼示例。如果您正苦於以下問題:Java JTextField.setFont方法具體用法?Java JTextField.setFont怎麽用?Java JTextField.setFont使用例子...

    本文整理匯總了Java中javax.swing.JTextField.setFont方法的典型用法代碼示例。如果您正苦於以下問題:Java JTextField.setFont方法的具體用法?Java JTextField.setFont怎麽用?Java JTextField.setFont使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JTextField的用法示例。

    在下文中一共展示了JTextField.setFont方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

    示例1: CheckBoxFrame

    ​點讚 3

    import javax.swing.JTextField; //導入方法依賴的package包/類

    public CheckBoxFrame()

    {

    super("JCheckBox Test");

    setLayout(new FlowLayout());

    // set up JTextField and set its font

    textField = new JTextField("Watch the font style change", 20);

    textField.setFont(new Font("Serif", Font.PLAIN, 14));

    add(textField); // add textField to JFrame

    boldJCheckBox = new JCheckBox("Bold");

    italicJCheckBox = new JCheckBox("Italic");

    add(boldJCheckBox); // add bold checkbox to JFrame

    add(italicJCheckBox); // add italic checkbox to JFrame

    // register listeners for JCheckBoxes

    CheckBoxHandler handler = new CheckBoxHandler();

    boldJCheckBox.addItemListener(handler);

    italicJCheckBox.addItemListener(handler);

    }

    開發者ID:cleitonferreira,項目名稱:LivroJavaComoProgramar10Edicao,代碼行數:21,

    示例2: JFilePicker

    ​點讚 3

    import javax.swing.JTextField; //導入方法依賴的package包/類

    public JFilePicker(String textFieldLabel, String buttonLabel) {

    setLayout(new FlowLayout(FlowLayout.CENTER, 5, 1));

    // creates the GUI

    label = new JLabel(textFieldLabel);

    label.setFont(new Font("Arial", Font.BOLD, 16));

    textField = new JTextField(30);

    textField.setFont(new Font("Arial", Font.PLAIN, 12));

    textField.setText(WorkspaceFile.getPathWorkspace());

    button = new JButton(buttonLabel);

    button.setFont(new Font("Arial", Font.BOLD, 14));

    label.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

    textField.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

    button.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

    add(button);

    add(textField);

    add(label);

    button.addActionListener(this);

    }

    開發者ID:BlidiWajdi,項目名稱:Mujeed-Arabic-Prolog,代碼行數:25,

    示例3: getTableCellEditorComponent

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    /**

    * It sets the cursot at the beginnig of edited cell, in case of searching it highlights the found text.

    * At the end it request for focus so the editor component (JTextField) has it, not the table.

    * This is also a hack with reason to figure out which cell is going to be edited, if a key or a value.

    */

    @Override

    public Component getTableCellEditorComponent(JTable table,

    Object value, boolean isSelected, int row, int column) {

    // Key or value? Only in the first column are keys.

    isKeyCell = (column == 0) ? true : false;

    valueComponent.getDocument().removeDocumentListener(listener);

    commentComponent.getDocument().removeDocumentListener(listener);

    final JTextField textField = (JTextField)super.getTableCellEditorComponent(table, value, isSelected, row, column);

    valueComponent.getDocument().addDocumentListener(listener);

    commentComponent.getDocument().addDocumentListener(listener);

    Caret caret = textField.getCaret();

    caret.setVisible(true);

    caret.setDot(0);

    textField.setFont(settings.getFont());

    // Check for search results.

    // If search was performed, highlight the found string.

    int[] result = (int[])table.getClientProperty(FindPerformer.TABLE_SEARCH_RESULT);

    if(result != null && row == result[0] && column == result[1]) {

    table.putClientProperty(FindPerformer.TABLE_SEARCH_RESULT, null); // removes property

    caret.setDot(result[2]);

    caret.moveDot(result[3]);

    }

    return textField;

    }

    開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,

    示例4: Channel

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    /**

    * Create the frame to choose the channel

    */

    public Channel() {

    this.setTitle("Chat IRC");

    this.setResizable(false);

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    this.setBounds(100, 100, 460, 261);

    this.setLocationRelativeTo(null);

    setIconImage(Toolkit.getDefaultToolkit().getImage(Channel.class.getResource("/image/swag.png")));

    contentPane = new JPanel();

    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

    setContentPane(contentPane);

    contentPane.setLayout(null);

    JButton btnOk = new JButton("OK");

    Icon imgOk = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Channel.class.getResource("/image/ok.png")));

    btnOk.setIcon(imgOk);

    btnOk.setFont(new Font("Tahoma", Font.BOLD, 14));

    btnOk.addActionListener(new ChannelListener());

    btnOk.setBounds(164, 152, 104, 30);

    contentPane.add(btnOk);

    JLabel lblChannel = new JLabel("Channel");

    lblChannel.setHorizontalAlignment(SwingConstants.LEFT);

    lblChannel.setFont(new Font("Tahoma", Font.BOLD, 14));

    lblChannel.setBounds(187, 30, 72, 30);

    contentPane.add(lblChannel);

    textFieldChannel = new JTextField();

    textFieldChannel.setFont(new Font("Tahoma", Font.PLAIN, 14));

    textFieldChannel.setBounds(115, 85, 203, 30);

    contentPane.add(textFieldChannel);

    textFieldChannel.setColumns(10);

    this.addWindowListener( new WindowAdapter() {

    public void windowClosing(WindowEvent e) {

    closeFrame();

    }

    });

    }

    開發者ID:LittleSnake42,項目名稱:java-irc,代碼行數:42,

    示例5: focusGained

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    @Override

    public void focusGained(FocusEvent e) {

    if(isEmpty) {

    JTextField field = (JTextField)realEditor.getEditorComponent();

    field.setText("");

    field.setFont(normalFont);

    }

    }

    開發者ID:GateNLP,項目名稱:gate-core,代碼行數:9,

    示例6: JTextFieldDemo1

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    public static void JTextFieldDemo1() {

    jf = new JFrame("TextField����");

    final Container contentPane = jf.getContentPane();

    contentPane.setLayout(new BorderLayout());

    jp = new JPanel();

    jtf1 = new JTextField();

    jtf2 = new JTextField(10);

    jtf3 = new JTextField("ָ���ı�����");

    jtf4 = new JTextField("ָ������+ָ������(ֻ��״̬)", 30);

    jtf3.setEnabled(false); // true���Ա༭

    jtf4.setFont(new Font("����", Font.BOLD | Font.ITALIC, 16)); // ���壬�Ƿ�Ӵ֡�б�壬�ֺ�

    // �����ı���ˮƽ���뷽ʽ

    jtf4.setHorizontalAlignment(SwingConstants.CENTER);

    jp.add(jtf1);

    jp.add(jtf2);

    jp.add(jtf3);

    jp.add(jtf4);

    contentPane.add(jp);

    jf.pack();

    jf.setLocation(400, 200);

    jf.setVisible(true);

    jf.addWindowListener(new WindowAdapter() {

    @Override

    public void windowClosing(WindowEvent e) {

    System.exit(0);

    }

    });

    }

    開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:37,

    示例7: StringControl

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    public StringControl(final Object f, PropertyDescriptor p) {

    super();

    final String name = p.getName();

    final Method r = p.getReadMethod(), w = p.getWriteMethod();

    setterMap.put(name, this);

    clazz = f;

    write = w;

    read = r;

    setLayout(new GridLayout(1, 0));

    // setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    setAlignmentX(ALIGNMENT);

    final JLabel label = new JLabel(name);

    label.setAlignmentX(ALIGNMENT);

    label.setFont(label.getFont().deriveFont(fontSize));

    addTip(p, label);

    add(label);

    textField = new JTextField(name);

    textField.setFont(textField.getFont().deriveFont(fontSize));

    textField.setHorizontalAlignment(SwingConstants.LEADING);

    textField.setColumns(10);

    add(label);

    add(textField);

    refresh();

    textField.addActionListener(new ActionListener() {

    public void actionPerformed(ActionEvent e) {

    try {

    w.invoke(clazz, textField.getText());

    } catch (Exception e2) {

    e2.printStackTrace();

    }

    }

    });

    }

    開發者ID:SensorsINI,項目名稱:jaer,代碼行數:38,

    示例8: init

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    private void init() {

    textField = new JTextField("");

    textField.setFont(new java.awt.Font("",0,15));

    textField.setHorizontalAlignment(JTextField.CENTER);

    gbLayout = new GridBagLayout();

    gbConst = new GridBagConstraints();

    panel = new JPanel();

    // panel.setBorder(new javax.swing.border.TitledBorder("JPST")); //JPanel of Slider and TextField

    setLabel("");

    panel.setLayout(gbLayout);

    column = 5;

    slider = new DecimalSlider();

    slider.setSize(200,40);

    slider.setPaintTicks(true);

    slider.setPaintLabels(true);

    slider.setDecimalSliderValue(300);

    setMinimum(0);

    setMaximum(500);

    slider.addChangeListener(new SliderListener());

    slider.setDecimalSliderMajorTickSpacing(100);

    slider.setDecimalSliderMinorTickSpacing(50);

    gbConst.gridx = 0; gbConst.gridy = 0;

    gbLayout.setConstraints(slider, gbConst);

    panel.add(slider);

    showSlider = true;

    setShowValues(false); // default is false to show values of slider

    setEditValues(false); // default is false to edit values of slider thru textField

    }

    開發者ID:etomica,項目名稱:etomica,代碼行數:31,

    示例9: richiediNome

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    private void richiediNome() {

    nome = null;

    askNome = new JTextField();

    JButton askNomeButton = new JButton(caricaImmagine("dominio/immagini/fatto.png"));

    JLabel askNomeLabel = new JLabel(caricaImmagine("dominio/immagini/richiediNome.png"));

    ActionListener action_nome_inserito = new ActionListener(){

    @Override

    public void actionPerformed(ActionEvent e) {

    nome = askNome.getText();

    };

    };

    askNome.setFont(new Font("nome", 1, 40));

    askNome.setBounds(this.getWidth()/2 - 125, 300, 250, 80);

    askNomeButton.setBounds(this.getWidth()/2 - 100, 400, 200, 80);

    askNomeLabel.setBounds(this.getWidth()/2 - 200, 100, 400, 80);

    askNome.addActionListener(action_nome_inserito);

    askNomeButton.addActionListener(action_nome_inserito);

    sfondo.add(askNome);

    sfondo.add(askNomeButton);

    sfondo.add(askNomeLabel);

    sfondo.repaint();

    while(nome == null) {

    pausa(100);

    }

    sfondo.removeAll();

    sfondo.repaint();

    fireViewEvent(new SetNome(nome));

    }

    開發者ID:IngSW-unipv,項目名稱:Progetto-A,代碼行數:36,

    示例10: stylizeTextField

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    public void stylizeTextField(JTextField t){

    t.setFont(font_14_bold);

    t.setForeground(Color.BLACK);

    t.setBackground(Color.WHITE);

    t.setHorizontalAlignment(JTextField.CENTER);

    }

    開發者ID:kevingilboy,項目名稱:COE1186,代碼行數:7,

    示例11: Login

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    /**

    * Create the frame to login

    */

    public Login() {

    this.setTitle("Client IRC");

    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    this.setResizable(false);

    this.setBounds(100, 100, 460, 261);

    this.setLocationRelativeTo(null);

    setIconImage(Toolkit.getDefaultToolkit().getImage(Login.class.getResource("/image/swag.png")));

    contentPane = new JPanel();

    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

    contentPane.setLayout(null);

    this.setContentPane(contentPane);

    JButton btnLogin = new JButton("Login");

    Icon imgOk = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Login.class.getResource("/image/ok.png")));

    btnLogin.setIcon(imgOk);

    btnLogin.setFont(new Font("Tahoma", Font.BOLD, 14));

    btnLogin.addActionListener(new ValidateConnectionListener());

    btnLogin.setBounds(217, 154, 139, 30);

    contentPane.add(btnLogin);

    JLabel lblNickname = new JLabel("Nickname");

    lblNickname.setHorizontalAlignment(SwingConstants.LEFT);

    lblNickname.setFont(new Font("Tahoma", Font.BOLD, 14));

    lblNickname.setBounds(179, 37, 86, 30);

    contentPane.add(lblNickname);

    JLabel lblIpServer = new JLabel("IP Server");

    lblIpServer.setFont(new Font("Tahoma", Font.BOLD, 14));

    lblIpServer.setBounds(179, 95, 86, 30);

    contentPane.add(lblIpServer);

    textFieldNickname = new JTextField();

    textFieldNickname.setFont(new Font("Tahoma", Font.PLAIN, 14));

    textFieldNickname.setBounds(286, 38, 145, 30);

    contentPane.add(textFieldNickname);

    textFieldNickname.setColumns(10);

    textFieldServer = new JTextField();

    textFieldServer.setFont(new Font("Tahoma", Font.PLAIN, 14));

    textFieldServer.setBounds(286, 96, 145, 30);

    contentPane.add(textFieldServer);

    textFieldServer.setColumns(10);

    JLabel lblImage = new JLabel("");

    lblImage.setBounds(23, 11, 146, 173);

    Icon imgLogin = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Login.class.getResource("/image/login-msn.png")));

    lblImage.setIcon(imgLogin);

    contentPane.add(lblImage);

    this.addWindowListener( new WindowAdapter() {

    public void windowClosing(WindowEvent e) {

    closeFrame();

    }

    });

    }

    開發者ID:LittleSnake42,項目名稱:java-irc,代碼行數:60,

    示例12: RadioButtonFrame

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    public RadioButtonFrame()

    {

    super("RadioButton Test");

    setLayout(new FlowLayout());

    textField = new JTextField("Watch the font style change", 25);

    add(textField); // add textField to JFrame

    // create radio buttons

    plainJRadioButton = new JRadioButton("Plain", true);

    boldJRadioButton = new JRadioButton("Bold", false);

    italicJRadioButton = new JRadioButton("Italic", false);

    boldItalicJRadioButton = new JRadioButton("Bold/Italic", false);

    add(plainJRadioButton); // add plain button to JFrame

    add(boldJRadioButton); // add bold button to JFrame

    add(italicJRadioButton); // add italic button to JFrame

    add(boldItalicJRadioButton); // add bold and italic button

    // create logical relationship between JRadioButtons

    radioGroup = new ButtonGroup(); // create ButtonGroup

    radioGroup.add(plainJRadioButton); // add plain to group

    radioGroup.add(boldJRadioButton); // add bold to group

    radioGroup.add(italicJRadioButton); // add italic to group

    radioGroup.add(boldItalicJRadioButton); // add bold and italic

    // create font objects

    plainFont = new Font("Serif", Font.PLAIN, 14);

    boldFont = new Font("Serif", Font.BOLD, 14);

    italicFont = new Font("Serif", Font.ITALIC, 14);

    boldItalicFont = new Font("Serif", Font.BOLD + Font.ITALIC, 14);

    textField.setFont(plainFont);

    // register events for JRadioButtons

    plainJRadioButton.addItemListener(

    new RadioButtonHandler(plainFont));

    boldJRadioButton.addItemListener(

    new RadioButtonHandler(boldFont));

    italicJRadioButton.addItemListener(

    new RadioButtonHandler(italicFont));

    boldItalicJRadioButton.addItemListener(

    new RadioButtonHandler(boldItalicFont));

    }

    開發者ID:cleitonferreira,項目名稱:LivroJavaComoProgramar10Edicao,代碼行數:43,

    示例13: initGui

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    void initGui() {

    Font font = new Font("Courier", Font.PLAIN, 14);

    command = new JTextField(40);

    command.setFont(font);

    command.setToolTipText("Type a Jason operation here.");

    command.addActionListener(new ActionListener() {

    @Override

    public void actionPerformed(ActionEvent arg0) {

    execCmd(command.getText().trim());

    }

    });

    //mindPanel = new JTextPane();

    //mindPanel.setEditable(false);

    //mindPanel.setContentType("text/html");

    output = new JTextArea(5,50);

    output.setFont(font);

    output.setEditable(false);

    output.setText("Example of operations you can type:\n +bel; !goal; .add_plan({+!goal

    output.append(" ?bel(A); .findall(X,bel(X),L); \n");

    output.append(" .mi // to open mind inspector\n");

    output.append(" .verbose(2) // to show debug messages\n");

    output.append(" .clear // clean console\n");

    output.append("\nYou can add more agents using the button 'new REPL ag' in MAS Console.");

    output.append("\n");

    frame = new JFrame(".:: REPL Interface for "+getTS().getUserAgArch().getAgName()+" ::.");

    frame.getContentPane().setLayout(new BorderLayout());

    frame.getContentPane().add(BorderLayout.NORTH,command);

    //f.getContentPane().add(BorderLayout.CENTER, new JScrollPane(mindPanel));

    frame.getContentPane().add(BorderLayout.CENTER,new JScrollPane(output));

    frame.pack();

    int h = 200;

    int w = (int)(h*2*1.618);

    frame.setBounds((int)(h*0.618), 20, w, h);

    frame.setLocation(lastPos, 200+lastPos);

    lastPos += 50;

    frame.setVisible(true);

    }

    開發者ID:nickrfer,項目名稱:code-sentinel,代碼行數:44,

    示例14: installUI

    ​點讚 2

    import javax.swing.JTextField; //導入方法依賴的package包/類

    @Override

    public void installUI(JComponent c) {

    super.installUI(c);

    jtf = (JTextField) c;

    JTextField editor = jtf;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    Font f = editor.getFont();

    if ((f == null) || (f instanceof UIResource)) {

    editor.setFont(uidefaults.getFont(prefix + ".font"));

    }

    Color bg = editor.getBackground();

    if ((bg == null) || (bg instanceof UIResource)) {

    editor.setBackground(uidefaults.getColor(prefix + ".background"));

    }

    Color fg = editor.getForeground();

    if ((fg == null) || (fg instanceof UIResource)) {

    editor.setForeground(uidefaults.getColor(prefix + ".foreground"));

    }

    Color color = editor.getCaretColor();

    if ((color == null) || (color instanceof UIResource)) {

    editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));

    }

    Color s = editor.getSelectionColor();

    if ((s == null) || (s instanceof UIResource)) {

    editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));

    }

    Color sfg = editor.getSelectedTextColor();

    if ((sfg == null) || (sfg instanceof UIResource)) {

    editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));

    }

    Color dfg = editor.getDisabledTextColor();

    if ((dfg == null) || (dfg instanceof UIResource)) {

    editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));

    }

    Border b = editor.getBorder();

    if ((b == null) || (b instanceof UIResource)) {

    editor.setBorder(uidefaults.getBorder(prefix + ".border"));

    }

    Insets margin = editor.getMargin();

    if (margin == null || margin instanceof UIResource) {

    editor.setMargin(uidefaults.getInsets(prefix + ".margin"));

    }

    }

    開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:57,

    注:本文中的javax.swing.JTextField.setFont方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

    展开全文
  • import javax.swing.... //导入方法依赖package包/类@NbBundle.Messages({"# {0} - icon path", "IssuePanel.attachmentsToSubmit=Unsubmitted Attachments"+ "New attachments were added but not yet sub...

    import javax.swing.AbstractButton; //导入方法依赖的package包/类

    @NbBundle.Messages({

    "# {0} - icon path",

    "IssuePanel.attachmentsToSubmit=

    %5C%22%7B0%7D%5C%22 Unsubmitted Attachments

    "

    + "

    New attachments were added but not yet submitted

    ",

    "IssuePanel.attachmentsAddedLocally=Attachments were added but not yet submitted"

    })

    private void updateAttachmentsStatus () {

    boolean change = false;

    if (!issue.isNew()) {

    boolean valueModifiedByUser = !issue.getUnsubmittedAttachments().isEmpty();

    removeTooltips(attachmentsWarning, IssueField.NB_NEW_ATTACHMENTS);

    AbstractButton attachmentsLabel = attachmentsSection.getLabelComponent();

    if (attachmentsLabel.getFont().isBold()) {

    attachmentsLabel.setFont(attachmentsLabel.getFont().deriveFont(attachmentsLabel.getFont().getStyle() & ~Font.BOLD));

    }

    if (valueModifiedByUser) {

    String message = Bundle.IssuePanel_attachmentsAddedLocally();

    tooltipsLocal.addTooltip(attachmentsWarning, IssueField.NB_NEW_ATTACHMENTS,

    Bundle.IssuePanel_attachmentsToSubmit(ICON_UNSUBMITTED_PATH));

    change = !message.equals(fieldsLocal.put(IssueField.NB_NEW_ATTACHMENTS, message));

    } else {

    change = fieldsLocal.remove(IssueField.NB_NEW_ATTACHMENTS) != null;

    }

    updateIcon(attachmentsWarning);

    if (unsavedFields.contains(IssueField.NB_NEW_ATTACHMENTS.getKey())) {

    attachmentsLabel.setFont(attachmentsLabel.getFont().deriveFont(attachmentsLabel.getFont().getStyle() | Font.BOLD));

    }

    }

    if (change && !reloading) {

    updateMessagePanel();

    }

    }

    展开全文
  • import javafx.scene.... //導入方法依賴package包/類public HeaderPanel(AppSession session) {this.session = session;content = new HBox(5);content.setPadding(new Insets(5));setCenter(content);textC...

    import javafx.scene.control.TextArea; //導入方法依賴的package包/類

    public HeaderPanel(AppSession session) {

    this.session = session;

    content = new HBox(5);

    content.setPadding(new Insets(5));

    setCenter(content);

    textContent = new TextArea();

    textContent.setPrefRowCount(16);

    textContent.setVisible(false);

    setBottom(textContent);

    textContent.setManaged(false);

    textContent.setFont(App.getDefaultFont());

    textContent.focusedProperty().addListener((val, before, after) -> {

    if (!after) { // if we lost focus

    rebuildFeatureIfTextChanged();

    }

    });

    MenuBar menuBar = new MenuBar();

    Menu fileMenu = new Menu("File");

    openFileMenuItem = new MenuItem("Open");

    fileMenu.getItems().addAll(openFileMenuItem);

    Menu importMenu = new Menu("Import");

    openImportMenuItem = new MenuItem("Open");

    importMenu.getItems().addAll(openImportMenuItem);

    menuBar.getMenus().addAll(fileMenu, importMenu);

    setTop(menuBar);

    if (session != null) {

    Label envLabel = new Label("karate.env");

    envLabel.setPadding(new Insets(5, 0, 0, 0));

    TextField envTextField = new TextField();

    envTextField.setText(session.getEnv().env);

    Button envButton = new Button("Reset");

    envButton.setOnAction(e -> session.resetAll(envTextField.getText()));

    Button runAllButton = new Button("Run ►►");

    runAllButton.setOnAction(e -> session.runAll());

    Button showContentButton = new Button(getContentButtonText(false));

    initTextContent();

    showContentButton.setOnAction(e -> {

    boolean visible = !textContent.isVisible();

    textContent.setVisible(visible);

    textContent.setManaged(visible);

    showContentButton.setText(getContentButtonText(visible));

    });

    content.getChildren().addAll(envLabel, envTextField, envButton, runAllButton, showContentButton);

    }

    }

    展开全文
  • Javasetfont的使用(转)

    千次阅读 2017-12-28 21:11:21
    java.awt.Font 设计字体显示效果 Font mf = new Font(String 字体,int 风格,int 字号); 字体:TimesRoman, Courier, Arial等 ...设置组件当前使用字体:setFont(Font fn) 获取组件当前使用字体:getFo

    java.awt.Font
    设计字体显示效果 Font mf = new Font(String 字体,int 风格,int 字号);
    字体:TimesRoman, Courier, Arial等
    风格:三个常量 lFont.PLAIN, Font.BOLD, Font.ITALIC
    字号:字的大小(磅数)
    设置组件当前使用的字体:setFont(Font fn)
    获取组件当前使用的字体:getFont()

    int i= font.stringWidth(String str);获取str字符的长度

    详细说明

    getFont(int face,int style,int size). 例如:
    Font font = Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font. SIZE_MEDIUM). 无论哪一个参数,都只能使用系统设置的数值,这些数值具体的大小在不同的手机上可能不同。下面对于其中的三个参数的取值做详细的介绍: face参数指字体的外观,其的值:   FACE_MONOSPACE——等宽字体l
    FACE_PROPORTIONAL——均衡字体l
    FACE_SYSTEM——系统字体style参数指字体的样式,其的取值:l
    STYLE_BOLD——粗体l
    STYLE_ITALIC——斜体l
    STYLE_PLAIN——普通l
    STYLE_UNDERLINED——下划线l
    STYLE_BOLD | STYLE_ITALIC——粗斜体l
    STYLE_UNDERLINED | STYLE_BOLD——带下划线粗体l
    STYLE_UNDERLINED | STYLE_ITALIC——带下划线斜体l
    STYLE_UNDERLINED | STYLE_ITALIC | STYLE_BOLD——带下划线的粗斜体size参数指字体的大小,其的取值:l
    SIZE_SMALL——小l
    SIZE_MEDIUM——中l
    SIZE_LARGE——大通过上面的参数的值,可以组合出你需要的字体对象。下面是一些常用的字体操作:

      1. 获得系统的默认字体:Font font = Font.getDefaultFont().

     

      2. 在panit方法内部,假设Graphics参数的名称为g,则获得当前字体的方法是:Font font = g.getFont().

      3. 在panit方法内部,假设Graphics参数的名称为g,则设置当前字体的方法是:g.setFont(font).其中font为你构造好的字体对象。

    展开全文
  • } } 调用BufferedImage.getGraphics()获得Graphics 错误原因:调用setColor(),setFont()会失败 求原因 提问:窗体提供g和BufferedImage.getGraphics()同样是Graphics类 但是前者能设置字体颜色,后者不行,为什么 ...
  • 字体:TimesRoman, Courier, Arial等风格:三个常量 lFont.PLAIN, Font.BOLD, Font.ITALIC字号:字大小(磅数)设置组件当前使用字体:setFont(Font fn)获取组件当前使用字体:getFont()i...
  • import java.awt.Label; //导入方法依赖package包/类public MainFrame() {this.setTitle(FRAME_TITLE);this.setResizable(false);this.setLayout(null);Dimension windowSize = Toolkit.getDefaultToolkit()....
  • 字体:TimesRoman, Courier, Arial等风格:三个常量 lFont.PLAIN, Font.BOLD, Font.ITALIC字号:字大小(磅数)设置组件当前使用字体:setFont(Font fn)获取组件当前使用字体:getFont()i...
  • 我注意到,如果标签文本是HTML(Mac上不会发生这种情况),则将忽略指定给setFont的字体. HTML格式对复杂显示器可读性非常有用.在正常情况下,我会在HTML标签中指定字体,但是我使用字体在运行时使用Font.createFont...
  • 我注意到,如果标签文本是HTML(Mac上不会发生这种情况),则将忽略指定给setFont的字体. HTML格式对复杂显示器可读性非常有用.在正常情况下,我会在HTML标签中指定字体,但是我使用字体在运行时使用Font.createFont...
  • 本文整理匯總了Java中javafx.scene.text.Text.setFont方法典型用法代碼示例。如果您正苦於以下問題:Java Text.setFont方法具體用法?Java Text.setFont怎麽用?Java Text.setFont使用例子?那麽恭喜您, 這裏...
  • 我是Java新手.我正在尝试使用带有按钮swing创建简单GUI,该按钮会更改JFreeChart库中图表字体.但是,当我使用chart.setFont时,它会使GUI冻结了几秒钟.我读到我应该在其他线程中使用setFont来避免该问题,但是它...
  • //导入方法依赖package包/类/*** Create the frame.*/public HistoryViewer(String[] transactions) {this.transactions = transactions;int screenPositionX = (int) Toolkit.getDefaultToolkit...
  • Java程序设计中setFont()函数用法(转)

    万次阅读 多人点赞 2015-09-17 09:59:09
    java.awt.Font 设计字体显示效果 Font mf = new Font(String 字体,int 风格,int 字号); 字体:TimesRoman, Courier, Arial等 ...设置组件当前使用字体:setFont(Font fn) 获取组件当前使用
  • import ... //导入方法依赖package包/类/*** Sets the fonts size of all components in the found set as a percentage of the font* size of the components' respective parents.* @param size...
  • 原文地址:Java程序设计中setFont()函数用法作者:孟湛斌 java.awt.Font 设计字体显示效果 Font mf = new Font(String 字体,int 风格,int 字号); 字体:TimesRoman, Courier, Arial等 风格:三个常量 ...
  • 既然是可能用途Highlighter(或HTML)用于JTextArea,此api实现了...importjava.awt.*;importjavax.swing.*;importjavax.swing.text.*;publicclassTextPaneHighlighting{privatestaticfinallongserialVersionUID=...
  • 这个是部分代码!!this.setLayout(null);Font f = new Font("华文宋体",20,20);//设置“请输入账户:...jl1.setBounds(60, 180, 110, 40);jl1.setFont(f);this.add(jl1);//设置账户JTextfieldjtf = new JTextField...
  • 【判断题】胃入口称幽门,与食管相接,胃出口称贲门,与十二指肠相接。【单选题】二进制数011111转换为十进制整数是______。【判断题】左、右冠状动脉是主动脉基部分支,是营养心脏血管。【单选题】儿童甲状腺...
  • java新手求各位高手帮忙看一下!我使用netbeans6.1运行了一个程序!发现当在paintComponent()方法上,加上setFont(getFont().deriveFont(70.f).deriveFont(Font.BOLD)); 这句代码时cpu占用就会达到50%左右,当去掉是就会...
  • //设置java字体颜色设置字体颜色和型号和大小jTextPane1.setFont(new Font("黑体",Font.PLAIN,jTextPane1.getFont().getSize()));ava.awt.Font设计字体显示效果 Font mf = new Font(String 字体,int 风格,in.....
  • 设置Java对话框字体方法MessageDialog中没有setFont这样函数,那要怎样设置该语句中`中文字体呢?以下是小编为大家搜索整理设置Java对话框字体方法,希望能给大家带来帮助!更多精彩内容请及时关注我们应届...
  • 字体:TimesRoman, Courier, Arial等风格:三个常量 lFont.PLAIN, Font.BOLD, Font.ITALIC字号:字大小(磅数)设置组件当前使用字体:setFont(Font fn)获取组件当前使用字体:getFont()i...
  • setPreferredSize实际上改变了标签大小你应该尝试使用setBorder方法绘制边框以验证新大小,但字体大小不会改变,如果你想要大字体尝试调用setFont并设置新字体大小,这里有一些代码开头:import java.awt.Color;...
  • import java.awt.Label; //导入方法依赖package包/类Database(){setSize(500,580);setVisible(true);setLayout(null);setTitle("Students Record");setResizable(false);Font fn=new Font("Georgia",Font.BOLD,12)...
  • publicclassBlockextendsJTextField{Pointpoint;Objectobject;Block(){setEditable(false);setHorizontalAlignment(JTextField....setFont(newFont("Arial",Font.BOLD,16));setF...public class Block extends ...
  • 字体:TimesRoman, Courier, Arial等风格:三个常量 lFont.PLAIN, Font.BOLD, Font.ITALIC字号:字大小(磅数)设置组件当前使用字体:setFont(Font fn)获取组件当前使用字体:getFont()i...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 401
精华内容 160
关键字:

java的setfont

java 订阅