List of usage examples for javax.swing JTextArea setLineWrap
@BeanProperty(preferred = true, description = "should lines be wrapped") public void setLineWrap(boolean wrap)
From source file:org.apache.jackrabbit.oak.explorer.Explorer.java
private void createAndShowGUI(final File path, boolean skipSizeCheck) throws IOException { JTextArea log = new JTextArea(5, 20); log.setMargin(new Insets(5, 5, 5, 5)); log.setLineWrap(true); log.setEditable(false);/*from w ww .ja v a 2 s . com*/ final NodeStoreTree treePanel = new NodeStoreTree(backend, log, skipSizeCheck); final JFrame frame = new JFrame("Explore " + path + " @head"); frame.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent windowEvent) { IOUtils.closeQuietly(treePanel); System.exit(0); } }); JPanel content = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(treePanel), new JScrollPane(log)); splitPane.setDividerLocation(0.3); content.add(new JScrollPane(splitPane), c); frame.getContentPane().add(content); JMenuBar menuBar = new JMenuBar(); menuBar.setMargin(new Insets(2, 2, 2, 2)); JMenuItem menuReopen = new JMenuItem("Reopen"); menuReopen.setMnemonic(KeyEvent.VK_R); menuReopen.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { try { treePanel.reopen(); } catch (IOException e) { throw new RuntimeException(e); } } }); JMenuItem menuCompaction = new JMenuItem("Time Machine"); menuCompaction.setMnemonic(KeyEvent.VK_T); menuCompaction.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { List<String> revs = backend.readRevisions(); String s = (String) JOptionPane.showInputDialog(frame, "Revert to a specified revision", "Time Machine", JOptionPane.PLAIN_MESSAGE, null, revs.toArray(), revs.get(0)); if (s != null && treePanel.revert(s)) { frame.setTitle("Explore " + path + " @" + s); } } }); JMenuItem menuRefs = new JMenuItem("Tar File Info"); menuRefs.setMnemonic(KeyEvent.VK_I); menuRefs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { List<String> tarFiles = new ArrayList<String>(); for (File f : path.listFiles()) { if (f.getName().endsWith(".tar")) { tarFiles.add(f.getName()); } } String s = (String) JOptionPane.showInputDialog(frame, "Choose a tar file", "Tar File Info", JOptionPane.PLAIN_MESSAGE, null, tarFiles.toArray(), tarFiles.get(0)); if (s != null) { treePanel.printTarInfo(s); } } }); JMenuItem menuSCR = new JMenuItem("Segment Refs"); menuSCR.setMnemonic(KeyEvent.VK_R); menuSCR.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { String s = JOptionPane.showInputDialog(frame, "Segment References\nUsage: <segmentId>", "Segment References", JOptionPane.PLAIN_MESSAGE); if (s != null) { treePanel.printSegmentReferences(s); } } }); JMenuItem menuDiff = new JMenuItem("SegmentNodeState diff"); menuDiff.setMnemonic(KeyEvent.VK_D); menuDiff.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { String s = JOptionPane.showInputDialog(frame, "SegmentNodeState diff\nUsage: <recordId> <recordId> [<path>]", "SegmentNodeState diff", JOptionPane.PLAIN_MESSAGE); if (s != null) { treePanel.printDiff(s); } } }); JMenuItem menuPCM = new JMenuItem("Persisted Compaction Maps"); menuPCM.setMnemonic(KeyEvent.VK_P); menuPCM.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { treePanel.printPCMInfo(); } }); menuBar.add(menuReopen); menuBar.add(new JSeparator(JSeparator.VERTICAL)); menuBar.add(menuCompaction); menuBar.add(new JSeparator(JSeparator.VERTICAL)); menuBar.add(menuRefs); menuBar.add(new JSeparator(JSeparator.VERTICAL)); menuBar.add(menuSCR); menuBar.add(new JSeparator(JSeparator.VERTICAL)); menuBar.add(menuDiff); menuBar.add(new JSeparator(JSeparator.VERTICAL)); menuBar.add(menuPCM); menuBar.add(new JSeparator(JSeparator.VERTICAL)); frame.setJMenuBar(menuBar); frame.pack(); frame.setSize(960, 720); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:org.executequery.gui.editor.LobDataItemViewerPanel.java
private JTextArea createTextArea() { JTextArea textArea = new JTextArea(); textArea.setEditable(false);/*from w w w.j av a 2s.c o m*/ textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setFont(new Font("monospaced", Font.PLAIN, 11)); return textArea; }
From source file:org.jets3t.gui.UserInputFields.java
/** * Builds a user input panel matching the fields specified in the uploader.properties file. * * @param fieldsPanel/* ww w . j a v a2 s . c om*/ * the panel component to add prompt and user input components to. * @param uploaderProperties * properties specific to the Uploader application that includes the field.* settings * necessary to build the User Inputs screen. * * @return * true if there is at least one valid user input field, false otherwise. */ public boolean buildFieldsPanel(JPanel fieldsPanel, Jets3tProperties uploaderProperties) { int fieldIndex = 0; for (int fieldNo = 0; fieldNo < 100; fieldNo++) { String fieldName = uploaderProperties.getStringProperty("field." + fieldNo + ".name", null); String fieldType = uploaderProperties.getStringProperty("field." + fieldNo + ".type", null); String fieldPrompt = uploaderProperties.getStringProperty("field." + fieldNo + ".prompt", null); String fieldOptions = uploaderProperties.getStringProperty("field." + fieldNo + ".options", null); String fieldDefault = uploaderProperties.getStringProperty("field." + fieldNo + ".default", null); if (fieldName == null) { log.debug("No field with index number " + fieldNo); continue; } else { if (fieldType == null || fieldPrompt == null) { log.warn("Field '" + fieldName + "' missing .type or .prompt properties"); continue; } if ("message".equals(fieldType)) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); } else if ("radio".equals(fieldType)) { if (fieldOptions == null) { log.warn( "Radio button field '" + fieldName + "' is missing the required .options property"); continue; } JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); JPanel optionsPanel = skinsFactory.createSkinnedJPanel("OptionsPanel"); optionsPanel.setLayout(new GridBagLayout()); int columnOffset = 0; ButtonGroup buttonGroup = new ButtonGroup(); StringTokenizer st = new StringTokenizer(fieldOptions, ","); while (st.hasMoreTokens()) { String option = st.nextToken(); JRadioButton radioButton = skinsFactory.createSkinnedJRadioButton(fieldName); radioButton.setText(option); buttonGroup.add(radioButton); if (fieldDefault != null && fieldDefault.equals(option)) { // This option is the default one. radioButton.setSelected(true); } else if (buttonGroup.getButtonCount() == 1) { // Make first button the default. radioButton.setSelected(true); } optionsPanel.add(radioButton, new GridBagConstraints(columnOffset++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); } fieldsPanel.add(optionsPanel, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsNone, 0, 0)); userInputComponentsMap.put(fieldName, buttonGroup); } else if ("selection".equals(fieldType)) { if (fieldOptions == null) { log.warn( "Radio button field '" + fieldName + "' is missing the required .options property"); continue; } JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); JComboBox comboBox = skinsFactory.createSkinnedJComboBox(fieldName); StringTokenizer st = new StringTokenizer(fieldOptions, ","); while (st.hasMoreTokens()) { String option = st.nextToken(); comboBox.addItem(option); } if (fieldDefault != null) { comboBox.setSelectedItem(fieldDefault); } fieldsPanel.add(comboBox, new GridBagConstraints(0, fieldIndex++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); userInputComponentsMap.put(fieldName, comboBox); } else if ("text".equals(fieldType)) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); JTextField textField = skinsFactory.createSkinnedJTextField(fieldName); if (fieldDefault != null) { textField.setText(fieldDefault); } fieldsPanel.add(textField, new GridBagConstraints(0, fieldIndex++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); userInputComponentsMap.put(fieldName, textField); } else if ("password".equals(fieldType)) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); JPasswordField passwordField = skinsFactory.createSkinnedJPasswordField(fieldName); if (fieldDefault != null) { passwordField.setText(fieldDefault); } fieldsPanel.add(passwordField, new GridBagConstraints(0, fieldIndex++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); userInputComponentsMap.put(fieldName, passwordField); } else if (fieldType.equals("textarea")) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 2, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); JTextArea textArea = skinsFactory.createSkinnedJTextArea(fieldName); textArea.setLineWrap(true); if (fieldDefault != null) { textArea.setText(fieldDefault); } JScrollPane scrollPane = skinsFactory.createSkinnedJScrollPane(fieldName); scrollPane.setViewportView(textArea); fieldsPanel.add(scrollPane, new GridBagConstraints(0, fieldIndex++, 2, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, insetsDefault, 0, 0)); userInputComponentsMap.put(fieldName, textArea); } else { log.warn("Unrecognised .type setting for field '" + fieldName + "'"); } } } return isUserInputFieldsAvailable(); }
From source file:org.kepler.gui.ComponentLibraryPreferencesTab.java
/** * Initialize the top panel that contains controls for the table. */// w ww .jav a 2 s. c o m private void initDoc() { String header = StaticResources.getDisplayString("preferences.description1", "The Component Library is built using KAR files found" + " in the following local directories. Adding or removing local directories will rebuild" + " the component library.") + "\n\n" + StaticResources.getDisplayString("preferences.description2", "By selecting the search box next to remote" + " repositories, components from the remote repositories will be included" + " when searching components.") + "\n\n" + StaticResources.getDisplayString("preferences.description3", "By selecting the save box next to a local repository, KAR files will be saved" + " to that directory by default.") + "\n\n" + StaticResources.getDisplayString("preferences.description4", "By selecting the save box next to a remote repository, you will be asked " + " if you want to upload the KAR to that repository when it is saved."); JTextArea headerTextArea = new JTextArea(header); headerTextArea.setEditable(false); headerTextArea.setLineWrap(true); headerTextArea.setWrapStyleWord(true); headerTextArea.setPreferredSize(new Dimension(300, 400)); headerTextArea.setBackground(TabManager.BGCOLOR); JPanel headerPanel = new JPanel(new BorderLayout()); headerPanel.setBackground(TabManager.BGCOLOR); headerPanel.add(headerTextArea, BorderLayout.CENTER); JScrollPane headerPane = new JScrollPane(headerPanel); headerPane.setPreferredSize(new Dimension(300, 150)); add(headerPane); }
From source file:org.opencms.applet.upload.FileUploadApplet.java
/** * Displays the dialog that shows the list of files that will be overwritten on the server. * <p>//from w w w. java 2 s.c o m * The user may uncheck the checkboxes in front of the relative paths to avoid overwriting. * <p> * * @param duplications * a list of Strings that are relative paths to the files that will be overwritten on the server * * @return one of */ private int showDuplicationsDialog(List duplications) { int rtv = ModalDialog.ERROR_OPTION; try { JTextArea dialogIntroPanel = new JTextArea(); dialogIntroPanel.setLineWrap(true); dialogIntroPanel.setWrapStyleWord(true); dialogIntroPanel.setText(m_overwriteDialogIntro); dialogIntroPanel.setEditable(false); dialogIntroPanel.setBackground(m_fileSelector.getBackground()); dialogIntroPanel.setFont(m_font); FileSelectionPanel selectionPanel = new FileSelectionPanel(duplications, m_fileSelector.getCurrentDirectory().getAbsolutePath()); JPanel stacker = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.gridheight = 1; gbc.gridwidth = 1; gbc.weightx = 1f; gbc.weighty = 0f; gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(2, 2, 2, 2); stacker.add(dialogIntroPanel, gbc); gbc.weighty = 1f; gbc.gridy = 1; gbc.insets = new Insets(0, 2, 0, 2); stacker.add(selectionPanel, gbc); m_overwriteDialog = new ModalDialog(m_fileSelector, m_overwriteDialogTitle, m_overwriteDialogOk, m_overwriteDialogCancel, stacker); m_overwriteDialog.setSize(new Dimension(560, 280)); //dialog.setResizable(false); m_overwriteDialog.showDialog(); rtv = m_overwriteDialog.getReturnValue(); } catch (Throwable f) { f.printStackTrace(System.err); } return rtv; }
From source file:org.paxle.desktop.impl.dialogues.settings.AbstractAttrConfig.java
protected JTextArea createDescription(final String desc) { final JTextArea df = new JTextArea(desc); Utilities.instance.setTextLabelDefaults(df); df.setLineWrap(true); df.setWrapStyleWord(true);/*from ww w.j a va 2 s . c om*/ return df; }
From source file:org.pgptool.gui.ui.tools.UiUtils.java
private static JScrollPane getScrollableMessage(String msg) { JTextArea textArea = new JTextArea(msg); textArea.setLineWrap(true); textArea.setWrapStyleWord(true);/*from w w w. j a va 2 s. c o m*/ textArea.setEditable(false); textArea.setMargin(new Insets(5, 5, 5, 5)); textArea.setFont(new JTextField().getFont()); // dirty fix to use better font JScrollPane scrollPane = new JScrollPane(); scrollPane.setPreferredSize(new Dimension(700, 150)); scrollPane.getViewport().setView(textArea); return scrollPane; }
From source file:org.photovault.swingui.PhotoInfoEditor.java
private void createRightsUI() { JPanel pane = new JPanel(); tabPane.addTab("Rights", pane); JLabel copyrightLabel = new JLabel("Copyright"); JTextField copyrightField = createMvTextField("usageRights.copyright", 30); JLabel attributionLabel = new JLabel("Name for attribution"); JTextField attributionField = createMvTextField("usageRights.attributionName", 30); JLabel attributionUrlLabel = new JLabel("Url for attribution"); JTextField attributionUrlField = createMvTextField("usageRights.attributionUrl", 30); JLabel licenseLabel = new JLabel("License"); List<License> licenses = new ArrayList(); licenses.addAll(EnumSet.allOf(License.class)); JComboBox licenseCombo = createMvComboBox("usageRights.license", licenses); // Tech note text JLabel termsLabel = new JLabel("Usage terms"); JTextArea termsTextArea = createMvTextArea("usageRights.usageTerms", 5, 40); termsTextArea.setLineWrap(true); termsTextArea.setWrapStyleWord(true); JScrollPane termsScrollPane = new JScrollPane(termsTextArea); termsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); Border termsBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); termsBorder = BorderFactory.createTitledBorder(termsBorder, "Usage terms"); termsScrollPane.setBorder(termsBorder); GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); pane.setLayout(layout);//from w ww. j a v a 2s . com JLabel[] labels = { copyrightLabel, licenseLabel, attributionLabel, attributionUrlLabel }; JComponent[] fields = { copyrightField, licenseCombo, attributionField, attributionUrlField }; addLabelTextRows(labels, fields, layout, pane); pane.add(termsScrollPane); c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; layout.setConstraints(termsScrollPane, c); }
From source file:org.p_vcd.ui.LicenseDialog.java
public LicenseDialog(String libName, String libHomepage, String licenseName, String licenseFilename) { setSize(680, 480);//from w ww .ja v a 2 s.c om setTitle(libName); getContentPane().setLayout(new BorderLayout()); { JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.NORTH); panel.setLayout(new MigLayout("", "[grow,trailing][grow]", "[20px][][]")); { JLabel lblSoft = new JLabel(libName); lblSoft.setFont(new Font("Tahoma", Font.BOLD, 16)); panel.add(lblSoft, "center,cell 0 0 2 1"); } { JLabel lblHomePage = new JLabel("Home page:"); lblHomePage.setFont(new Font("Tahoma", Font.BOLD, 14)); panel.add(lblHomePage, "cell 0 1"); } { JLabel lblHome = SwingUtil.createLink(libHomepage, libHomepage); lblHome.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(lblHome, "cell 1 1"); } { JLabel lblNewLabel = new JLabel("License:"); lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 14)); panel.add(lblNewLabel, "cell 0 2"); } { JLabel lblLicense = new JLabel(licenseName); lblLicense.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(lblLicense, "cell 1 2"); } } { JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.CENTER); panel.setLayout(new FlowLayout()); panel.setBorder(new EmptyBorder(5, 5, 5, 5)); JScrollPane scrollPane = new JScrollPane(); scrollPane.setPreferredSize(new Dimension(600, 300)); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); panel.add(scrollPane); { JTextArea txtLicense = new JTextArea(); txtLicense.setEditable(false); txtLicense.setFont(new Font("Monospaced", Font.PLAIN, 11)); txtLicense.setWrapStyleWord(true); txtLicense.setLineWrap(true); try { InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream("org/p_vcd/licenses/" + licenseFilename); String text = IOUtils.toString(is, "UTF-8"); IOUtils.closeQuietly(is); txtLicense.setText(text); txtLicense.setCaretPosition(0); } catch (Exception e) { e.printStackTrace(); } scrollPane.setViewportView(txtLicense); } } { JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.SOUTH); panel.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LicenseDialog.this.dispose(); } }); okButton.setActionCommand("OK"); panel.add(okButton); getRootPane().setDefaultButton(okButton); } }
From source file:org.revager.tools.GUITools.java
/** * Creates a new title text area for popup windows. * // ww w . java2s . c om * @param titleText * the title text * * @return the newly created text area */ public static JTextArea newPopupTitleArea(String titleText) { JTextArea textTitle = new JTextArea(); textTitle.setEditable(false); textTitle.setText(titleText); textTitle.setBackground(UI.POPUP_BACKGROUND); textTitle.setFont(UI.STANDARD_FONT.deriveFont(Font.BOLD)); textTitle.setLineWrap(true); textTitle.setWrapStyleWord(true); textTitle.setFocusable(false); textTitle.setBorder(new EmptyBorder(5, 5, 5, 5)); return textTitle; }