List of usage examples for javax.swing JTextArea setEditable
@BeanProperty(description = "specifies if the text can be edited") public void setEditable(boolean b)
TextComponent
should be editable. From source file:com.ethercamp.harmony.desktop.HarmonyDesktop.java
private void showErrorWindow(String title, String body) { try {/*w w w . j a v a 2 s . c om*/ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // System.setProperty("apple.awt.UIElement", "false"); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JTextArea textArea = new JTextArea(body); JScrollPane scrollPane = new JScrollPane(textArea); textArea.setLineWrap(true); textArea.setFont(Font.getFont(Font.MONOSPACED)); textArea.setEditable(false); textArea.setWrapStyleWord(true); scrollPane.setPreferredSize(new Dimension(500, 500)); JTextPane titleLabel = new JTextPane(); titleLabel.setContentType("text/html"); // let the text pane know this is what you want titleLabel.setText("<html>" + "<b>" + title + "</b>" + "</html>"); // showing off titleLabel.setEditable(false); titleLabel.setBackground(null); titleLabel.setBorder(null); panel.add(titleLabel); panel.add(scrollPane); final JFrame frame = new JFrame(); frame.setAlwaysOnTop(true); moveCenter(frame); frame.setVisible(true); JOptionPane.showMessageDialog(frame, panel, "Oops. Ethereum Harmony stopped with error.", JOptionPane.CLOSED_OPTION); System.exit(1); } catch (Exception e) { log.error("Problem showing error window", e); } }
From source file:hermes.browser.actions.AbstractFIXBrowserDocumentComponent.java
protected Component createPrettyPrintPanel(FIXMessage m) { final JTextArea textArea = new JTextArea(); textArea.setEditable(false); textArea.setFont(Font.decode("Monospaced-PLAIN-12")); byte[] bytes = null; try {//from w w w .j a v a 2 s .c om textArea.setText(FIXUtils.prettyPrint(m)); } catch (Throwable e) { textArea.setText(e.getMessage()); log.error("exception converting message to byte[]: ", e); } textArea.setCaretPosition(0); return SwingUtils.createJScrollPane(textArea); }
From source file:hermes.browser.actions.AbstractFIXBrowserDocumentComponent.java
protected Component createHexPanel(FIXMessage m) { final JTextArea textArea = new JTextArea(); textArea.setEditable(false); textArea.setFont(Font.decode("Monospaced-PLAIN-12")); byte[] bytes = null; try {/* ww w. jav a2s. c o m*/ textArea.setText(DumpUtils.dumpBinary(m.getBytes(), DumpUtils.DUMP_AS_HEX_AND_ALPHA)); } catch (Throwable e) { textArea.setText(e.getMessage()); log.error("exception converting message to byte[]: ", e); } textArea.setCaretPosition(0); final JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(textArea); return scrollPane; }
From source file:edu.ku.brc.specify.ui.AppBase.java
/** * Creates a ScrollPane with the text from the log file. * @param logFile the file/*from w w w. j av a2s . c om*/ * @param doError indicates it should display the error log * @return the ScrollPane. */ protected static JScrollPane getLogFilePanel(final File logFile, final boolean doError) { JTextArea textArea = new JTextArea(); if (logFile.exists()) { try { textArea.setText(FileUtils.readFileToString(logFile)); } catch (Exception ex) { } // no catch on purpose } else { textArea.setText( doError ? getResourceString("Specify.LOG_NO_ERRORS") : getResourceString("Specify.LOG_EMPTY")); //$NON-NLS-1$ //$NON-NLS-2$ } textArea.setEditable(false); return new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); }
From source file:hermes.browser.actions.AbstractFIXBrowserDocumentComponent.java
/** * When a user selects a row, bring up the messages in the below panel. Uses * the MessengerRenderer's that have been configured with the first one * returning a panel being the one used. *//*from ww w . jav a 2s.c o m*/ public void doSelectionChanged(FIXMessageTable table, ListSelectionEvent e) { int selectedRow = table.getSelectedRow(); if (table.getRowCount() > selectedRow && selectedRow >= 0) { final int row = selectedRow; final FIXMessage m = table.getMessageAt(row); // // // // Keep the selected row visible. // // table.scrollRectToVisible(table.getCellRect(selectedRow, 0, true)); try { if (!renderedLRUMap.containsKey(m)) { JComponent rendered = FIXUtils.createView(m, true, true); renderedLRUMap.put(m, rendered); } getMessagePayloadPanel().setViewportView(renderedLRUMap.get(m)); } catch (Exception e1) { log.error(e1.getMessage(), e1); JTextArea text = new JTextArea(e1.getMessage()); text.setEditable(false); getMessagePayloadPanel().setViewportView(text); } updateMessageTabbedPane(m); } }
From source file:fll.scheduler.ChooseChallengeDescriptor.java
private void initComponents() { getContentPane().setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1;/*from www . j a va 2 s . com*/ gbc.weighty = 1; gbc.fill = GridBagConstraints.BOTH; final JTextArea instructions = new JTextArea( "Choose a challenge description from the drop down list OR choose a file containing your custom challenge description.", 3, 40); instructions.setEditable(false); instructions.setWrapStyleWord(true); instructions.setLineWrap(true); getContentPane().add(instructions, gbc); gbc = new GridBagConstraints(); mCombo = new JComboBox<DescriptionInfo>(); gbc.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(mCombo, gbc); mCombo.setRenderer(new DescriptionInfoRenderer()); mCombo.setEditable(false); final List<DescriptionInfo> descriptions = DescriptionInfo.getAllKnownChallengeDescriptionInfo(); for (final DescriptionInfo info : descriptions) { mCombo.addItem(info); } mFileField = new JLabel(); gbc = new GridBagConstraints(); gbc.weightx = 1; getContentPane().add(mFileField, gbc); final JButton chooseButton = new JButton("Choose File"); gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(chooseButton, gbc); chooseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent ae) { mFileField.setText(null); final JFileChooser fileChooser = new JFileChooser(); final FileFilter filter = new BasicFileFilter("FLL Description (xml)", new String[] { "xml" }); fileChooser.setFileFilter(filter); final int returnVal = fileChooser.showOpenDialog(ChooseChallengeDescriptor.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final File selectedFile = fileChooser.getSelectedFile(); mFileField.setText(selectedFile.getAbsolutePath()); } } }); final Box buttonPanel = new Box(BoxLayout.X_AXIS); gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(buttonPanel, gbc); buttonPanel.add(Box.createHorizontalGlue()); final JButton ok = new JButton("Ok"); buttonPanel.add(ok); ok.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent ae) { // use the selected description if nothing is entered in the file box final DescriptionInfo descriptionInfo = mCombo.getItemAt(mCombo.getSelectedIndex()); if (null != descriptionInfo) { mSelected = descriptionInfo.getURL(); } final String text = mFileField.getText(); if (!StringUtils.isEmpty(text)) { final File file = new File(text); if (file.exists()) { try { mSelected = file.toURI().toURL(); } catch (final MalformedURLException e) { throw new FLLInternalException("Can't turn file into URL?", e); } } } setVisible(false); } }); final JButton cancel = new JButton("Cancel"); buttonPanel.add(cancel); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent ae) { mSelected = null; setVisible(false); } }); pack(); }
From source file:medsavant.uhn.cancer.UserCommentApp.java
private JPanel getCommentPanel(UserComment lc) { JTextArea commentText = new JTextArea(); commentText.setText(lc.getCommentText()); commentText.setEditable(false); commentText.setLineWrap(true);//w w w. j a va 2s . c om commentText.setPreferredSize(new Dimension(COMMENTTEXT_PREFERRED_WIDTH, COMMENTTEXT_PREFERRED_HEIGHT)); JScrollPane jsp = new JScrollPane(commentText); JPanel outerCommentPanel = new JPanel(); outerCommentPanel.setLayout(new BoxLayout(outerCommentPanel, BoxLayout.X_AXIS)); outerCommentPanel.add(jsp); outerCommentPanel.add(Box.createHorizontalGlue()); return outerCommentPanel; }
From source file:net.aepik.alasca.gui.util.LoadFileFrame.java
/** * Initialize frame content.// w w w . j av a2 s . c o m */ private void initFrame() { // - Panel bouton du bas - JPanel boutonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); boutonsPanel.add(boutonOk); boutonsPanel.add(boutonAnnuler); // - Panel nom du fichier - JTextArea textAreaFilename = new JTextArea( "Indiquez le nom du fichier contenant les dfinitions du schma LDAP que vous souhaitez charger."); textAreaFilename.setEditable(false); textAreaFilename.setLineWrap(true); textAreaFilename.setWrapStyleWord(true); textAreaFilename.setFont((new JLabel()).getFont()); textAreaFilename.setBorder(BorderFactory.createEmptyBorder(7, 6, 12, 6)); textAreaFilename.setBackground(new Color(240, 235, 226)); boutonOpenFile.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 5, 0, 0, boutonsPanel.getBackground()), boutonOpenFile.getBorder())); JPanel filenamePanel = new JPanel(new BorderLayout()); filenamePanel.add(textAreaFilename, BorderLayout.NORTH); filenamePanel.add(filename, BorderLayout.CENTER); filenamePanel.add(boutonOpenFile, BorderLayout.EAST); filenamePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 4, 1, 4), BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Schma LDAP "), BorderFactory.createEmptyBorder(0, 5, 5, 5)))); // - Panel du selecteur de syntaxes - JTextArea textAreaSyntaxes = new JTextArea( "Il vous faut appliquer un filtre sur le schma que vous voulez charger. Voici la liste des filtres disponibles :"); textAreaSyntaxes.setEditable(false); textAreaSyntaxes.setLineWrap(true); textAreaSyntaxes.setWrapStyleWord(true); textAreaSyntaxes.setFont((new JLabel()).getFont()); textAreaSyntaxes.setBorder(BorderFactory.createEmptyBorder(7, 6, 12, 6)); textAreaSyntaxes.setBackground(new Color(240, 235, 226)); JPanel syntaxesPanel = new JPanel(new BorderLayout()); syntaxesPanel.add(textAreaSyntaxes, BorderLayout.NORTH); syntaxesPanel.add(syntaxes); syntaxesPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 4, 1, 4), BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Syntaxe LDAP "), BorderFactory.createEmptyBorder(0, 5, 5, 5)))); // On injecte le nom des classes de syntaxes possibles // dynamiquement. String[] syntaxesName = Schema.getSyntaxeNames(); for (int i = 0; syntaxesName != null && i < syntaxesName.length; i++) { syntaxes.addItem(syntaxesName[i]); } // - Organisation gnrale - JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(filenamePanel, BorderLayout.NORTH); mainPanel.add(syntaxesPanel, BorderLayout.CENTER); JPanel mainPanelContainer = new JPanel(new BorderLayout()); mainPanelContainer.add(mainPanel, BorderLayout.NORTH); mainPanelContainer.add(boutonsPanel, BorderLayout.SOUTH); mainPanelContainer.setBorder(BorderFactory.createEmptyBorder(2, 1, 1, 1)); getContentPane().add(new DescriptiveInternalFrame(mainFrame.getIconImage(), "Slectionner un fichier et sa syntaxe.", mainPanelContainer)); // - Listeners - addWindowListener(this); boutonOpenFile.addActionListener(this); boutonOk.addActionListener(this); boutonAnnuler.addActionListener(this); }
From source file:coreferenceresolver.gui.MarkupGUI.java
private JScrollPane newMarkupPanel(NounPhrase np, ReviewElement reviewElement) { //MODEL/*from w w w.j a va 2s. co m*/ Element element = new Element(); //Newly added ScrollablePanel markupPanel = new ScrollablePanel(); markupPanel.setLayout(new BoxLayout(markupPanel, BoxLayout.X_AXIS)); markupPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT); JTextArea npContentTxtArea = new JTextArea(); npContentTxtArea.setEditable(false); npContentTxtArea.setText(((MarkupNounPhrase) np).content); markupPanel.add(npContentTxtArea); //REF SpinnerModel refSpinnerModel = new SpinnerNumberModel(np.getChainId(), -1, COLORS.length - 1, 1); JSpinner refSpinner = new JSpinner(refSpinnerModel); refSpinner.setValue(np.getChainId()); refSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { np.setChainId((int) refSpinner.getValue()); try { rePaint(reviewElements.get(np.getReviewId()), np); } catch (BadLocationException ex) { Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex); } } }); element.refSpinner = refSpinner; //TYPE String[] typeValues = { "Object", "Other", "Candidate", "Attribute" }; SpinnerModel typeSpinnerModel = new SpinnerListModel(typeValues); JSpinner typeSpinner = new JSpinner(typeSpinnerModel); typeSpinner.setValue(typeValues[np.getType()]); element.typeSpinner = typeSpinner; //REF + TYPE ScrollablePanel spinners = new ScrollablePanel(); spinners.setLayout(new BoxLayout(spinners, BoxLayout.X_AXIS)); spinners.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT); spinners.add(refSpinner); spinners.add(typeSpinner); markupPanel.add(spinners); reviewElement.addElement(element); JScrollPane scrollMarkupPanel = new JScrollPane(markupPanel); return scrollMarkupPanel; }
From source file:hermes.renderers.DefaultMessageRenderer.java
/** * Show a BytesMessage either as a java object or just a size. * /* w w w. j ava2 s .co m*/ * @param parent * * @param bytesMessage * @return * @throws JMSException * @throws IOException * @throws ClassNotFoundException */ protected JComponent handleBytesMessage(JScrollPane parent, BytesMessage bytesMessage) throws JMSException, IOException, ClassNotFoundException { final MyConfig currentConfig = (MyConfig) getConfig(); JTextArea textPane = new MyTextArea(); textPane.setEditable(false); textPane.setWrapStyleWord(true); textPane.setLineWrap(true); bytesMessage.reset(); if (currentConfig.isBytesIsObject()) { final byte[] bytes = MessageUtils.asBytes(bytesMessage); final ByteArrayInputStream bistream = new ByteArrayInputStream(bytes); final ObjectInputStream oistream = new ObjectInputStream(bistream); final Object o = oistream.readObject(); textPane.setText(o.toString()); } else if (currentConfig.isBytesIsString()) { try { String text = new String(MessageUtils.asBytes(bytesMessage), currentConfig.getBytesEncoding()); textPane.setText(text); return textPane; } catch (JMSException e) { textPane.setText(e.getMessage()); } } else { HexMessageRenderer renderer = new HexMessageRenderer(); textPane = (JTextArea) renderer.render(parent, bytesMessage); // Hack. } textPane.setCaretPosition(0); return textPane; }