Java JScrollPane getMessageScrollPane(String message)

Here you can find the source of getMessageScrollPane(String message)

Description

get Message Scroll Pane

License

Open Source License

Declaration

private static JScrollPane getMessageScrollPane(String message) 

Method Source Code


//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License"); you may

import javax.swing.*;
import javax.swing.border.EmptyBorder;

import java.awt.*;

public class Main {
    private static JScrollPane getMessageScrollPane(String message) {
        JTextArea ta = new JTextArea(message);
        ta.setBorder(new EmptyBorder(0, 0, 0, 0));
        ta.setLineWrap(true);/*w ww.j  a va 2 s. c  om*/
        ta.setWrapStyleWord(true);
        ta.setCaretPosition(0);
        ta.setEditable(false);
        JScrollPane sp = new JScrollPane(ta);
        sp.setBorder(new EmptyBorder(5, 5, 5, 5));
        if (message.length() < 100) {
            sp.setPreferredSize(new Dimension(400, 50));
        } else {
            sp.setPreferredSize(new Dimension(400, 100));
        }
        return sp;
    }
}

Related

  1. defaultAutoScroll(JComponent comp, Point cursorLocn)
  2. defaultGetAutoscrollInsets(JComponent comp)
  3. findScrollPane(Component c)
  4. findScrollPane(Component component)
  5. getContainingScroll(Component comp)
  6. getNoScrollPaletteWindow(Component gui, String windowName, ComponentListener cl)
  7. getScrollableMessage(String msg)
  8. getScrollBarWidth(BasicComboPopup popup, JScrollPane scrollPane)
  9. getScrollPaneViewportSize(JScrollPane panel)