Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.Color;

import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;

import javax.swing.SwingConstants;

public class Main {
    private static final Color LABEL_COLOR = new Color(0, 70, 213);

    public static void addSeparator(JPanel panel, String text) {
        JLabel l = createLabel(text);
        l.setForeground(LABEL_COLOR);

        panel.add(l, "gapbottom 1, span, split 2, aligny center");
        panel.add(configureActiveComponent(new JSeparator()), "gapleft rel, growx");
    }

    public static JLabel createLabel(String text) {
        return createLabel(text, SwingConstants.LEADING);
    }

    public static JLabel createLabel(String text, int align) {
        final JLabel b = new JLabel(text, align);
        configureActiveComponent(b);

        return b;
    }

    private static JComponent configureActiveComponent(JComponent c) {
        // if (benchRuns == 0) {
        // c.addMouseMotionListener(toolTipListener);
        // c.addMouseListener(constraintListener);
        // }
        return c;
    }
}