Java JScrollPane getScrollableMessage(String msg)

Here you can find the source of getScrollableMessage(String msg)

Description

get Scrollable Message

License

Open Source License

Declaration

private static JScrollPane getScrollableMessage(String msg) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * PGPTool is a desktop application for pgp encryption/decryption
 * Copyright (C) 2017 Sergey Karpushin//from  w ww .j av a2s. c  o m
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *******************************************************************************/

import java.awt.Dimension;

import java.awt.Insets;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class Main {
    private static JScrollPane getScrollableMessage(String msg) {
        JTextArea textArea = new JTextArea(msg);
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setEditable(false);
        textArea.setMargin(new Insets(5, 5, 5, 5));
        textArea.setFont(new JTextField().getFont()); // dirty fix to use better font
        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setPreferredSize(new Dimension(700, 150));
        scrollPane.getViewport().setView(textArea);
        return scrollPane;
    }
}

Related

  1. findScrollPane(Component c)
  2. findScrollPane(Component component)
  3. getContainingScroll(Component comp)
  4. getMessageScrollPane(String message)
  5. getNoScrollPaletteWindow(Component gui, String windowName, ComponentListener cl)
  6. getScrollBarWidth(BasicComboPopup popup, JScrollPane scrollPane)
  7. getScrollPaneViewportSize(JScrollPane panel)
  8. hasParentScrollPane(JComponent component)
  9. initScrollPane(JScrollPane scrollPane)