Java JTextArea addStyle(JTextArea textArea, String labelName, boolean isBorder)

Here you can find the source of addStyle(JTextArea textArea, String labelName, boolean isBorder)

Description

add Style

License

Open Source License

Declaration

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

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. j  a  v a 2  s  .com
        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. addMessageLogger(JTextArea t)
  2. adjustToText(JTextArea testString)
  3. appendNewLine(final JTextArea textArea, final String line)
  4. applyDefaultProperties(final JTextArea comp)
  5. attachSimpleUndoManager(JTextArea jta)