Java JScrollPane addStyle(JScrollPane jScrollPane, String labelName)

Here you can find the source of addStyle(JScrollPane jScrollPane, String labelName)

Description

add Style

License

Open Source License

Declaration

public static void addStyle(JScrollPane jScrollPane, 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);/* w w  w .j  a  va2  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. applyCorrectViewPosition(JComponent targetComponent, JScrollPane scrollPane)
  2. bindHorizontalScrolling(JScrollPane jScrollPane1, JScrollPane jScrollPane2)
  3. buildLabeledScroller(String label, Component contents)
  4. createJScrollPane(JComponent component)