Java JTextField addStyle(JTextField textField, String labelName)

Here you can find the source of addStyle(JTextField textField, String labelName)

Description

add Style

License

Open Source License

Declaration

public static void addStyle(JTextField textField, String labelName) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;

public class Main {
    public static void addStyle(JTextField textField, String labelName) {
        textField.setHorizontalAlignment(SwingConstants.RIGHT);
        Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
        TitledBorder titled = BorderFactory.createTitledBorder(line, labelName);
        titled.setTitleFont(new Font("Verdana", 0, 13));
        titled.setTitleColor(new Color(213, 225, 185));
        Border empty = new EmptyBorder(5, 8, 5, 8);
        CompoundBorder border = new CompoundBorder(titled, empty);
        textField.setBorder(border);/*from   w  w w . java 2  s  . c o m*/
        textField.setForeground(new Color(143, 170, 220));
        textField.setFont(new Font("Monospaced", 0, 13));
    }

    public static void addStyle(JTextArea textArea, String labelName, boolean isBorder) {

        Border border = null;
        if (isBorder) {
            Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
            TitledBorder titled = BorderFactory.createTitledBorder(line, labelName);
            titled.setTitleFont(new Font("Verdana", 0, 13));
            titled.setTitleColor(new Color(213, 225, 185));
            Border empty = new EmptyBorder(5, 8, 5, 8);
            CompoundBorder cBorder = new CompoundBorder(titled, empty);
        }
        textArea.setBorder(border);
        textArea.setForeground(new Color(143, 170, 220));
        textArea.setFont(new Font("Monospaced", 0, 13));
    }

    public static void addStyle(JScrollPane jScrollPane, String labelName) {
        Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
        TitledBorder titled = BorderFactory.createTitledBorder(line, labelName);
        titled.setTitleFont(new Font("Verdana", 0, 13));
        titled.setTitleColor(new Color(213, 225, 185));
        Border empty = new EmptyBorder(5, 8, 5, 8);
        CompoundBorder border = new CompoundBorder(titled, empty);
        jScrollPane.setBorder(border);
        jScrollPane.setForeground(new Color(143, 170, 220));
        jScrollPane.setBackground(Color.WHITE);
        jScrollPane.setFont(new Font("Monospaced", 0, 13));
        jScrollPane.setHorizontalScrollBar(null);
    }

    public static void addStyle(JTable jTable) {
        jTable.setForeground(new Color(143, 170, 220));
        jTable.setBackground(Color.WHITE);
        jTable.setFont(new Font("Monospaced", 0, 13));
    }
}

Related

  1. addHighlight(JTextField label, MouseEvent mouseEvent1, MouseEvent mouseEvent2)
  2. addInputValidator(final DocumentListener inputValidator, final JTextField... textFields)
  3. addLabelTextRows(JLabel[] labels, JTextField[] textFields, GridBagLayout gridbag, Container container)
  4. addPlaceHolder(final JTextField field, final String placeHolderText)
  5. adjustTextToRight(JTextField textField)
  6. applyDefaultProperties(final JTextField comp)
  7. AreAllTextFieldsFilled(javax.swing.JTextField[] tfs)
  8. badField(JTextField field)