Example usage for javax.swing JTextArea add

List of usage examples for javax.swing JTextArea add

Introduction

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

Prototype

public Component add(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

From source file:CubaHSQLDBServer.java

private void addCopyPopup(final JTextArea source) {
    final JPopupMenu popup = new JPopupMenu();
    popup.add(new AbstractAction("Copy to clipboard") {
        @Override//from w  ww  . j  av  a2s  . c  o m
        public void actionPerformed(ActionEvent e) {
            StringSelection contents = new StringSelection(source.getText());
            Toolkit.getDefaultToolkit().getSystemClipboard().setContents(contents, contents);
        }
    });
    source.add(popup);
    source.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                popup.show(source, e.getX(), e.getY());
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                popup.show(source, e.getX(), e.getY());
            }
        }
    });
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

public JTextArea appendTextArea(String label, String tooltip) {
    JTextArea textArea = new JUndoableTextArea();
    textArea.setColumns(defaultTextAreaColumns);
    textArea.setRows(defaultTextAreaRows);
    textArea.setAutoscrolls(true);//ww  w.  j a  v a2 s .  c om
    textArea.add(new JScrollPane());
    setToolTip(textArea, tooltip);
    textArea.getAccessibleContext().setAccessibleDescription(tooltip);
    JTextComponentPopupMenu.add(textArea);
    append(label, new JScrollPane(textArea));
    return textArea;
}