Java Code Examples for javax.swing.JTextField#setFont()

The following examples show how to use javax.swing.JTextField#setFont() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public FileNameComponent(int textfieldcolumns, List<File> lastFiles) {
  setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));

  txtFilename = new JTextField();
  txtFilename.setColumns(textfieldcolumns);
  txtFilename.setFont(smallFont);
  add(txtFilename);

  // last used files chooser button
  // on click - set file name to textField
  btnLastFiles = new JLastFilesButton("last", file -> txtFilename.setText(file.getPath()));
  add(btnLastFiles);

  JButton btnFileBrowser = new JButton("...");
  btnFileBrowser.addActionListener(this);
  add(btnFileBrowser);

  setLastFiles(lastFiles);
}
 
Example 2
protected void setupValue() {
	value = new JTextField("", 2);
	value.setAlignmentX(LEFT_ALIGNMENT);
	value.setFont(MEDIUM_FONT);
	add(value);

	value2 = new JTextField("", 2);
	value2.setAlignmentX(LEFT_ALIGNMENT);
	value2.setFont(MEDIUM_FONT);
	add(value2);

	getTextField().addActionListener(this);
	getTextField2().addActionListener(this);
	getTextField().addFocusListener(this);
	getTextField2().addFocusListener(this);
	load();
}
 
Example 3
public PanMetagonTags(){
  
  setBackground(UI.BUTTON_RED);
  setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  
  Component horizontalStrut = Box.createHorizontalStrut(4);
  add(horizontalStrut);
  
  JLabel lbljigtag = new JLabel("MetagonTags=");
  add(lbljigtag);
  lbljigtag.setFont(new Font("Dialog", Font.BOLD, 14));
  
  Component horizontalStrut_3 = Box.createHorizontalStrut(4);
  add(horizontalStrut_3);
  
  txtmetagontags = new JTextField("foo",20);
  txtmetagontags.setBackground(UI.BUTTON_YELLOW);
  add(txtmetagontags);
  txtmetagontags.setFont(new Font("DejaVu Sans Mono", Font.PLAIN, 18));
  txtmetagontags.setBorder(null);
  txtmetagontags.addKeyListener(new KeyAdapter(){
    public void keyReleased(KeyEvent e){
      GE.ge.editor_metagon.setMetagonTags(txtmetagontags.getText());}});
  
  Component horizontalStrut_1 = Box.createHorizontalStrut(4);
  add(horizontalStrut_1);
  
}
 
Example 4
private JTextField makeTextField(JPanel features, int row) {
	final JTextField f = new JTextField(5);
	f.setHorizontalAlignment(SwingUtilities.RIGHT);
	f.setFont(FONT);
	f.setText("");
	f.setEditable(false);

	final GridBagConstraints gbc = new GridBagConstraints();
	gbc.gridx = 1;
	gbc.gridy = row;
	features.add(f, gbc);

	return f;
}
 
Example 5
Source Project: ET_Redux   File: DialogEditor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param textF
 * @param editable
 */
public BigDecimalDocument(JTextField textF, boolean editable) {
    super(textF, editable);
    this.editable = editable;
    textF.setFont(myScienceFont);
    textF.setCaretPosition(0);
}
 
Example 6
private void createFeatureField() {
	featureField = new JTextField();
	featureField.setOpaque(false);
	featureField.setFont(Font.decode("Monaco-24"));
	featureField.setHorizontalAlignment(JTextField.CENTER);
	featureField.setEditable(false);
	featureField.setBorder(null);
}
 
Example 7
Source Project: zap-extensions   File: RegexPanel.java    License: Apache License 2.0 5 votes vote down vote up
public RegexPanel(RegexModel regexModel, Runnable onRegexChanged) {
    super(new BorderLayout());
    this.regexModel = regexModel;
    this.onRegexChanged = onRegexChanged;
    regexField = new JTextField();
    regexField.setFont(RegexDialog.monoFont);
    regexField.setText(regexModel.getRegex());
    regexField.getDocument().addDocumentListener(documentListener);

    JPanel regexPanel = new JPanel(new BorderLayout());
    regexPanel.add(regexField, BorderLayout.CENTER);
    add(regexPanel, BorderLayout.CENTER);
    setBorder(RegexDialog.createBorder(REGEX_HEADER));
}
 
