build JScrollPane - Java Swing

Java examples for Swing:JScrollPane

Description

build JScrollPane

Demo Code


//package com.java2s;
import javax.swing.*;
import java.awt.*;

public class Main {
    public static JScrollPane buildJScrollPane(JTextArea inputBox) {
        Font bigFont = new Font("sanserif", Font.BOLD, 24);
        inputBox.setLineWrap(true);//from  w w w  .  j av a2 s.c  om
        inputBox.setWrapStyleWord(true);
        inputBox.setFont(bigFont);

        JScrollPane newScroller = new JScrollPane(inputBox);
        newScroller
                .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        newScroller
                .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        return newScroller;
    }
}

Related Tutorials