当前位置: 首页>>代码示例>>Java>>正文


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

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,代码来源:CheckBoxFrame.java

示例2: JFilePicker

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,代码来源:JFilePicker.java

示例3: getTableCellEditorComponent

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,代码来源:PropertiesTableCellEditor.java

示例4: Channel

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,代码来源:Channel.java

示例5: focusGained

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,代码来源:AnnotationSetNameComboEditor.java

示例6: JTextFieldDemo1

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,代码来源:TextField.java

示例7: StringControl

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,代码来源:ParameterControlPanel.java

示例8: init

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,代码来源:DeviceSlider.java

示例9: richiediNome

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,代码来源:PartitaOfflineGuiView.java

示例10: stylizeTextField

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,代码来源:TrainControllerGUI.java

示例11: Login

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,代码来源:Login.java

示例12: RadioButtonFrame

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,代码来源:RadioButtonFrame.java

示例13: initGui

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 <- .print(ok) }); !!goal; \n   .send(bob,tell,hello);\n");
    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,代码来源:ReplAgGUI.java

示例14: installUI

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,代码来源:XTextFieldPeer.java


注:本文中的javax.swing.JTextField.setFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。