Example 8
private void createFeatureField() {
	featureField = new JTextField();
	featureField.setOpaque(false);
	featureField.setFont(Font.decode("Monaco-24"));
	featureField.setHorizontalAlignment(JTextField.CENTER);
	featureField.setEditable(false);
	featureField.setBorder(null);
}
 
Example 9
Source Project: PolyGlot   File: PCellEditor.java    License: MIT License 5 votes vote down vote up
@Override
public Component getTableCellEditorComponent(JTable table, Object value,
        boolean isSelected, int rowIndex, int vColIndex) {
    JTextField curComp = (JTextField) component;

    setValue(curComp, (String) value);

    curComp.setFont(myFont);

    return component;
}
 
Example 10
Source Project: PolyGlot   File: ScrDeprecatedDeclensions.java    License: MIT License 4 votes vote down vote up
/**
 * creates fields for deprecated dimension combinations
 */
private void createDeprecatedFields() {
    Set<Entry<String, DeclensionNode>> decSet = allWordDeclensions.entrySet();
    Iterator<Entry<String, DeclensionNode>> depIt = decSet.iterator();
    
    while (depIt.hasNext()) {
        Entry<String, DeclensionNode> decEnt = depIt.next();
        DeclensionNode curDec = decEnt.getValue();

        JTextField newField = new PTextField(core, false, "");
        Label newLabel = new Label(curDec.getNotes());
        
        // in the case of no patterns for word type, but existing deprecated declensions
        if (firstField == null) {
            firstField = newField;
        }

        String value = curDec.getValue();
        newField.setText(value);
        try {
            newField.setToolTipText(core.getPronunciationMgr()
                    .getPronunciation(value));
        } catch (Exception e) {
            // user error
            // IOHandler.writeErrorLog(e);
            newField.setToolTipText("Regex error: " + e.getLocalizedMessage());
        }

        if (conFont != null) {
            newField.setFont(conFont);
        }
                   
        pnlDeclensions.add(newLabel);
        pnlDeclensions.add(newField);
        
        fieldMap.put(curDec.getCombinedDimId(), newField);
        labelMap.put(curDec.getCombinedDimId(), curDec.getNotes());
        
        numFields++;
    }
}
 
Example 11
@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"));
    }
}
 
Example 12
Source Project: gepard   File: ControlPanel.java    License: MIT License 4 votes vote down vote up
private JTextField getCustomTextField(String text, int size) {
	JTextField ret = new JTextField(text, size);
	ret.setFont(TEXT_FONT);
	return ret;
}
 
Example 13
@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"));
    }
}
 
Example 14
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().getAgArch().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);
}
 
Example 15
@Override
public Component getComponent(int width, int height) throws IOException {
	engine.getOptions().setDoubleInitialImage(false);

	final JPanel outer = new JPanel();
	outer.setOpaque(false);
	outer.setPreferredSize(new Dimension(width, height));
	outer.setLayout(new GridBagLayout());

	// the main panel
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	vc = new VideoCaptureComponent(320, 240);
	vc.getDisplay().getScreen().setPreferredSize(new Dimension(640, 240));

	vc.getDisplay().addVideoListener(this);
	base.add(vc);

	final JPanel controls1 = new JPanel();
	controls1.setOpaque(false);
	final JButton grab = new JButton("Grab");
	grab.setActionCommand("grab");
	grab.addActionListener(this);
	grab.setFont(FONT);
	controls1.add(grab);
	base.add(controls1);

	final JPanel controls = new JPanel();
	controls.setOpaque(false);
	final JLabel label = new JLabel("Threshold:");
	label.setFont(FONT);
	controls.add(label);
	final JSlider slider = new JSlider(0, 100000);
	matcher.setThreshold(slider.getValue());
	slider.setPreferredSize(new Dimension(slider.getPreferredSize().width + 250, slider.getPreferredSize().height));
	controls.add(slider);
	final JTextField tf = new JTextField(5);
	tf.setFont(FONT);
	tf.setEnabled(false);
	tf.setText(slider.getValue() + "");
	controls.add(tf);

	slider.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			tf.setText(slider.getValue() + "");
			matcher.setThreshold(slider.getValue());
		}
	});

	base.add(controls);

	outer.add(base);

	return outer;
}
 
