Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.awt.Font;

import javax.swing.JTextPane;

public class Main {
    /**
     * Creates a new <code>JTextPane</code> object with the given properties.
     *
     * @param text The text which will appear in the text pane
     * @param backgroundColor The background color
     * @return A <code>JTextPane</code> object
     */
    public static JTextPane createJTextPane(String text, Color backgroundColor) {
        JTextPane jTextPane = new JTextPane();
        jTextPane.setBorder(null);
        jTextPane.setEditable(false);
        jTextPane.setBackground(backgroundColor);
        jTextPane.setFont(new Font("Times New Roman", Font.PLAIN, 14));
        if (text != null) {
            jTextPane.setText(text);
        }
        jTextPane.setVerifyInputWhenFocusTarget(false);
        jTextPane.setAutoscrolls(false);
        return jTextPane;
    }
}