Example usage for javax.swing JTextArea addHierarchyListener

List of usage examples for javax.swing JTextArea addHierarchyListener

Introduction

In this page you can find the example usage for javax.swing JTextArea addHierarchyListener.

Prototype

public void addHierarchyListener(HierarchyListener l) 

Source Link

Document

Adds the specified hierarchy listener to receive hierarchy changed events from this component when the hierarchy to which this container belongs changes.

Usage

From source file:org.wandora.application.gui.topicpanels.ProcessingTopicPanel.java

private void showRichErrorDialog(String msg) {
    final JTextArea area = new JTextArea();
    area.setFont(errorMessageFont);//from   w w  w. ja v a2s .co m
    //area.setPreferredSize(new Dimension(520, 180));
    area.setEditable(false);
    area.setText(msg);

    // Make the JOptionPane resizable using the HierarchyListener
    area.addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            Window window = SwingUtilities.getWindowAncestor(area);
            if (window instanceof Dialog) {
                Dialog dialog = (Dialog) window;
                if (!dialog.isResizable()) {
                    dialog.setResizable(true);
                }
            }
        }
    });

    JScrollPane scroller = new JScrollPane(area);
    scroller.setPreferredSize(new Dimension(520, 180));
    JOptionPane.showMessageDialog(Wandora.getWandora(), scroller, "Errors", JOptionPane.PLAIN_MESSAGE);
}