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.revager.tools.GUITools.java
/** * Sets the given text area into a scroll pane. * /* w w w. ja v a 2s .c o m*/ * @param txt * the text area * * @return the scroll pane */ public static JScrollPane setIntoScrllPn(JTextArea txt) { txt.setLineWrap(true); txt.setWrapStyleWord(true); return new JScrollPane(txt, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); }
From source file:org.tinymediamanager.ui.dialogs.BugReportDialog.java
/** * Instantiates a new feedback dialog./*w w w. j a va 2 s. c o m*/ */ public BugReportDialog() { super(BUNDLE.getString("BugReport"), "bugReportdialog"); getContentPane().setLayout(new BorderLayout(0, 0)); JPanel panelContent = new JPanel(); getContentPane().add(panelContent, BorderLayout.CENTER); panelContent.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_ROWSPEC, })); final JTextArea taDescription = new JTextArea(); taDescription.setOpaque(false); taDescription.setWrapStyleWord(true); taDescription.setLineWrap(true); taDescription.setEditable(false); taDescription.setText(BUNDLE.getString("BugReport.description")); //$NON-NLS-1$ panelContent.add(taDescription, "2, 2, 6, 1, fill, fill"); final JButton btnSaveLogs = new JButton(BUNDLE.getString("BugReport.createlogs")); //$NON-NLS-1$ btnSaveLogs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // open the log download window try { Path file = TmmUIHelper.saveFile(BUNDLE.getString("BugReport.savelogs"), "tmm_logs.zip", //$NON-NLS-1$ new FileNameExtensionFilter("Zip files", ".zip")); if (file != null) { writeLogsFile(file.toFile()); } } catch (Exception ex) { LOGGER.error("Could not write logs.zip: " + ex.getMessage()); } } }); final JLabel lblStep1 = new JLabel(BUNDLE.getString("BugReport.step1")); //$NON-NLS-1$ panelContent.add(lblStep1, "2, 4, default, top"); final JTextArea taStep1 = new JTextArea(); taStep1.setText(BUNDLE.getString("BugReport.step1.description")); //$NON-NLS-1$ taStep1.setOpaque(false); taStep1.setEditable(false); panelContent.add(taStep1, "5, 4, fill, fill"); panelContent.add(btnSaveLogs, "7, 4"); final JButton btnCreateIssue = new JButton(BUNDLE.getString("BugReport.craeteissue")); //$NON-NLS-1$ btnCreateIssue.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // create the url for github String baseUrl = "https://github.com/tinyMediaManager/tinyMediaManager/issues/new?body="; String params = "Version: " + ReleaseInfo.getRealVersion(); params += "\nBuild: " + ReleaseInfo.getRealBuildDate(); params += "\nOS: " + System.getProperty("os.name") + " " + System.getProperty("os.version"); params += "\nJDK: " + System.getProperty("java.version") + " " + System.getProperty("os.arch") + " " + System.getProperty("java.vendor"); params += "\n\n__What is the actual behaviour?__\n\n"; params += "\n\n__What is the expected behaviour?__\n\n"; params += "\n\n__Steps to reproduce:__\n\n"; params += "\n\n__Additional__\nHave you attached the logfile from the day it happened?"; String url = ""; try { url = baseUrl + URLEncoder.encode(params, "UTF-8"); TmmUIHelper.browseUrl(url); } catch (Exception e1) { LOGGER.error("FAQ", e1); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, url, "message.erroropenurl", new String[] { ":", e1.getLocalizedMessage() })); } } }); final JLabel lblStep2 = new JLabel(BUNDLE.getString("BugReport.step2")); //$NON-NLS-1$ panelContent.add(lblStep2, "2, 6, default, top"); final JTextArea taStep2 = new JTextArea(); taStep2.setOpaque(false); taStep2.setEditable(false); taStep2.setText(BUNDLE.getString("BugReport.step2.description")); //$NON-NLS-1$ panelContent.add(taStep2, "5, 6, fill, fill"); panelContent.add(btnCreateIssue, "7, 6"); final JLabel lblHintIcon = new JLabel(IconManager.HINT); panelContent.add(lblHintIcon, "3, 8"); final JLabel lblHint = new JLabel(BUNDLE.getString("BugReport.languagehint")); //$NON-NLS-1$ panelContent.add(lblHint, "5, 8"); JPanel panelButtons = new JPanel(); getContentPane().add(panelButtons, BorderLayout.SOUTH); JButton btnClose = new JButton(BUNDLE.getString("Button.close")); //$NON-NLS-1$ btnClose.setIcon(IconManager.CANCEL); btnClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); panelButtons.setLayout(new FormLayout( new ColumnSpec[] { ColumnSpec.decode("default:grow"), FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("25px"), FormSpecs.RELATED_GAP_ROWSPEC, })); panelButtons.add(btnClose, "2, 2"); }
From source file:org.tinymediamanager.ui.dialogs.RegisterDonatorVersionDialog.java
public RegisterDonatorVersionDialog() { super(BUNDLE.getString("tmm.registerdonator"), "registerDonator"); //$NON-NLS-1$ setBounds(166, 5, 400, 300);/*from w w w . j av a 2s. c om*/ boolean isDonator = Globals.isDonator(); Properties props = null; if (isDonator) { props = License.decrypt(); } { JPanel panelContent = new JPanel(); getContentPane().add(panelContent, BorderLayout.CENTER); panelContent.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.PARAGRAPH_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.UNRELATED_GAP_ROWSPEC, })); { JTextArea textArea = new JTextArea(); textArea.setOpaque(false); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setEditable(false); panelContent.add(textArea, "2, 2, 3, 1, default, center"); if (isDonator) { textArea.setText(BUNDLE.getString("tmm.registerdonator.thanks")); //$NON-NLS-1$ } else { textArea.setText(BUNDLE.getString("tmm.registerdonator.hint")); //$NON-NLS-1$ } } { JLabel lblName = new JLabel(BUNDLE.getString("tmm.registerdonator.name")); //$NON-NLS-1$ panelContent.add(lblName, "2, 4, right, default"); tfName = new JTextField(""); lblName.setLabelFor(tfName); panelContent.add(tfName, "4, 4, fill, default"); tfName.setColumns(10); if (isDonator) { tfName.setText(props.getProperty("user")); tfName.setEnabled(false); } } { JLabel lblEmailAddress = new JLabel(BUNDLE.getString("tmm.registerdonator.email")); //$NON-NLS-1$ panelContent.add(lblEmailAddress, "2, 6, right, default"); tfEmailAddress = new JTextField(""); lblEmailAddress.setLabelFor(tfEmailAddress); panelContent.add(tfEmailAddress, "4, 6, fill, default"); tfEmailAddress.setColumns(10); if (isDonator) { tfEmailAddress.setText(props.getProperty("email")); tfEmailAddress.setEnabled(false); } } } { JPanel panelButtons = new JPanel(); panelButtons.setBorder(new EmptyBorder(4, 4, 4, 4)); getContentPane().add(panelButtons, BorderLayout.SOUTH); EqualsLayout layout = new EqualsLayout(5); layout.setMinWidth(100); panelButtons.setLayout(layout); { JButton btnRegister = new JButton(BUNDLE.getString("Button.register")); //$NON-NLS-1$ btnRegister.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try { LOGGER.debug("registering for donator version: ", tfEmailAddress.getText()); Properties p = new Properties(); p.setProperty("user", tfName.getText()); p.setProperty("email", tfEmailAddress.getText()); p.setProperty("generated", String.valueOf(new Date().getTime())); p.setProperty("uuid", FileUtils.readFileToString(new File("tmm.uuid"))); // get encrypted string and write tmm.lic if (License.encrypt(p) && License.isValid()) { JOptionPane.showMessageDialog(RegisterDonatorVersionDialog.this, BUNDLE.getString("tmm.registerdonator.success")); //$NON-NLS-1$ setVisible(false); } else { JOptionPane.showMessageDialog(RegisterDonatorVersionDialog.this, BUNDLE.getString("tmm.registerdonator.error")); //$NON-NLS-1$ } } catch (Exception ex) { LOGGER.error("Error registering donator version: " + ex.getMessage()); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); if (isDonator) { btnRegister.setEnabled(false); } panelButtons.add(btnRegister); } { JButton btnClose = new JButton(BUNDLE.getString("Button.close")); //$NON-NLS-1$ btnClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { setVisible(false); } }); panelButtons.add(btnClose); } } addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { tfName.requestFocus(); } }); }
From source file:org.ut.biolab.medsavant.client.filter.TabularFilterView.java
protected final void initContentPanel() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); if (availableValues == null) { JTextArea label = new JTextArea( "There are too many unique values to generate this list. You will not be able to filter on this column. "); label.setOpaque(false);//from w ww .ja va 2 s . c o m label.setLineWrap(true); label.setWrapStyleWord(true); gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(3, 3, 3, 3); add(label, gbc); this.showViewCard(); return; } applyButton = new JButton("Apply"); applyButton.setEnabled(false); AbstractListModel model = new SimpleListModel(); field = new QuickListFilterField(model); field.setHintText("Type here to filter options"); // the width of the field has to be less than the width // provided to the filter, otherwise, it will push the grid wider // and components will be inaccessible field.setPreferredSize(new Dimension(FIELD_WIDTH, 22)); filterableList = new FilterableCheckBoxList(field.getDisplayListModel()) { @Override public int getNextMatch(String prefix, int startIndex, Position.Bias bias) { return -1; } @Override public boolean isCheckBoxEnabled(int index) { return true; } }; filterableList.getCheckBoxListSelectionModel() .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); if (model.getSize() > 0) { filterableList.setPrototypeCellValue(model.getElementAt(0)); // Makes it much faster to determine the view's preferred size. } SearchableUtils.installSearchable(filterableList); filterableList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { applyButton.setEnabled(true); } } }); setAllSelected(true); applyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { applyFilter(); } }); JScrollPane jsp = new JScrollPane(filterableList) { @Override public Dimension getPreferredSize() { Dimension result = super.getPreferredSize(); result = new Dimension(Math.min(result.width, TabularFilterView.this.getWidth() - 20), result.height); return result; } }; selectAll = ViewUtil.createHyperLinkButton("Select All"); selectAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setAllSelected(true); applyButton.setEnabled(true); } }); JButton selectNone = ViewUtil.createHyperLinkButton("Select None"); selectNone.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setAllSelected(false); applyButton.setEnabled(true); } }); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(3, 15, 3, 15); add(field, gbc); gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(3, 3, 3, 3); add(jsp, gbc); gbc.gridwidth = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.NONE; add(selectAll, gbc); add(selectNone, gbc); gbc.weightx = 1.0; gbc.anchor = GridBagConstraints.EAST; add(applyButton, gbc); this.showViewCard(); }
From source file:org.ut.biolab.medsavant.client.view.component.SelectableListView.java
protected final void initContentPanel() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); if (availableValues == null) { JTextArea label = new JTextArea("There are too many values to display."); label.setOpaque(false);/*from ww w . ja va 2s . co m*/ label.setLineWrap(true); label.setWrapStyleWord(true); gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(3, 3, 3, 3); add(label, gbc); return; } AbstractListModel model = new SelectableListView.SimpleListModel(); field = new QuickListFilterField(model); field.setHintText("Type here to filter options"); // the width of the field has to be less than the width // provided to the filter, otherwise, it will push the grid wider // and components will be inaccessible field.setPreferredSize(new Dimension(FIELD_WIDTH, 22)); filterableList = new FilterableCheckBoxList(field.getDisplayListModel()) { @Override public int getNextMatch(String prefix, int startIndex, Position.Bias bias) { return -1; } @Override public boolean isCheckBoxEnabled(int index) { return true; } }; filterableList.getCheckBoxListSelectionModel() .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); if (model.getSize() > 0) { filterableList.setPrototypeCellValue(model.getElementAt(0)); // Makes it much faster to determine the view's preferred size. } SearchableUtils.installSearchable(filterableList); setAllSelected(true); JScrollPane jsp = new JScrollPane(filterableList) { @Override public Dimension getPreferredSize() { Dimension result = super.getPreferredSize(); result = new Dimension(Math.min(result.width, SelectableListView.this.getWidth() - 20), result.height); return result; } }; selectAll = ViewUtil.createHyperLinkButton("Select All"); selectAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setAllSelected(true); } }); JButton selectNone = ViewUtil.createHyperLinkButton("Select None"); selectNone.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setAllSelected(false); } }); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(3, 15, 3, 15); add(field, gbc); gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(3, 3, 3, 3); add(jsp, gbc); gbc.gridwidth = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.HORIZONTAL; JPanel bottom = new JPanel(); ViewUtil.applyHorizontalBoxLayout(bottom); bottom.add(selectAll); bottom.add(selectNone); bottom.add(Box.createHorizontalGlue()); JButton applyButton = new JButton("Apply"); applyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { saveSelections(); } }); bottom.add(applyButton); add(bottom, gbc); }
From source file:pcgen.gui2.dialog.AboutDialog.java
/** * Build up a scrollable list of monkeys, given the monkey names. * @param monkeys The names of the monkeys * @return A JScrollPane to display the monkeys. *//* w w w.java 2 s . com*/ private JScrollPane buildMonkeyList(String monkeys) { JTextArea textArea = new JTextArea(); JScrollPane scroller = new JScrollPane(); textArea.setWrapStyleWord(true); textArea.setLineWrap(true); textArea.setEditable(false); textArea.setText(monkeys); scroller.setViewportView(textArea); textArea.setCaretPosition(0); return scroller; }
From source file:pcgen.gui2.dialog.AboutDialog.java
/** * Construct the includes panel. This panel shows details * and licencing statrements about any libraries distributed * with PCGen.//from w w w . j a v a2s .c o m * * @return The includes panel. */ private JPanel buildIncludesPanel() { JPanel iPanel = new JPanel(); JTextArea otherLibrariesField = new JTextArea(); iPanel.setLayout(new BorderLayout()); String s = LanguageBundle.getString("in_abt_lib_apache"); //$NON-NLS-1$ s += LanguageBundle.getString("in_abt_lib_jdom"); //$NON-NLS-1$ s += LanguageBundle.getString("in_abt_lib_l2f"); //$NON-NLS-1$ otherLibrariesField.setText(s); otherLibrariesField.setWrapStyleWord(true); otherLibrariesField.setLineWrap(true); otherLibrariesField.setEditable(false); otherLibrariesField.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); iPanel.add(otherLibrariesField, BorderLayout.CENTER); return iPanel; }
From source file:pcgen.gui2.dialog.AboutDialog.java
/** * Construct the awards panel. This panel shows each award * the pcgen project has been awarded/* w w w. ja v a 2 s . c o m*/ * * @return The awards panel. */ private JPanel buildAwardsPanel() { JScrollPane sp = new JScrollPane(); JPanel panel = new JPanel(); JPanel aPanel = new JPanel(); aPanel.setLayout(new GridBoxLayout(2, 2)); aPanel.setBackground(Color.WHITE); Icon goldIcon = Icons.createImageIcon("gold200x200-2005.gif"); if (goldIcon != null) { JLabel e2005 = new JLabel(goldIcon); aPanel.add(e2005); JTextArea title = new JTextArea(); title.setLineWrap(true); title.setWrapStyleWord(true); title.setEditable(false); title.setText(LanguageBundle.getString("in_abt_awards_2005_ennie")); aPanel.add(title); } Icon bronzeIcon = Icons.createImageIcon("bronze200x200-2003.gif"); if (bronzeIcon != null) { JLabel e2003 = new JLabel(bronzeIcon); aPanel.add(e2003); JTextArea title = new JTextArea(); title.setLineWrap(true); title.setWrapStyleWord(true); title.setEditable(false); title.setText(LanguageBundle.getString("in_abt_awards_2003_ennie")); aPanel.add(title); } sp.setViewportView(aPanel); panel.add(sp, BorderLayout.CENTER); return panel; }
From source file:plpwr.Task3.java
/*** * @link http://stackoverflow.com/a/18068820/781312 */// w ww . j a v a 2s . co m public Task3() throws Throwable { Reader filereader; try { File[] files = {}; // files= new Task2.FileDialogFluent(Window.getWindow(), "Choose file", FileDialog.LOAD).setVisibleFluent(true).getFiles(); File file = files[0]; filereader = new FileReader(file); } catch (Throwable t) { String input = "name,dateOfBirth,dept,jobTitle\n" + "John,1962-11-24,accounting,senior accountant\n" + "Tina,1962-09-26,administration,manager\n" + "Karen,1972-01-10, marketing,graphic designer\n" + "Michael,1978-02-11,research,programmer\n" + "Sandra,1976-10-26,marketing,account manager"; filereader = new StringReader(input); } CSVReader reader = new CSVReader(filereader); List<String[]> rows = reader.readAll(); String header[] = rows.remove(0); System.out.println(StringUtils.join(header, '\t')); for (String[] str : rows) { System.out.println(StringUtils.join(str, '\t')); } DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element el = doc.createElement("employees"); for (String[] row : rows) { Element e = doc.createElement("employee"); for (int i = 0; i < row.length; i++) { System.out.println("ROW" + row[i]); Element a = doc.createElement(header[i]); a.appendChild(doc.createTextNode(row[i])); e.appendChild(a); } el.appendChild(e); } doc.appendChild(el); JTextArea msg = new JTextArea(App.formatDocument(doc)); msg.setLineWrap(true); msg.setWrapStyleWord(true); showDialog(null, msg); }
From source file:se.cambio.cds.gdl.editor.view.panels.DescriptionPanel.java
public JPanel getDescriptionPanel() { if (descriptionPanel == null) { descriptionPanel = new JPanel(new BorderLayout()); JTextArea ta = new JTextArea(); ta.setLineWrap(true); ta.setWrapStyleWord(true);//w ww.j av a 2 s . co m connect(_conceptContext, "/description", ta); ta.setBorder(BorderFactory.createEtchedBorder()); descriptionPanel.add(ta, BorderLayout.CENTER); } return descriptionPanel; }