Example 16
public void init(String unitName, String unitType, String unitDescription) {

		setOpaque(false);
		setLayout(new BorderLayout(10, 20));
		// this.setSize(350, 400); // undecorated 301, 348 ; decorated : 303, 373

		JPanel mainPanel = new JPanel(new FlowLayout());// new BorderLayout());
		mainPanel.setOpaque(false);
		mainPanel.setBackground(new Color(0, 0, 0, 128));
		// setMinimumSize()
		this.add(mainPanel, BorderLayout.NORTH);

		JPanel westPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));// new BorderLayout());
		westPanel.setOpaque(false);
		westPanel.setBackground(new Color(0, 0, 0, 128));
		// setMinimumSize()
		this.add(westPanel, BorderLayout.WEST);

		JPanel eastPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));// new BorderLayout());
		eastPanel.setOpaque(false);
		eastPanel.setBackground(new Color(0, 0, 0, 128));
		// setMinimumSize()
		this.add(eastPanel, BorderLayout.EAST);

		// Creating the text Input
		JTextField tf1 = new JTextField("", 15);

		tf1.setHorizontalAlignment(JTextField.CENTER);
		tf1.setOpaque(false);
		tf1.setFocusable(false);
		tf1.setBackground(new Color(92, 83, 55, 128));
		tf1.setColumns(20);
		Border border = BorderFactory.createLineBorder(Color.gray, 2);
		tf1.setBorder(border);
		tf1.setText(unitName);
		tf1.setForeground(Color.BLACK);
		tf1.setFont(new Font("Arial", Font.BOLD, 14));

		mainPanel.add(tf1);

		JTextArea ta = new JTextArea();
		String type = "TYPE: ";
		String description = "DESCRIPTION: ";

		ta.setLineWrap(true);
		ta.setFocusable(false);
		ta.setWrapStyleWord(true);
		ta.setText(type + "\n");
		ta.append(unitType + "\n\n");
		ta.append(description + "\n");
		ta.append(unitDescription);
		ta.setCaretPosition(0);
		ta.setEditable(false);
		ta.setForeground(Color.black); 
		ta.setFont(new Font("Dialog", Font.PLAIN, 14));
		ta.setOpaque(false);
		ta.setBackground(new Color(92, 83, 55, 128));

		CustomScroll scr = new CustomScroll(ta);
		scr.setSize(PopUpUnitMenu.D_WIDTH - 50 , PopUpUnitMenu.D_HEIGHT);
		add(scr, BorderLayout.CENTER);

		JPanel southPanel = new JPanel();
		add(southPanel, BorderLayout.SOUTH);
		southPanel.setOpaque(false);
		southPanel.setBackground(new Color(0, 0, 0, 128));
		
		setVisible(true);

	}
 
Example 17
Source Project: ET_Redux   File: DialogEditor.java    License: Apache License 2.0 4 votes vote down vote up
/**
 *
 * @param textF
 */
public IntegerDocument(JTextField textF) {
    super(textF, true);
    textF.setFont(myScienceFont);
}
 
Example 18
@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"));
    }
}
 
