Java Code Examples for javax.swing.JTextArea#setComponentPopupMenu()

The following examples show how to use javax.swing.JTextArea#setComponentPopupMenu() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IDEF0Object.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
private void cancelEdit(final AttributeEditor editor,
                        final JTextArea textArea, final JPopupMenu menu) {
    movingArea.remove(getTextComponent());
    movingArea.revalidate();
    movingArea.repaint();
    textArea.setComponentPopupMenu(menu);
    editor.close();
    setTextComponent(null);
    movingArea.getPanel().setActionDisable(false);
}
 
Example 2
Source File: ConnectionInfoPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Adds a JTextArea with the given text
 *
 * @param text
 * 		The text
 */
private JComponent createTextArea(StringProperty text) {
	// Without the TextArea the GUI is collapsing
	JTextArea multi = new JTextArea(text.get());
	multi.setFont(OPEN_SANS_12);
	// update text
	text.addListener(l -> {
		if (!multi.getText().equals(text.get())) {
			SwingTools.invokeLater(() -> multi.setText(text.get()));
		}
	});
	multi.setWrapStyleWord(true);
	multi.setLineWrap(true);
	multi.setEditable(editable);
	if (!editable) {
		multi.setHighlighter(null);
		multi.setComponentPopupMenu(null);
		multi.setInheritsPopupMenu(false);
		multi.setBackground(getBackground());
		multi.setBorder(BorderFactory.createEmptyBorder());
	} else {
		multi.getDocument().addDocumentListener(new TextChangedDocumentListener(text));
		multi.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
	}
	if (!isTypeKnown) {
		multi.setForeground(UNKNOWN_TYPE_COLOR);
	}
	return createWithScrollPane(multi);
}
 
Example 3
Source File: DFDSNamePanel.java    From ramus with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create the panel.
 */
public DFDSNamePanel(Engine engine, Element element) {
    super(new BorderLayout());
    this.engine = engine;
    this.element = element;
    dataPlugin = NDataPluginFactory.getExistingDataPlugin(engine);
    textArea = new JTextArea();
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setComponentPopupMenu(createSelectLanguageMenu());

    textArea.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (undoManager == null)
                return;
            if (e.isControlDown()) {
                if (e.getKeyCode() == KeyEvent.VK_Z)
                    if (undoManager.canUndo())
                        undoManager.undo();
                if (e.getKeyCode() == KeyEvent.VK_Y)
                    if (undoManager.canRedo())
                        undoManager.redo();
            }
        }
    });

    if (dataPlugin != null) {
        Row row = dataPlugin.findRowByGlobalId(element.getId());
        if (row instanceof Function) {
            Function function = (Function) row;
            panel = new ArrowLinksPanel(function);
            JSplitPane splitPane = new JSplitPane();
            add(splitPane, BorderLayout.CENTER);
            splitPane.setLeftComponent(new JScrollPane(textArea));
            splitPane.setRightComponent(panel);
            createChecker();
            return;
        }
    }

    add(new JScrollPane(textArea), BorderLayout.CENTER);

    createChecker();
}
 
Example 4
Source File: ConnectionInfoPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Creates a connection information display panel.
 *
 * @param connection
 * 		the model of the connection to show
 * @param showDescriptions
 * 		if {@code true} descriptions for the headers are displayed
 */
public ConnectionInfoPanel(ConnectionModel connection, boolean showDescriptions) {
	super(new GridBagLayout());
	this.editable = connection.isEditable();
	String connectionType = connection.getType();
	isTypeKnown = ConnectionHandlerRegistry.getInstance().isTypeKnown(connectionType);

	// header with icon, name, and type
	GridBagConstraints gbc = new GridBagConstraints();
	JPanel headerPanel = new JPanel(new GridBagLayout());
	GridBagConstraints headerGbc = new GridBagConstraints();
	headerGbc.gridx = 0;
	headerGbc.gridy = 0;
	headerGbc.anchor = GridBagConstraints.WEST;
	headerGbc.gridheight = 2;
	headerGbc.insets = new Insets(0, 0, 0, 10);
	headerPanel.add(new JLabel(ConnectionI18N.getConnectionIcon(connectionType, IconSize.HUGE)), headerGbc);

	headerGbc.gridx = 1;
	headerGbc.gridheight = 1;
	headerGbc.insets = new Insets(0, 0, 0, 0);
	JLabel nameLabel = new JLabel(connection.getName());
	nameLabel.setToolTipText(connection.getName());
	nameLabel.setFont(OPEN_SANS_SEMIBOLD_24);
	headerPanel.add(nameLabel, headerGbc);

	headerGbc.gridx = 1;
	headerGbc.gridy += 1;
	headerGbc.gridheight = 1;
	JComponent typeComponent = createTypeComponent(connectionType);
	headerPanel.add(typeComponent, headerGbc);

	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.weightx = 1.0;
	gbc.fill = GridBagConstraints.HORIZONTAL;
	gbc.anchor = GridBagConstraints.NORTHWEST;
	gbc.insets = new Insets(25, 25, 15, 25);
	JPanel headerOuterPanel = new JPanel(new BorderLayout());
	headerOuterPanel.add(headerPanel, BorderLayout.WEST);
	add(headerOuterPanel, gbc);

	gbc.gridy += 1;
	gbc.weightx = 0.8;
	gbc.insets = new Insets(0, 20, 0, 200);
	JSeparator separator = new JSeparator();
	add(separator, gbc);

	// body with location, description, and tags
	JPanel bodyPanel = new JPanel(new GridLayout(3, 2, 30, 20));
	bodyPanel.add(createDescriptionPanel(ConnectionI18N.getConnectionGUILabel("location"),
			ConnectionI18N.getConnectionGUILabel("location_description"), showDescriptions));

	String repositoryName = connection.getLocation() != null ?
			RepositoryLocation.REPOSITORY_PREFIX + connection.getLocation().getRepositoryName() : "";
	JTextArea locArea = new JTextArea(repositoryName);
	locArea.setEditable(false);
	locArea.setHighlighter(null);
	locArea.setLineWrap(true);
	locArea.setComponentPopupMenu(null);
	locArea.setInheritsPopupMenu(false);
	locArea.setBackground(getBackground());
	locArea.setBorder(BorderFactory.createEmptyBorder());
	locArea.setFont(OPEN_SANS_12);
	if (!isTypeKnown) {
		locArea.setForeground(UNKNOWN_TYPE_COLOR);
	}

	bodyPanel.add(locArea);

	bodyPanel.add(createDescriptionPanel(ConnectionI18N.getConnectionGUILabel("description"),
			ConnectionI18N.getConnectionGUILabel("description_description"), showDescriptions));

	bodyPanel.add(createTextArea(connection.descriptionProperty()));

	bodyPanel.add(createDescriptionPanel(ConnectionI18N.getConnectionGUILabel("tags"),
			ConnectionI18N.getConnectionGUILabel("tags_description"), showDescriptions));

	bodyPanel.add(createTagPanel(connection.getTags(), connection::setTags));

	gbc.gridy += 1;
	gbc.weightx = 1.0;
	gbc.weighty = 1.0;
	gbc.fill = GridBagConstraints.BOTH;
	gbc.insets = new Insets(15, 25, 10, 25);
	add(bodyPanel, gbc);
}