Java Code Examples for javax.swing.JTextArea#setWrapStyleWord()
The following examples show how to use
javax.swing.JTextArea#setWrapStyleWord() .
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: OpenTextFileListener.java From collect-earth with MIT License | 6 votes |
public OpenTextFileListener(Frame owner, String filePath, String title) { this.filePath = filePath; dialog = new JDialog(owner, title + " " + filePath); //$NON-NLS-1$ dialog.setLocationRelativeTo(owner); dialog.setSize(new Dimension(300, 400)); dialog.setModal(true); final BorderLayout layoutManager = new BorderLayout(); final JPanel panel = new JPanel(layoutManager); dialog.add(panel); disclaimerTextArea = new JTextArea(); disclaimerTextArea.setEditable(false); disclaimerTextArea.setLineWrap(true); disclaimerTextArea.setWrapStyleWord(true); final JScrollPane scrollPane = new JScrollPane(disclaimerTextArea); panel.add(scrollPane, BorderLayout.CENTER); scrollPane.setPreferredSize(new Dimension(250, 250)); final JButton close = new JButton(Messages.getString("CollectEarthWindow.5")); //$NON-NLS-1$ close.addActionListener( e -> dialog.setVisible(false) ); panel.add(close, BorderLayout.SOUTH); }
Example 2
Source File: PrintLatinCJKTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void showFrame() { JFrame f = new JFrame(); JTextArea jta = new JTextArea(info, 4, 30); jta.setLineWrap(true); jta.setWrapStyleWord(true); f.add("Center", jta); JButton b = new JButton("Print"); b.addActionListener(testInstance); f.add("South", b); f.pack(); f.setVisible(true); }
Example 3
Source File: AboutDialog.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates a panel showing the licence. * * @return a panel. */ private JPanel createLicencePanel() { final JPanel licencePanel = new JPanel( new BorderLayout() ); final JTextArea area = new JTextArea( this.licence ); area.setLineWrap( true ); area.setWrapStyleWord( true ); area.setCaretPosition( 0 ); area.setEditable( false ); licencePanel.add( new JScrollPane( area ) ); return licencePanel; }
Example 4
Source File: UI.java From netbeans with Apache License 2.0 | 5 votes |
public static JTextArea createTextArea(int columns, String message) { JTextArea text = new JTextArea(message); text.setBackground(null); text.setEditable(false); text.setColumns(columns); text.setLineWrap(true); text.setWrapStyleWord(true); return text; }
Example 5
Source File: TableCellLongTextRenderer.java From WhiteRabbit with Apache License 2.0 | 5 votes |
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final JTextArea jtext = new JTextArea(); jtext.setText((String)value); jtext.setWrapStyleWord(true); jtext.setLineWrap(true); jtext.setFont(table.getFont()); jtext.setSize(table.getColumn(table.getColumnName(column)).getWidth(), (int)jtext.getPreferredSize().getHeight()); jtext.setMargin(new Insets(10,5,10,5)); return jtext; }
Example 6
Source File: MenuFileParser.java From ontopia with Apache License 2.0 | 5 votes |
public WarningBox(String warning) { // Create the warning panel to hold all the other components. JPanel warningPanel = new JPanel(); // Lay out the components vertically. warningPanel.setLayout(new BoxLayout(warningPanel, BoxLayout.Y_AXIS)); warningPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory .createEtchedBorder(), Messages.getString("Viz.Warning"))); // Create the warning message. JTextArea warningTextArea = new JTextArea(warning); warningTextArea.setLineWrap(true); warningTextArea.setWrapStyleWord(true); warningTextArea.setEditable(false); warningTextArea.setFont(warningTextArea.getFont().deriveFont(13f)); warningTextArea.setBackground(warningPanel.getBackground()); warningPanel.add(warningTextArea); // Will listen for and act upon changes to the OK button. ActionListener okListener = new ActionListener() { @Override public void actionPerformed(ActionEvent action) { setVisible(false); } }; // Create an Ok button. JButton okButton = new JButton( Messages.getString("Viz.OK")); okButton.addActionListener(okListener); warningPanel.add(okButton); getContentPane().add(warningPanel); setSize(400, 150); }
Example 7
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 8
Source File: GeneralPropertiesProvider.java From visualvm with GNU General Public License v2.0 | 5 votes |
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 9
Source File: VerifyDialog.java From RipplePower with Apache License 2.0 | 5 votes |
public VerifyDialog(JDialog parent) { super(parent, "Verify Message", Dialog.ModalityType.DOCUMENT_MODAL); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); addressField = new JTextField("", 34); JPanel addressPane = new JPanel(); addressPane.add(new JLabel("Address ", JLabel.RIGHT)); addressPane.add(addressField); messageField = new JTextArea(6, 70); messageField.setLineWrap(true); messageField.setWrapStyleWord(true); messageField.setFont(addressField.getFont()); scrollPane = new JScrollPane(messageField); JPanel messagePane = new JPanel(); messagePane.add(new JLabel("Message ", JLabel.RIGHT)); messagePane.add(scrollPane); signatureField = new JTextField("", 70); JPanel signaturePane = new JPanel(); signaturePane.add(new JLabel("Signature ", JLabel.RIGHT)); signaturePane.add(signatureField); JPanel buttonPane = new ButtonPane(this, 10, new String[] { "Verify", "verify" }, new String[] { "Done", "done" }); JPanel contentPane = new JPanel(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); contentPane.setOpaque(true); contentPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); contentPane.add(addressPane); contentPane.add(Box.createVerticalStrut(15)); contentPane.add(messagePane); contentPane.add(Box.createVerticalStrut(15)); contentPane.add(signaturePane); contentPane.add(Box.createVerticalStrut(15)); contentPane.add(buttonPane); setContentPane(contentPane); }
Example 10
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 11
Source File: AboutDialog.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Creates a panel showing the licence. * * @return a panel. */ private JPanel createLicencePanel() { final JPanel licencePanel = new JPanel(new BorderLayout()); final JTextArea area = new JTextArea(this.licence); area.setLineWrap(true); area.setWrapStyleWord(true); area.setCaretPosition(0); area.setEditable(false); licencePanel.add(new JScrollPane(area)); return licencePanel; }
Example 12
Source File: ModulesInstaller.java From visualvm with GNU General Public License v2.0 | 5 votes |
private JComponent getErrorNotifyPanel (Exception x) { JTextArea area = new JTextArea (); area.setWrapStyleWord (true); area.setLineWrap (true); area.setEditable (false); area.setRows (15); area.setColumns (40); area.setOpaque (false); area.setText (getBundle ("InstallerMissingModules_ErrorPanel", x.getLocalizedMessage (), x)); return area; }
Example 13
Source File: PrintLatinCJKTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void showFrame() { JFrame f = new JFrame(); JTextArea jta = new JTextArea(info, 4, 30); jta.setLineWrap(true); jta.setWrapStyleWord(true); f.add("Center", jta); JButton b = new JButton("Print"); b.addActionListener(testInstance); f.add("South", b); f.pack(); f.setVisible(true); }
Example 14
Source File: SharedFunctions.java From zap-extensions with Apache License 2.0 | 5 votes |
public static JTextArea createTextArea(int rows, int cols, String tip, int limit) { JTextArea txt = new JTextArea(rows, cols); if (limit > -1) { txt.setDocument(new JTextFieldLimit(limit)); } txt.setToolTipText(tip); txt.setLineWrap(true); txt.setWrapStyleWord(true); return txt; }
Example 15
Source File: MultiLineLabel.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
public MultiLineLabel(String text, int margin) { JTextArea label = new JTextArea(text); label.setLineWrap(true); label.setWrapStyleWord(true); label.setEditable(false); if (margin > 0) GUIUtils.addMargin(label, margin); setViewportView(label); }
Example 16
Source File: ConversionChoiceDialog.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
/** * Initialises the user interface. */ private void initComponents() { setLayout(new GridBagLayout()); JTextArea introLabel = new JTextArea(introText, 5, 40); introLabel.setEditable(false); introLabel.setWrapStyleWord(true); introLabel.setLineWrap(true); GridBagConstraints gbc = new GridBagConstraints(); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 1.0); gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(10, 10, 5, 10); add(introLabel, gbc); choiceCombo = new JComboBox<>(); for (String choice : choices) { choiceCombo.addItem(choice); } if (defaultChoice >= 0 && defaultChoice < choices.size()) { choiceCombo.setSelectedIndex(defaultChoice); } Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); gbc.insets = new Insets(5, 10, 5, 10); add(choiceCombo, gbc); JLabel dummy = new JLabel(" "); Utility.buildRelativeConstraints(gbc, 1, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); add(dummy, gbc); JButton okButton = new JButton(LanguageBundle.getString("in_ok")); okButton.addActionListener(this); getRootPane().setDefaultButton(okButton); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); gbc.insets = new Insets(5, 5, 10, 10); add(okButton, gbc); pack(); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { result = choiceCombo.getSelectedIndex(); setVisible(false); logChoice(); } }); }
Example 17
Source File: DFDSNamePanel.java From ramus with GNU General Public License v3.0 | 4 votes |
/** * 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 18
Source File: TextualDocumentView.java From gate-core with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void initGUI() { // textView = new JEditorPane(); // textView.setContentType("text/plain"); // textView.setEditorKit(new RawEditorKit()); textView = new JTextArea(); textView.setAutoscrolls(false); textView.setLineWrap(true); textView.setWrapStyleWord(true); // the selection is hidden when the focus is lost for some system // like Linux, so we make sure it stays // it is needed when doing a selection in the search textfield textView.setCaret(new PermanentSelectionCaret()); scroller = new JScrollPane(textView); textView.setText(document.getContent().toString()); textView.getDocument().addDocumentListener(swingDocListener); // display and put the caret at the beginning of the file SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { if(textView.modelToView(0) != null) { textView.scrollRectToVisible(textView.modelToView(0)); } textView.select(0, 0); textView.requestFocus(); } catch(BadLocationException e) { e.printStackTrace(); } } }); // contentPane = new JPanel(new BorderLayout()); // contentPane.add(scroller, BorderLayout.CENTER); // //get a pointer to the annotation list view used to display // //the highlighted annotations // Iterator horizViewsIter = owner.getHorizontalViews().iterator(); // while(annotationListView == null && horizViewsIter.hasNext()){ // DocumentView aView = (DocumentView)horizViewsIter.next(); // if(aView instanceof AnnotationListView) // annotationListView = (AnnotationListView)aView; // } highlightsMinder = new Timer(BLINK_DELAY, new UpdateHighlightsAction()); highlightsMinder.setInitialDelay(HIGHLIGHT_DELAY); highlightsMinder.setDelay(BLINK_DELAY); highlightsMinder.setRepeats(true); highlightsMinder.setCoalesce(true); highlightsMinder.start(); // blinker = new Timer(this.getClass().getCanonicalName() + // "_blink_timer", // true); // final BlinkAction blinkAction = new BlinkAction(); // blinker.scheduleAtFixedRate(new TimerTask(){ // public void run() { // blinkAction.actionPerformed(null); // } // }, 0, BLINK_DELAY); initListeners(); }
Example 19
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 20
Source File: JUtils.java From CQL with GNU Affero General Public License v3.0 | 3 votes |
/** * Creates a new JTextArea, sets various useful properties for using it, and * sticks it in a JScrollPane (so that it will scroll), which is then returned. * The JTextArea is accessible via * <code>scrollpane.getViewport().getMModel()</code>, or you can use * JUtils.taText(JScrollPane) to get the text. * * @param initial the initial text * @param row * @param cols the number of cols (@see javax.swing.JTextArea) * @return a JScrollPane containing the created JTextArea */ public static JScrollPane textArea(String initial, int row, int cols) { JTextArea ta = new JTextArea(initial, row, cols); ta.setLineWrap(true); ta.setWrapStyleWord(true); ta.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); return new JScrollPane(ta); }