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

The following examples show how to use javax.swing.JTextField#setForeground() . 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
Source File: UIRes.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
public static void addStyle(JTextField textField, String labelName, boolean bottom) {
	textField.setHorizontalAlignment(SwingConstants.RIGHT);
	Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
	TitledBorder titled = BorderFactory.createTitledBorder(line, labelName);
	titled.setTitleFont(GraphicsUtils.getFont("Verdana", 0, 13));
	titled.setTitleColor(fontColorTitle);
	Border empty = null;
	if (bottom) {
		empty = new EmptyBorder(5, 8, 5, 8);
	} else {
		empty = new EmptyBorder(5, 8, 0, 8);
	}
	CompoundBorder border = new CompoundBorder(titled, empty);
	textField.setBorder(border);
	textField.setForeground(fontColor);
	textField.setFont(GraphicsUtils.getFont("Monospaced", 0, 13));
}
 
Example 2
Source File: SingleEntryDialog.java    From nanoleaf-desktop with MIT License 6 votes vote down vote up
public SingleEntryDialog(Component parent, String entryLabel,
		String buttonLabel, ActionListener buttonListener)
{
	super();
	
	entry = new JTextField(entryLabel);
	entry.setForeground(Color.WHITE);
	entry.setBackground(Color.DARK_GRAY);
	entry.setBorder(new LineBorder(Color.GRAY));
	entry.setCaretColor(Color.WHITE);
	entry.setFont(new Font("Tahoma", Font.PLAIN, 22));
	entry.addFocusListener(new TextFieldFocusListener(entry));
	contentPanel.add(entry, "cell 0 1, grow, gapx 2 2");
	
	JButton btnConfirm = new ModernButton(buttonLabel);
	btnConfirm.setFont(new Font("Tahoma", Font.PLAIN, 18));
	btnConfirm.addActionListener(buttonListener);
	contentPanel.add(btnConfirm, "cell 0 3, alignx center");
	
	JLabel spacer = new JLabel(" ");
	contentPanel.add(spacer, "cell 0 4");
	
	finalize(parent);
	
	btnConfirm.requestFocus();
}
 
Example 3
Source File: ManageZoomDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Verify that the x-value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyDomainRangeUpperBoundInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		double domainUpperBound;
		if (inputString.startsWith("-")) {
			domainUpperBound = Double.parseDouble(inputString.substring(1));
			domainUpperBound = -domainUpperBound;
		} else {
			domainUpperBound = Double.parseDouble(inputString);
		}
		// TODO: fix check for actual ranges
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
Example 4
Source File: AddParallelLineDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Verify that the x-value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyXInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		Double.parseDouble(inputString);
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
Example 5
Source File: GridNode.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
@Override
public void focusLost(FocusEvent e) {
    if (e.getSource() instanceof JTextField) {
        JTextField tf = (JTextField) e.getSource();
        if (tf.getText().isEmpty()) {
            tf.setText(waterMark);
            tf.setForeground(new Color(150, 150, 150));
        }
    }
}
 
Example 6
Source File: TextCellEditor.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
@Override
	public Component getEditorComponent(int row, int column, Object value,
			boolean isSelected, JGrid grid) {
		// TODO
		if (value == null) {
			return super.getEditorComponent(row, column, value, isSelected, grid);
		}
		
		try {
			bandElement = (BandElement) value;
		} catch (ClassCastException e) {
			return super.getEditorComponent(row, column, value, isSelected, grid);
		}
//		System.out.println("bandElement = " + bandElement);
		
		JTextField renderer = (JTextField) super.getEditorComponent(row, column, bandElement.getText(), isSelected, grid);
		renderer.setFont(bandElement.getFont());
		renderer.setBackground(bandElement.getBackground());
		renderer.setForeground(bandElement.getForeground());
		renderer.setHorizontalAlignment(bandElement.getHorizontalAlign());

        Border outer = new CustomLineBorder(bandElement.getBorder());
		Border inner = null;
		if (bandElement.getPadding() != null) {
			Padding padding = bandElement.getPadding();
			inner = new EmptyBorder(padding.getTop(), padding.getLeft(), padding.getBottom(), padding
					.getRight());
		} else {
			inner = new EmptyBorder(0, 0, 0, 0);
		}
		CompoundBorder border = new CompoundBorder(outer, inner);
		renderer.setBorder(border);	
		
		this.grid = grid;
		
		return renderer;
	}
 
