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


Java JTextField.setForeground方法代码示例

本文整理汇总了Java中javax.swing.JTextField.setForeground方法的典型用法代码示例。如果您正苦于以下问题:Java JTextField.setForeground方法的具体用法?Java JTextField.setForeground怎么用?Java JTextField.setForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTextField的用法示例。


在下文中一共展示了JTextField.setForeground方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyDomainRangeLowerBoundInput

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Verify that the y-value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyDomainRangeLowerBoundInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		double domainLowerBound;
		if (inputString.startsWith("-")) {
			domainLowerBound = Double.parseDouble(inputString.substring(1));
			domainLowerBound = -domainLowerBound;
		} else {
			domainLowerBound = Double.parseDouble(inputString);
		}
		// TODO: fix check for actual ranges
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:ManageZoomDialog.java

示例2: verifyValueRangeLowerBoundInput

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Verify that the width value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyValueRangeLowerBoundInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		double valueLowerBound;
		if (inputString.startsWith("-")) {
			valueLowerBound = Double.parseDouble(inputString.substring(1));
			valueLowerBound = -valueLowerBound;
		} else {
			valueLowerBound = Double.parseDouble(inputString);
		}
		// TODO: fix check for actual ranges
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:ManageZoomDialog.java

示例3: verifyColorInput

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Verify that the color value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyColorInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		double color;
		if (inputString.startsWith("-")) {
			color = Double.parseDouble(inputString.substring(1));
			color = -color;
		} else {
			color = Double.parseDouble(inputString);
		}
		// TODO: fix check for actual ranges
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:ManageZoomDialog.java

示例4: getSelectedPort

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Get the value of a port field.
 *
 * @param field The field to read.
 * @return The port number in the field, or negative on error.
 */
private int getSelectedPort(JTextField field) {
    int port;
    try {
        port = Integer.parseInt(field.getText());
    } catch (NumberFormatException e) {
        port = -1;
    }
    if (0 < port && port < 0x10000) return port;
    field.setForeground(Color.red);
    return -1;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:18,代码来源:NewPanel.java

示例5: setColorField

import javax.swing.JTextField; //导入方法依赖的package包/类
public static void setColorField(JTextField field) {
    Color c = Util.decodeColor(field.getText(), Color.black);
    field.setForeground(c);
    //field.setForeground(new Color(~c.getRGB()));
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:6,代码来源:Util.java

示例6: setBgcolorField

import javax.swing.JTextField; //导入方法依赖的package包/类
public static void setBgcolorField(JTextField field) {
    Color c = Util.decodeColor(field.getText());
    field.setBackground(c);
    field.setForeground(new Color(~c.getRGB()));
}
 
开发者ID:ser316asu,项目名称:SER316-Aachen,代码行数:6,代码来源:Util.java

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

示例8: GUI

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Constructor que arma el GUI.
 */
public GUI(){
	contenedor=getContentPane();
	contenedor.setLayout(null);
	
	/*Creamos el objeto*/
	fileChooser=new JFileChooser();
	 
	/*Propiedades del Label, lo instanciamos, posicionamos y
	 * activamos los eventos*/
	labelTitulo= new JLabel();
	labelTitulo.setText("l Tribunal Supremo Electorial");
	labelTitulo.setBounds(110, 20, 180, 23);
	
	areaDeTexto = new JTextArea();
	areaDeTexto.setEditable(false);
	//para que el texto se ajuste al area
	areaDeTexto.setLineWrap(true);
	//permite que no queden palabras incompletas al hacer el salto de linea
	areaDeTexto.setWrapStyleWord(true);
   	scrollPaneArea = new JScrollPane();
	scrollPaneArea.setBounds(20, 50, 350, 270);
       scrollPaneArea.setViewportView(areaDeTexto);
      	
	/*Propiedades del boton, lo instanciamos, posicionamos y
	 * activamos los eventos*/
	botonAbrir= new JButton();
	botonAbrir.setText("Boton 1");
	botonAbrir.setBounds(474, 281, 91, 23);
	botonAbrir.addActionListener(this);
	
	/*Agregamos los componentes al Contenedor*/
	contenedor.add(labelTitulo);
	contenedor.add(scrollPaneArea);
	contenedor.add(botonAbrir);
	
	btnNewButton = new JButton("Boton 2");
	btnNewButton.setBounds(620, 281, 89, 23);
	getContentPane().add(btnNewButton);
	btnNewButton.addActionListener(this);
	
	JTextPane txtpnInstruccionesnBoton = new JTextPane();
	txtpnInstruccionesnBoton.setEditable(false);
	txtpnInstruccionesnBoton.setFont(new Font("Dialog", Font.PLAIN, 14));
	txtpnInstruccionesnBoton.setBackground(SystemColor.control);
	txtpnInstruccionesnBoton.setText("Instrucciones: \r\nCargar: Cargar datos guategrafo.txt\r\nBoton 1: Preguntar el nombre de la ciudad origen y ciudad destino.\r\nBoton 2: Modificar grafo");
	txtpnInstruccionesnBoton.setBounds(440, 50, 269, 101);
	getContentPane().add(txtpnInstruccionesnBoton);
	
	txtNoHayArchivo = new JTextField();
	txtNoHayArchivo.setEditable(false);
	txtNoHayArchivo.setForeground(Color.RED);
	txtNoHayArchivo.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 14));
	txtNoHayArchivo.setText("No hay archivo cargado.");
	txtNoHayArchivo.setBackground(Color.DARK_GRAY);
	txtNoHayArchivo.setBounds(509, 190, 204, 34);
	getContentPane().add(txtNoHayArchivo);
	txtNoHayArchivo.setColumns(10);
	
	btnCargar = new JButton("Cargar");
	btnCargar.setBounds(410, 197, 89, 23);
	getContentPane().add(btnCargar);
	btnCargar.addActionListener(this);
     		//Asigna un titulo a la barra de titulo
	setTitle("Proyecto");
	//tama�o de la ventana
	setSize(750,363);
	//pone la ventana en el Centro de la pantalla
	setLocationRelativeTo(null);
	
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
 
开发者ID:mretolaza,项目名称:HojaDeTrabajo9,代码行数:75,代码来源:GUI.java

示例9: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:57,代码来源:XTextFieldPeer.java


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