Example 19
@SuppressWarnings("deprecation")
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	chartDataset = new DefaultXYDataset();
	X = createData();
	chartDataset.addSeries("points", X);
	final double[][] lineData = computeLineData();
	chartDataset.addSeries("line", lineData);

	chart = ChartFactory.createXYLineChart(null, "x", "y", chartDataset, PlotOrientation.VERTICAL,
			false, false, false);
	((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setSeriesLinesVisible(0, false);
	((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setSeriesShapesVisible(0, true);
	((NumberAxis) chart.getXYPlot().getDomainAxis()).setRange(-5, 5);
	((NumberAxis) chart.getXYPlot().getRangeAxis()).setRange(-10, 10);

	((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setStroke(new BasicStroke(2.5f));

	chartContainer = new ImageContainer(chart.createBufferedImage(width, height / 2));
	base.add(chartContainer);

	final JPanel bottomPane = new JPanel();
	bottomPane.setPreferredSize(new Dimension(width, height / 2));
	base.add(bottomPane);

	final JPanel controlsdata = new JPanel();
	controlsdata.setLayout(new BoxLayout(controlsdata, BoxLayout.X_AXIS));
	bottomPane.add(controlsdata);
	final JButton button = new JButton("Go");
	controlsdata.add(button);

	button.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			button.setEnabled(false);
			base.requestFocus();
			new Thread(AbstractGradientDescentDemo.this).start();
		}
	});

	paramsField = new JTextField(20);
	paramsField.setOpaque(false);
	paramsField.setFont(Font.decode("Monaco-24"));
	paramsField.setHorizontalAlignment(JTextField.CENTER);
	paramsField.setEditable(false);
	paramsField.setBorder(null);
	paramsField.setText(String.format("%2.2f, %2.2f", params[0], params[1]));
	controlsdata.add(paramsField);

	errorDataset = new DefaultXYDataset();
	errorSeries = new double[][] { { 0 }, { computeError() } };
	errorDataset.addSeries("data", errorSeries);
	errorChart = ChartFactory.createXYLineChart("Error over time",
			"Iteration", "Error", errorDataset,
			PlotOrientation.VERTICAL,
			false, false, false);
	((NumberAxis) errorChart.getXYPlot().getDomainAxis()).setRange(0, 1);
	((NumberAxis) errorChart.getXYPlot().getRangeAxis()).setRange(0, computeError());
	errorContainer = new ImageContainer(errorChart.createBufferedImage((width - 5) / 2, (height - 5) / 2));
	bottomPane.add(errorContainer);

	return base;
}
 
Example 20
@Override
public JPanel getComponent(int width, int height) throws IOException {
	final JPanel c = super.getComponent(width, height);

	this.vc.getDisplay().addVideoListener(this);

	final JPanel controls = new JPanel(new GridBagLayout());
	controls.setOpaque(false);

	final JLabel scaleLbl = new JLabel("<html>Scale (\u03C3<sup>2</sup>): </html>");
	scaleLbl.setFont(FONT);
	controls.add(scaleLbl);

	scaleSlider = new JSlider(1, 500, 1);
	controls.add(scaleSlider);

	scaleField = new JTextField(5);
	scaleField.setEditable(false);
	scaleField.setFont(FONT);
	scaleField.setHorizontalAlignment(JTextField.RIGHT);
	controls.add(scaleField);

	final JLabel kLbl = new JLabel("<html>k: </html>");
	kLbl.setFont(FONT);
	controls.add(kLbl);

	kSlider = new JSlider(10, 50, 16);
	controls.add(kSlider);

	kField = new JTextField(5);
	kField.setEditable(false);
	kField.setFont(FONT);
	kField.setHorizontalAlignment(JTextField.RIGHT);
	controls.add(kField);

	scaleSlider.addChangeListener(this);
	kSlider.addChangeListener(this);

	stateChanged(null);

	final GridBagConstraints gbc = new GridBagConstraints();
	gbc.gridy = 1;
	c.add(controls, gbc);

	return c;
}