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

The following examples show how to use javax.swing.JTextArea#setMinimumSize() . 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: Display.java    From jacamo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Display(){
    setTitle(".:: ENVIRONMENT CONSOLE ::.");
    setSize(600,600);

    JPanel panel = new JPanel();
    setContentPane(panel);
    panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));

    numMsg = new JLabel("0");
    text = new JTextArea();
    text.setMinimumSize(new Dimension(580,550));
    text.setMaximumSize(new Dimension(580,550));
    text.setPreferredSize(new Dimension(580,550));
    text.setEditable(true);

    panel.add(text);
    panel.add(Box.createVerticalStrut(5));
    panel.add(numMsg);
}
 
Example 2
Source File: MsgDisplay.java    From jacamo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public MsgDisplay(String name){
    setTitle(name+" console");
    setSize(405,405);

    JPanel panel = new JPanel();
    setContentPane(panel);
    panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));

    text = new JTextArea();
    text.setMinimumSize(new Dimension(400,400));
    text.setMaximumSize(new Dimension(400,400));
    text.setPreferredSize(new Dimension(400,400));
    text.setEditable(true);

    panel.add(text);
    panel.add(Box.createVerticalStrut(5));
}
 
Example 3
Source File: GeneralPropertiesProvider.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public PropertiesPanel createPanel(JvmstatApplication dataSource) {
    PropertiesPanel panel = new PropertiesPanel();
    panel.setLayout(new BorderLayout());
    JTextArea textArea = new JTextArea() {
        public Dimension getMinimumSize() {
            Dimension prefSize = getPreferredSize();
            Dimension minSize = super.getMinimumSize();
            prefSize.width = 0;
            if (minSize.height < prefSize.height) return prefSize;
            else return minSize;
        }
    };
    textArea.setBorder(BorderFactory.createEmptyBorder());
    textArea.setOpaque(false);
    // Nimbus LaF doesn't respect setOpaque(false), this is a workaround.
    // May cause delays for remote X sessions due to color transparency.
    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) // NOI18N
        textArea.setBackground(new Color(0, 0, 0, 0));
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setText(NbBundle.getMessage(GeneralPropertiesProvider.class,
            PropertiesImpl.isLocalConnection(dataSource) ?
            "MSG_ConnectionPropertiesDefault" : "MSG_ConnectionPropertiesCustom")); // NOI18N
    textArea.setMinimumSize(new Dimension(1, 1));
    textArea.setCaretPosition(0);
    panel.add(textArea, BorderLayout.CENTER);
    return panel;
}
 
Example 4
Source File: GeneralPropertiesProvider.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public PropertiesPanel createPanel(ApplicationSupport.CurrentApplication dataSource) {
    PropertiesPanel panel = new PropertiesPanel();
    panel.setLayout(new BorderLayout());
    JTextArea textArea = new JTextArea(NbBundle.getMessage(
            GeneralPropertiesProvider.class, "MSG_ConnectionProperties")) { // NOI18N
        public Dimension getMinimumSize() {
            Dimension prefSize = getPreferredSize();
            Dimension minSize = super.getMinimumSize();
            prefSize.width = 0;
            if (minSize.height < prefSize.height) return prefSize;
            else return minSize;
        }
    };
    textArea.setBorder(BorderFactory.createEmptyBorder());
    textArea.setOpaque(false);
    // Nimbus LaF doesn't respect setOpaque(false), this is a workaround.
    // May cause delays for remote X sessions due to color transparency.
    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) // NOI18N
        textArea.setBackground(new Color(0, 0, 0, 0));
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setCaretPosition(0);
    textArea.setMinimumSize(new Dimension(1, 1));
    panel.add(textArea, BorderLayout.CENTER);

    return panel;
}
 
