Java JOptionPane Message displayEditor(Component parent, String title, String msg)

Here you can find the source of displayEditor(Component parent, String title, String msg)

Description

display Editor

License

Open Source License

Declaration

public static String displayEditor(Component parent, String title, String msg) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Component;

import javax.swing.JDialog;

import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class Main {
    public static String displayEditor(Component parent, String title, String msg) {
        JTextArea editArea = new JTextArea(msg, 5, 30);
        editArea.setEditable(true);//w w  w  . j a  v a  2 s  .c o  m
        editArea.setLineWrap(true);

        JScrollPane scroll = new JScrollPane(editArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

        final JOptionPane optionPane = new JOptionPane(scroll, JOptionPane.PLAIN_MESSAGE,
                JOptionPane.OK_CANCEL_OPTION);
        JDialog dialog = optionPane.createDialog(parent, title);
        dialog.setResizable(true);
        dialog.show();

        Object iValue = optionPane.getValue();

        if (iValue == null) {
            return null;
        }

        int value = ((Integer) optionPane.getValue()).intValue();

        if (value == JOptionPane.OK_OPTION) {
            return editArea.getText();
        }

        return null;
    }
}

Related

  1. copyToClipBoard(String code, boolean displayMessage)
  2. createPane(Component comp, String msg)
  3. createPane(int type, String message, int messageMaxLength)
  4. debug(String message)
  5. display2(Component parent, String message, String title, int optionType, int messageType, Icon icon)
  6. displayInputMessage(String title, String message, String defaultInput)
  7. displayInputMessage(String title, String message, String defaultInput)
  8. displayMessage(Component parent, String string, String title)
  9. displayMessage(Component parentComponent, String message, String windowTitle, int messageType)