Java Code Examples for javax.swing.JTextArea#setPreferredSize()
The following examples show how to use
javax.swing.JTextArea#setPreferredSize() .
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: NotifyDescriptor.java From netbeans with Apache License 2.0 | 6 votes |
/** * Define a descriptive message to be reported. In the most common * usage, the message is just a <code>String</code>. However, the type * of this parameter is actually <code>Object</code>. Its interpretation depends on * its type: * <dl compact> * <dt><code>Object[]</code><dd> A recursively interpreted series of messages. * <dt>{@link Component}<dd> The <code>Component</code> is displayed in the dialog. * <dt>{@link javax.swing.Icon}<dd> The <code>Icon</code> is wrapped in a {@link JLabel} and displayed in the dialog. * <dt>anything else<dd> The {@link Object#toString string representation} of the object. * </dl> * * @param newMessage the <code>Object</code> to report * @see #getMessage */ public void setMessage(Object newMessage) { checkMessageValidity(newMessage); Object oldMessage = message; if (newMessage instanceof String) { // bugfix #25457, use JTextArea for word-wrapping JTextArea area = new JTextArea((String) newMessage); area.setPreferredSize(new Dimension(SIZE_PREFERRED_WIDTH, SIZE_PREFERRED_HEIGHT)); area.setBackground(UIManager.getColor("Label.background")); // NOI18N area.setBorder(BorderFactory.createEmptyBorder()); area.setLineWrap(true); area.setWrapStyleWord(true); area.setEditable(false); area.setFocusable(true); area.getAccessibleContext().setAccessibleName(NbBundle.getMessage(NotifyDescriptor.class, "ACN_NotifyDescriptor_MessageJTextArea")); // NOI18N area.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(NotifyDescriptor.class, "ACD_NotifyDescriptor_MessageJTextArea")); // NOI18N newMessage = area; } message = newMessage; firePropertyChange(PROP_MESSAGE, oldMessage, newMessage); }
Example 2
Source File: Display.java From jacamo with GNU Lesser General Public License v3.0 | 6 votes |
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 3
Source File: MsgDisplay.java From jacamo with GNU Lesser General Public License v3.0 | 6 votes |
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 4
Source File: DLabel.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
Editor(final DLabel l) { super(getShortTitle()); label = l; jta = new JTextArea(label.title.equals(" ") ? "" : label.title, 5, 20); // the whole text is the 'title' in the Displayable class. jta.setLineWrap(true); jta.setWrapStyleWord(true); final JScrollPane jsp = new JScrollPane(jta); jta.setPreferredSize(new Dimension(200,200)); getContentPane().add(jsp); pack(); setVisible(true); final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); final Rectangle box = this.getBounds(); setLocation((screen.width - box.width) / 2, (screen.height - box.height) / 2); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(this); new ToFront(this); }
Example 5
Source File: InstancesView.java From netbeans with Apache License 2.0 | 5 votes |
public SuspendInfoPanel() { setLayout(new java.awt.GridBagLayout()); JTextArea infoText = new JTextArea(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp")); infoText.setEditable(false); infoText.setEnabled(false); infoText.setBackground(getBackground()); infoText.setDisabledTextColor(new JLabel().getForeground()); infoText.setLineWrap(true); infoText.setWrapStyleWord(true); infoText.setPreferredSize( new Dimension( infoText.getFontMetrics(infoText.getFont()).stringWidth(infoText.getText()), infoText.getPreferredSize().height)); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; //gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; //gridBagConstraints.weightx = 1.0; gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); add(infoText, gridBagConstraints); infoText.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp")); JButton pauseButton = new JButton(); pauseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doStopCurrentDebugger(); } }); org.openide.awt.Mnemonics.setLocalizedText(pauseButton, NbBundle.getMessage(InstancesView.class, "CTL_Pause")); pauseButton.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/actions/Pause.gif", false)); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); add(pauseButton, gridBagConstraints); }
Example 6
Source File: JFancyBox.java From pumpernickel with MIT License | 5 votes |
protected static JComponent createContent(String text) { JTextArea textArea = new JTextArea(text); Dimension d = TextSize.getPreferredSize(textArea, 500); textArea.setPreferredSize(d); textArea.setEditable(false); textArea.setWrapStyleWord(true); textArea.setLineWrap(true); textArea.setOpaque(false); return textArea; }
Example 7
Source File: BasicQOptionPaneUI.java From pumpernickel with MIT License | 5 votes |
@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 8
Source File: BasicQOptionPaneUI.java From pumpernickel with MIT License | 5 votes |
@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 9
Source File: InfoPage.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Adds text paragraph * * @param text */ public void addText(String text) { JTextArea textItem = new JTextArea(text); textItem.setLineWrap(true); textItem.setWrapStyleWord(true); textItem.setEditable(false); textItem.setBackground(infoPanel.getBackground()); textItem.setPreferredSize(new Dimension(560, 45)); JPanel itemPanel = new JPanel(); itemPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); itemPanel.add(textItem); infoPanel.add(itemPanel); }
Example 10
Source File: IndividualDataPanel.java From mvisc with GNU General Public License v3.0 | 4 votes |
public IndividualDataPanel(ZooracleContentPanel zooracleContentPanel) { this.zooracleContentPanel = zooracleContentPanel; labelName = GUISettings.getDefaultLabel(Locale.labelName, lw, lh, a, va); labelGender = GUISettings.getDefaultLabel(Locale.labelSex, lw, lh, a, va); labelComment = GUISettings.getDefaultLabel(Locale.labelComment, lw, 80, a, va); labelMetaData = GUISettings.getDefaultLabel(Locale.labelMetaData, lw, 100, a, va); textFieldName = new JTextField(""); textFieldName.setPreferredSize(new Dimension(200, 30)); textFieldName.setBorder(BorderFactory.createLineBorder(Color.BLACK)); textAreaComment = new JTextArea(); textAreaComment.setPreferredSize(new Dimension(200, 80)); textAreaComment.setBorder(BorderFactory.createLineBorder(Color.BLACK)); comboBoxGender = new JComboBox(); // comboBoxGender.setBorder(BorderFactory.createLineBorder(Color.BLACK)); for (Object item : Locale.dropDownGenders) comboBoxGender.addItem(item); // Create some items to add to the list String listData[] = { "BT_1.1", "BT_1.2", "BT_1.3", "BT_1.4" }; metaList = new JList(listData); JScrollPane metaScrollPane = new JScrollPane(metaList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); metaScrollPane.setPreferredSize(new Dimension(200, 100)); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel panelName = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel panelGender = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel panelComment = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel panelMetaList = new JPanel(new FlowLayout(FlowLayout.LEFT)); panelName.add(labelName); panelName.add(textFieldName); panelGender.add(labelGender); panelGender.add(comboBoxGender); panelComment.add(labelComment); panelComment.add(textAreaComment); panelMetaList.add(labelMetaData); panelMetaList.add(metaScrollPane); this.add(panelName); this.add(panelGender); this.add(panelComment); this.add(panelMetaList); this.setBackground(GUISettings.windowColor); this.setForeground(GUISettings.windowColor); this.setMinimumSize(new Dimension(300, 500)); }
Example 11
Source File: BasicFontChooserUI.java From orbit-image-analysis with GNU General Public License v3.0 | 4 votes |
protected void installComponents() { JLabel label; ResourceBundle bundle = ResourceBundle.getBundle(FontChooserUI.class.getName() + "RB"); fontPanel = new JPanel(new PercentLayout(PercentLayout.VERTICAL, 2)); fontPanel.add( label = new JLabel(bundle.getString("FontChooserUI.fontLabel"))); fontPanel.add(fontField = new JTextField(25)); fontField.setEditable(false); fontPanel.add(new JScrollPane(fontList = new JList()), "*"); label.setLabelFor(fontList); label.setDisplayedMnemonic( bundle.getString("FontChooserUI.fontLabel.mnemonic").charAt(0)); fontList.setVisibleRowCount(7); fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); String[] fontFamilies = chooser.getModel().getFontFamilies(null); fontList.setListData(fontFamilies); fontSizePanel = new JPanel(new PercentLayout(PercentLayout.VERTICAL, 2)); fontSizePanel.add( label = new JLabel(bundle.getString("FontChooserUI.styleLabel"))); fontSizePanel.add( boldCheck = new JCheckBox(bundle.getString("FontChooserUI.style.bold"))); fontSizePanel.add( italicCheck = new JCheckBox(bundle.getString("FontChooserUI.style.italic"))); boldCheck.setMnemonic( bundle.getString("FontChooserUI.style.bold.mnemonic").charAt(0)); italicCheck.setMnemonic( bundle.getString("FontChooserUI.style.italic.mnemonic").charAt(0)); fontSizePanel.add( label = new JLabel(bundle.getString("FontChooserUI.sizeLabel"))); label.setDisplayedMnemonic( bundle.getString("FontChooserUI.sizeLabel.mnemonic").charAt(0)); fontSizePanel.add(fontSizeField = new JTextField()); label.setLabelFor(fontSizeField); fontSizePanel.add(new JScrollPane(fontSizeList = new JList()), "*"); int[] defaultFontSizes = chooser.getModel().getDefaultSizes(); String[] sizes = new String[defaultFontSizes.length]; for (int i = 0, c = sizes.length; i < c; i++) { sizes[i] = String.valueOf(defaultFontSizes[i]); } fontSizeList.setListData(sizes); fontSizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fontSizeList.setVisibleRowCount(2); chooser.setLayout(LookAndFeelTweaks.createBorderLayout()); JPanel panel = new JPanel(); panel.setLayout(LookAndFeelTweaks.createHorizontalPercentLayout()); panel.add(fontPanel, "*"); panel.add(fontSizePanel); chooser.add("Center", panel); previewPanel = new JTextArea(); previewPanel.setPreferredSize(new Dimension(100, 40)); previewPanel.setText(chooser.getModel().getPreviewMessage(null)); JScrollPane scroll = new JScrollPane(previewPanel); chooser.add("South", scroll); }
Example 12
Source File: CreateIndexDialogFactory.java From lucene-solr with Apache License 2.0 | 4 votes |
private JPanel optionalSettings() { JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(false); JPanel description = new JPanel(); description.setLayout(new BoxLayout(description, BoxLayout.Y_AXIS)); description.setOpaque(false); JPanel name = new JPanel(new FlowLayout(FlowLayout.LEADING)); name.setOpaque(false); JLabel nameLbl = new JLabel(MessageUtils.getLocalizedMessage("createindex.label.option")); name.add(nameLbl); description.add(name); JTextArea descTA1 = new JTextArea(MessageUtils.getLocalizedMessage("createindex.textarea.data_help1")); descTA1.setPreferredSize(new Dimension(550, 20)); descTA1.setBorder(BorderFactory.createEmptyBorder(2, 10, 10, 5)); descTA1.setOpaque(false); descTA1.setLineWrap(true); descTA1.setEditable(false); description.add(descTA1); JPanel link = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 1)); link.setOpaque(false); JLabel linkLbl = FontUtils.toLinkText(new URLLabel(MessageUtils.getLocalizedMessage("createindex.label.data_link"))); link.add(linkLbl); description.add(link); JTextArea descTA2 = new JTextArea(MessageUtils.getLocalizedMessage("createindex.textarea.data_help2")); descTA2.setPreferredSize(new Dimension(550, 50)); descTA2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 5)); descTA2.setOpaque(false); descTA2.setLineWrap(true); descTA2.setEditable(false); description.add(descTA2); panel.add(description, BorderLayout.PAGE_START); JPanel dataDirPath = new JPanel(new FlowLayout(FlowLayout.LEADING)); dataDirPath.setOpaque(false); dataDirPath.add(new JLabel(MessageUtils.getLocalizedMessage("createindex.label.datadir"))); dataDirPath.add(dataDirTF); dataDirPath.add(dataBrowseBtn); dataDirPath.add(clearBtn); panel.add(dataDirPath, BorderLayout.CENTER); return panel; }
Example 13
Source File: TransferViewBuilder.java From raccoon4 with Apache License 2.0 | 4 votes |
@Override protected JPanel assemble() { peers = new Vector<TransferPeerBuilder>(); GridBagConstraints spacerConstraints = new GridBagConstraints(); spacerConstraints.gridx = GridBagConstraints.REMAINDER; spacerConstraints.gridy = GridBagConstraints.RELATIVE; spacerConstraints.weightx = 1; spacerConstraints.weighty = 1; spacerConstraints.fill = GridBagConstraints.BOTH; list = new JPanel(); list.setLayout(new GridBagLayout()); contentConstraints = new GridBagConstraints(); contentConstraints.gridx = GridBagConstraints.REMAINDER; contentConstraints.gridy = GridBagConstraints.RELATIVE; contentConstraints.fill = GridBagConstraints.HORIZONTAL; contentConstraints.anchor = GridBagConstraints.NORTH; contentConstraints.insets.bottom = 3; ActionLocalizer al = Messages.getLocalizer(); trim = new JButton(al.localize("trimdownloads")); trim.addActionListener(this); list.add(new JPanel(), spacerConstraints); JPanel cont = new JPanel(); cont.setLayout(new GridBagLayout()); GridBagConstraints contgbc = new GridBagConstraints(); if (!globals.get(Traits.class).isAvailable("4.0.x")) { JTextArea txt = new JTextArea(Messages.getString(ID + ".booster.plug")); txt.setLineWrap(true); txt.setWrapStyleWord(true); txt.setPreferredSize(new Dimension(ITEMWIDTH + 2 * 10,50)); txt.setEditable(false); txt.setBackground(null); txt.setForeground(Color.RED); cont.add(txt,contgbc); contgbc.gridx=0; contgbc.gridy =1; contgbc.insets = new Insets(5,5,5,5); contgbc.anchor=GridBagConstraints.NORTHEAST; order=new JButton(Messages.getString(ID + ".booster.ok")); order.addActionListener(this); cont.add(order,contgbc); contgbc.gridy=2; contgbc.gridx=0; } JScrollPane tmp = new JScrollPane(list); tmp.setBorder(BorderFactory.createEmptyBorder()); tmp.getVerticalScrollBar().setUnitIncrement(20); tmp.setPreferredSize(new Dimension(ITEMWIDTH + 2 * 10, 400)); tmp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); contgbc.weightx=1; contgbc.weighty=1; cont.add(tmp,contgbc); JPanel ret = new DialogBuilder(cont) .withTitle(Messages.getString(ID + ".title")) .withSubTitle(Messages.getString(ID + ".subtitle")) .withButtons(new ButtonBarBuilder().add(trim)).build(globals); globals.get(TransferManager.class).setPeer(this); return ret; }
Example 14
Source File: AboutActionListener.java From quickfix-messenger with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void actionPerformed(ActionEvent e) { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.weighty = 0.0; c.ipadx = 2; c.ipady = 2; JLabel titleLabel = new JLabel("<html><b>QuickFIX Messenger</b></html>"); JLabel nameLabel = new JLabel("<html><i>by Jan Amoyo</i></html>"); JLabel emailLabel = new JLabel("<html>[email protected]</html>"); JLabel webpageLabel = new JLabel( "<html><a href=''>quickfix-messenger</a></html>"); webpageLabel.addMouseListener(new LinkMouseAdapter(this, frame .getMessenger().getConfig().getHomeUrl())); webpageLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); JLabel licenseLabel = new JLabel("<html><b>License</b></html>"); JTextArea licenseText = new JTextArea(readLicenseFile(), 15, 60); licenseText.setWrapStyleWord(true); licenseText.setLineWrap(true); licenseText.setEditable(false); JScrollPane licenseTextScrollPane = new JScrollPane(licenseText); licenseText.setPreferredSize(new Dimension(400, 400)); licenseTextScrollPane.setBorder(new EtchedBorder()); c.gridx = 0; c.gridy = 0; panel.add(titleLabel, c); c.gridx = 0; c.gridy = 1; panel.add(nameLabel, c); c.gridx = 0; c.gridy = 2; panel.add(emailLabel, c); c.gridx = 0; c.gridy = 3; panel.add(webpageLabel, c); c.gridx = 0; c.gridy = 4; panel.add(Box.createRigidArea(new Dimension(50, 10)), c); c.gridx = 0; c.gridy = 5; panel.add(licenseLabel, c); c.gridx = 0; c.gridy = 6; panel.add(licenseTextScrollPane, c); JOptionPane.showMessageDialog(frame, panel, "About QuickFIX Messenger", JOptionPane.PLAIN_MESSAGE); }
Example 15
Source File: FeedbackDialog.java From chipster with MIT License | 4 votes |
public FeedbackDialog(SwingClientApplication application, String errorMessage, boolean sendSessionByDefault) { super(application.getMainFrame(), true); this.application = application; this.setTitle("Contact support"); this.errorMessage = errorMessage; // Layout this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.gridx = 0; c.gridy = 0; // Text are for entering details c.insets.set(10,10,5,10); c.gridy++; this.add(new JLabel("Message"), c); detailArea = new JTextArea(); detailArea.setLineWrap(true); detailArea.setWrapStyleWord(true); detailArea.setPreferredSize(new Dimension(300, 150)); c.insets.set(0, 10, 10, 10); c.gridy++; this.add(detailArea, c); // Email c.insets.set(10,10,5,10); c.gridy++; this.add(new JLabel("Your email"), c); emailField = new JTextField(); emailField.setPreferredSize(new Dimension(300, 20)); c.insets.set(0, 10, 10, 10); c.gridy++; this.add(emailField, c); // Checkbox for attaching user data c.insets.set(10,10,5,10); c.gridy++; attachSessionBox = new JCheckBox("Attach data and workflow information"); attachSessionBox.setSelected(sendSessionByDefault); this.add(attachSessionBox, c); // Checkbox for client logs c.insets.set(10,10,5,10); c.gridy++; attachLogsBox = new JCheckBox("Attach log files"); attachLogsBox.setSelected(true); this.add(attachLogsBox, c); // OK button okButton = new JButton("OK"); okButton.setPreferredSize(BUTTON_SIZE); okButton.addActionListener(this); // Cancel button cancelButton = new JButton("Cancel"); cancelButton.setPreferredSize(BUTTON_SIZE); cancelButton.addActionListener(this); // Buttons pannel JPanel buttonsPanel = new JPanel(); buttonsPanel.add(okButton); buttonsPanel.add(cancelButton); c.fill = GridBagConstraints.HORIZONTAL; c.insets.set(10, 10, 5, 10); c.gridy++; this.add(buttonsPanel, c); }
Example 16
Source File: Utility.java From freecol with GNU General Public License v2.0 | 2 votes |
/** * Gets a text area with standard settings suitable for use in FreeCol * panels, which can not adapt their size. * * @param text The text to display in the text area. * @param size The size of the area to display the text in. * @return A suitable text area. */ public static JTextArea getDefaultTextArea(String text, Dimension size) { JTextArea textArea = createTextArea(text); textArea.setPreferredSize(size); return textArea; }