Example 5
Source File: GeneralPropertiesProvider.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public PropertiesPanel createPanel(JmxApplication dataSource) {
    PropertiesPanel panel = new PropertiesPanel();
    panel.setLayout(new BorderLayout());
    JTextArea textArea = new JTextArea() {
        public Dimension getMinimumSize() {
            Dimension prefSize = getPreferredSize();
            Dimension minSize = super.getMinimumSize();
            prefSize.width = 0;
            if (minSize.height < prefSize.height) return prefSize;
            else return minSize;
        }
    };
    textArea.setBorder(BorderFactory.createEmptyBorder());
    textArea.setOpaque(false);
    // Nimbus LaF doesn't respect setOpaque(false), this is a workaround.
    // May cause delays for remote X sessions due to color transparency.
    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) // NOI18N
        textArea.setBackground(new Color(0, 0, 0, 0));
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setText(NbBundle.getMessage(GeneralPropertiesProvider.class, "MSG_ConnectionProperties")); // NOI18N
    textArea.setCaretPosition(0);
    textArea.setMinimumSize(new Dimension(1, 1));
    panel.add(textArea, BorderLayout.CENTER);
    return panel;
}
 
Example 6
Source File: GeneralPropertiesProvider.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public PropertiesPanel createPanel(final Host dataSource) {
    PropertiesPanel panel = new PropertiesPanel();
    panel.setLayout(new BorderLayout());
    final JTextArea textArea = new JTextArea() {
        public Dimension getMinimumSize() {
            Dimension prefSize = getPreferredSize();
            Dimension minSize = super.getMinimumSize();
            prefSize.width = 0;
            if (minSize.height < prefSize.height) return prefSize;
            else return minSize;
        }
    };
    textArea.setBorder(BorderFactory.createEmptyBorder());
    textArea.setOpaque(false);
    // Nimbus LaF doesn't respect setOpaque(false), this is a workaround.
    // May cause delays for remote X sessions due to color transparency.
    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) // NOI18N
        textArea.setBackground(new Color(0, 0, 0, 0));
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    String resolving = NbBundle.getMessage(GeneralPropertiesProvider.class, "LBL_Resolving"); // NOI18N
    updateProperties(textArea, resolving, resolving);
    textArea.setMinimumSize(new Dimension(1, 1));
    panel.add(textArea, BorderLayout.CENTER);
    VisualVM.getInstance().runTask(new Runnable() {
        public void run() {
            InetAddress address = dataSource.getInetAddress();
            final String hostname = address.getCanonicalHostName();
            final String ip = address.getHostAddress();
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    updateProperties(textArea, hostname, ip);
                }
            });
        }
    });
    return panel;
}
 
Example 7
Source File: VectorContentViewer.java    From SVG-Android with Apache License 2.0 5 votes vote down vote up
VectorContentViewer(String stringData, OnTextWatcher textWatcher) {
    this.mTextWatcher = textWatcher;
    setLayout(new GridLayout(1, 1));
    mTextArea = new JTextArea();
    mTextArea.setText(stringData);
    mTextArea.getDocument().addDocumentListener(this);
    mTextArea.setMinimumSize(new Dimension(200, 200));
    add(mTextArea);
}
 
Example 8
Source File: BasicQOptionPaneUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected void updateMainMessage(QOptionPane pane) {
	super.updateMainMessage(pane);
	JTextArea mainText = getMainMessageTextArea(pane);
	Dimension mainTextSize = TextSize.getPreferredSize(mainText,
			getInt(pane, KEY_MESSAGE_WIDTH));
	Insets insets = getInsets(pane, KEY_MAIN_MESSAGE_INSETS);
	mainTextSize.width += insets.left + insets.right;
	mainTextSize.height += insets.top + insets.bottom;
	mainText.setPreferredSize(mainTextSize);
	mainText.setMinimumSize(mainTextSize);
	mainText.setEnabled(getBoolean(pane, KEY_TEXT_EDITABLE));
	mainText.setOpaque(false);
}
 
Example 9
Source File: BasicQOptionPaneUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected void updateSecondaryMessage(QOptionPane pane) {
	super.updateSecondaryMessage(pane);
	JTextArea secondaryText = getSecondaryMessageTextArea(pane);
	Dimension secondaryTextSize = TextSize.getPreferredSize(secondaryText,
			getInt(pane, KEY_MESSAGE_WIDTH));
	Insets insets = getInsets(pane, KEY_SECONDARY_MESSAGE_INSETS);
	secondaryTextSize.width += insets.left + insets.right;
	secondaryTextSize.height += insets.top + insets.bottom;
	secondaryText.setPreferredSize(secondaryTextSize);
	secondaryText.setMinimumSize(secondaryTextSize);
	secondaryText.setEnabled(getBoolean(pane, KEY_TEXT_EDITABLE));
	secondaryText.setOpaque(false);
}
 