Example 7
Source File: AddParallelLineDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Verify that the y-value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyYInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		Double.parseDouble(inputString);
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
Example 8
Source File: EditParallelLineDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Verify that the value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyValueInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		Double.parseDouble(inputString);
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
Example 9
Source File: XTextFieldPeer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@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 10
Source File: XTextFieldPeer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@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 11
Source File: XTextFieldPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@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 File: UnitInfoPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
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 13
Source File: IntegerCustomEditor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void handleInvalid(JTextField field) {
    field.setForeground(getErrorColor());
    getMap().get(field).setForeground(getErrorColor());
}
 
Example 14
Source File: IntegerCustomEditor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void handleValid(JTextField field) {
    field.setForeground(getForeground());
    getMap().get(field).setForeground(getForeground());
}
 
Example 15
Source File: XTextFieldPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@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 16
Source File: TracerDataView.java    From pega-tracerviewer with Apache License 2.0 4 votes vote down vote up
protected void setMessage(JTextField statusBar, Message message) {

        if (message != null) {

            Color color = Color.BLUE;

            if (message.getMessageType().equals(Message.MessageType.ERROR)) {
                color = Color.RED;
            }

            String text = message.getText();

            statusBar.setForeground(color);
            statusBar.setText(text);
        }
    }
 
Example 17
Source File: ColorEntry.java    From nanoleaf-desktop with MIT License 4 votes vote down vote up
private void initUI(Container contentPane)
{
	JPanel panel = new JPanel();
	panel.setBackground(Color.DARK_GRAY);
	contentPane.add(panel, "flowx, cell 0 1");
	panel.setLayout(new MigLayout("", "[]", "[][][]"));
	
	JLabel lblRgb = new JLabel("RGB");
	lblRgb.setForeground(Color.WHITE);
	lblRgb.setFont(new Font("Tahoma", Font.PLAIN, 20));
	panel.add(lblRgb, "flowx,cell 0 0");
	
	txtRgb = new JTextField();
	txtRgb.setFont(new Font("Tahoma", Font.PLAIN, 20));
	txtRgb.setForeground(Color.WHITE);
	txtRgb.setBackground(Color.DARK_GRAY);
	txtRgb.setText("128, 128, 128");
	txtRgb.setColumns(10);
	txtRgb.setCaretColor(Color.WHITE);
	txtRgb.addKeyListener(new EnterColorListener(EnterColorListener.RGB));
	panel.add(txtRgb, "cell 0 0,gapx 15 0");
	
	JLabel lblHsb = new JLabel("HSB");
	lblHsb.setForeground(Color.WHITE);
	lblHsb.setFont(new Font("Tahoma", Font.PLAIN, 20));
	panel.add(lblHsb, "flowx,cell 0 1");
	
	txtHsb = new JTextField();
	txtHsb.setText("0, 0, 50");
	txtHsb.setFont(new Font("Tahoma", Font.PLAIN, 20));
	txtHsb.setForeground(Color.WHITE);
	txtHsb.setBackground(Color.DARK_GRAY);
	txtHsb.setColumns(10);
	txtHsb.setCaretColor(Color.WHITE);
	txtHsb.addKeyListener(new EnterColorListener(EnterColorListener.HSB));
	panel.add(txtHsb, "cell 0 1,gapx 15 0,aligny top");
	
	JLabel lblHex = new JLabel("HEX");
	lblHex.setForeground(Color.WHITE);
	lblHex.setFont(new Font("Tahoma", Font.PLAIN, 20));
	panel.add(lblHex, "flowx,cell 0 2");
	
	txtHex = new JTextField();
	txtHex.setForeground(Color.WHITE);
	txtHex.setText("#808080");
	txtHex.setFont(new Font("Tahoma", Font.PLAIN, 20));
	txtHex.setBackground(Color.DARK_GRAY);
	txtHex.setColumns(10);
	txtHex.setCaretColor(Color.WHITE);
	txtHex.addKeyListener(new EnterColorListener(EnterColorListener.HEX));
	panel.add(txtHex, "cell 0 2,gapx 15 0");
}
 
Example 18
Source File: XTextFieldPeer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@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
Source File: XTextFieldPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@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 20
Source File: OrderOfLossesInputPanel.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
private void turnToRedIfNotValidOrderOfLoss(final JTextField textField) {
  textField.setForeground(isValidOrderOfLoss(textField.getText(), data) ? null : Color.red);
}