Example 10
Source File: DeprecationWarning.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates a multiline text label, which does not support HTML
 *
 * @param text
 * 		the text of the label
 * @return a multi line label
 */
private static JComponent createMultiLineLabel(String text) {
	JTextArea flowLabel = new JTextArea(text, 1, 0);
	flowLabel.setDisabledTextColor(flowLabel.getForeground());
	flowLabel.setMinimumSize(new Dimension(20, 40));
	flowLabel.setBackground(null);
	flowLabel.setLineWrap(true);
	flowLabel.setWrapStyleWord(true);
	flowLabel.setBorder(BorderFactory.createEmptyBorder());
	flowLabel.setOpaque(false);
	flowLabel.setEnabled(false);
	return flowLabel;
}
 
Example 11
Source File: JTableLogs.java    From mts with GNU General Public License v3.0 4 votes vote down vote up
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    JTextArea jTextArea = super.getJTextArea(isSelected);
    TextEvent textEvent = (TextEvent) table.getModel().getValueAt(row, column);

    if (null == value) {
        jTextArea.setText("");
        jTextArea.setBackground(Color.WHITE);
        jTextArea.setForeground(Color.BLACK);
    }
    else {
        String text = textEvent.getText();
        jTextArea.setText(text);

        jTextArea.setBackground(GuiHelper.getColorForTopic(textEvent.getTopic()));
        jTextArea.setForeground(GuiHelper.getColorForLevel(textEvent.getLevel()));

        jTextArea.setMinimumSize(new Dimension(table.getRowHeight(), table.getRowHeight()));

        // to get the prefered height
        jTextArea.setSize(table.getColumnModel().getColumn(column).getWidth(), -1);
        jTextArea.setSize(table.getColumnModel().getColumn(column).getWidth(), (int) jTextArea.getPreferredSize().getHeight());
        int preferedHeight = (int) Math.round(jTextArea.getPreferredSize().getHeight());

        // set the prefered height if is different
        if (table.getRowHeight(row) != preferedHeight && table.getRowHeight(row) != table.getRowHeight()) {
            table.setRowHeight(row, preferedHeight);
        }
        if (search != null) {
            if (text.toLowerCase().contains(search)) {
                jTextArea.setBackground(Color.ORANGE);
                jTextArea.setForeground(Color.BLACK);
            }
        }
        if ((row == index) && (index > -1)) {
            jTextArea.setBackground(Color.YELLOW);
            jTextArea.setForeground(Color.BLACK);

          //  table.setRowHeight(row, (int) jTextArea.getPreferredSize().getHeight());
        }

    }

    if (table.getRowHeight(row) != table.getRowHeight()) {
        jTextArea.setToolTipText("Click to collapse");
    }

    return jTextArea;
}
 
Example 12
Source File: EULADialog.java    From azure-devops-intellij with MIT License 4 votes vote down vote up
private EULADialog(@Nullable Project project, @NotNull String title, @Nullable String eulaText, boolean isPlainText, OnEulaAccepted onAccept) {
    super(project);
    this.onAccept = onAccept;
    myEulaTextFound = eulaText != null;

    JComponent component;
    if (isPlainText) {
        JTextArea textArea = new JTextArea();
        textArea.setText(eulaText);
        textArea.setMinimumSize(null);
        textArea.setEditable(false);
        textArea.setCaretPosition(0);
        textArea.setBackground(null);
        textArea.setBorder(JBUI.Borders.empty());

        component = textArea;
    } else {
        JEditorPane editor = new JEditorPane();
        editor.setContentType("text/html");
        editor.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); // work around <meta> tag
        editor.setText(eulaText);
        editor.setEditable(false);
        editor.setCaretPosition(0);
        editor.setMinimumSize(null);
        editor.setBorder(JBUI.Borders.empty());

        component = editor;
    }

    myScrollPane = new JBScrollPane(component);
    myScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    setModal(true);
    setTitle(title);

    setOKButtonText("Accept");
    getOKAction().putValue(DEFAULT_ACTION, null);

    setCancelButtonText("Decline");
    getCancelAction().putValue(DEFAULT_ACTION, Boolean.TRUE);

    init();
}