List of usage examples for javax.swing JTextArea setText
@BeanProperty(bound = false, description = "the text of this component") public void setText(String t)
TextComponent
to the specified text. From source file:algorithm.QRCodeWatermarking.java
/** * Creates the GUI that is used to configure this algorithm. *//*from w ww .j av a 2 s . c o m*/ private void createConfigurationGui() { initButtons(); panel = new GUIPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.gridwidth = 2; panel.add(new JLabel("<html><h2>QR-code options</h2></html>"), constraints); constraints.gridy++; constraints.gridwidth = 1; panel.add(new JLabel("QR-code size: "), constraints); constraints.gridx++; sizeField.setText("200"); panel.add(sizeField, constraints); constraints.gridwidth = 2; constraints.gridx = 0; constraints.gridy++; constraints.gridy++; constraints.gridx = 0; constraints.gridwidth = 1; panel.add(new JLabel("Select output file format:"), constraints); constraints.gridx++; panel.add(imageFormatBox, constraints); constraints.gridx = 0; constraints.gridy++; // separate file: constraints.gridwidth = 2; panel.add(falseEncapsulate, constraints); constraints.gridy++; constraints.gridy++; // add to carrier: panel.add(trueEncapsulate, constraints); constraints.gridy++; JTextArea infoArea = new JTextArea(); infoArea.setText("" + "\nPlease note: " + "\n- The QR-code will be created from the first payload file, if the dataset has more than one payload files, and added to each carrier file. " + "All other payload files will be ignored, if this option is selected." + "\n- Carrier files need to be one of the following file types:" + "\n\tpng, jpeg, jp2, jpg, bmp, gif" + "\n- All carrier files of other file formats are ignored." + "\n- The QR-code pixel size should exceed the carrier image size in no dimension." + "\n- If the size of the selected payload file is too big to create a QR-code from it, you will get an error message." + "\n\n" + "Options for adding the QR-code to the carrier images:"); infoArea.setEditable(false); infoArea.setLineWrap(true); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 1; panel.add(infoArea, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridy++; panel.add(new JLabel("On which image position should the barcode be added?"), constraints); constraints.gridy++; constraints.gridwidth = 1; panel.add(new JLabel("X :"), constraints); constraints.gridx++; xPositionField.setText("0"); panel.add(xPositionField, constraints); constraints.gridx = 0; constraints.gridy++; panel.add(new JLabel("Y :"), constraints); constraints.gridx++; yPositionField.setText("0"); panel.add(yPositionField, constraints); constraints.gridx = 0; constraints.gridy++; constraints.gridy++; panel.add(messageLabel, constraints); }
From source file:hermes.renderers.DefaultMessageRenderer.java
/** * Render the message, delegates to typed methods. *///from w w w . j a v a2 s .co m @Override public JComponent render(JScrollPane parent, final Message m) { try { if (getPanelMap().containsKey(m)) { return (JComponent) getPanelMap().get(m); } JComponent rval = null; if (m instanceof TextMessage) { rval = handleTextMessage((TextMessage) m); } else if (m instanceof javax.jms.ObjectMessage) { rval = handleObjectMessage((ObjectMessage) m); } else if (m instanceof javax.jms.MapMessage) { rval = handleMapMessage((MapMessage) m); } else if (m instanceof BytesMessage) { rval = handleBytesMessage(parent, (BytesMessage) m); } else if (m instanceof StreamMessage) { rval = handleStreamMessage((StreamMessage) m); } else { JTextArea textPane = new JTextArea(); textPane.setEditable(false); textPane.setText("Message has no Payload"); rval = textPane; } getPanelMap().put(m, rval); return rval; } catch (Throwable ex) { final JTextArea textPane = new JTextArea(); textPane.setEditable(false); final StringWriter string = new StringWriter(); final PrintWriter writer = new PrintWriter(string); ex.printStackTrace(writer); writer.flush(); textPane.setText("Unable to display message:\n" + string.toString()); log.error(ex.getMessage(), ex); return textPane; } }
From source file:testFileHandler.java
public void decrypt(String encryptedText, String secretKey, javax.swing.JTextArea plainTextField) throws Exception { byte[] message = Base64.decodeBase64(encryptedText.getBytes("utf-8")); MessageDigest md = MessageDigest.getInstance("SHA-1"); byte[] digestOfPassword = md.digest(secretKey.getBytes("utf-8")); byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24); SecretKey key = new SecretKeySpec(keyBytes, "DESede"); Cipher decipher = Cipher.getInstance("DESede"); decipher.init(Cipher.DECRYPT_MODE, key); byte[] plainText = decipher.doFinal(message); plainTextField.setText(new String(plainText, "UTF-8")); }
From source file:gui.QTLResultsPanel.java
private void setTrait_simple(Trait trait, JTextArea ta) { if (trait == null || trait.qtlEffects == null) { ta.setText(""); return;/*from w w w.j ava2 s. c o m*/ } StringBuffer text = new StringBuffer(1000); text.append("Model sig lod R2 mean_1 se_1 mean_2 se_2\n"); for (int i = 0; i < 10; i++) { String line = (i + 1) + " " + getModel(i + 1); while (line.length() < 15) { line += " "; } for (int j = 0; j < 7; j++) { if (j <= 5) { if (trait.modelScores[i][j] >= 0) { line += " "; } line += Prefs.d3.format(trait.modelScores[i][j]); } else if (trait.modelScoresExtra != null) { if (trait.modelScoresExtra[i][0] >= 0) { line += " "; } line += Prefs.d3.format(trait.modelScoresExtra[i][0]); } else { line += "N/A"; } while (line.length() < 15 + (j + 1) * 8) { line += " "; } } text.append(line + "\n"); } ta.setText(text.toString()); }
From source file:coreferenceresolver.gui.MarkupGUI.java
private JScrollPane newReviewPanel(Review review, int reviewId) throws BadLocationException { //Model/*from w ww .jav a 2 s . c o m*/ ReviewElement reviewElement = new ReviewElement(); ScrollablePanel reviewPanel = new ScrollablePanel(); reviewPanel.setLayout(new BoxLayout(reviewPanel, BoxLayout.PAGE_AXIS)); JTextField title = new JTextField("NEW REVIEW " + reviewId); title.setBackground(Color.pink); reviewPanel.add(title); JTextArea reviewContentTxtArea = new JTextArea(); reviewContentTxtArea.setLineWrap(true); reviewContentTxtArea.setWrapStyleWord(true); reviewContentTxtArea.setEditable(false); reviewContentTxtArea.setText(review.getRawContent()); int chainId = 0; for (CorefChain cc : review.getCorefChains()) { for (int npId : cc.getChain()) { NounPhrase np = review.getNounPhrases().get(npId); Object highlighTag = reviewContentTxtArea.getHighlighter().addHighlight(np.getOffsetBegin(), np.getOffsetEnd() + 1, highlightPainters.get(chainId)); this.markupReviews.get(reviewId).getNounPhrases().get(npId).highlighterTag = highlighTag; } ++chainId; } reviewPanel.add(reviewContentTxtArea); ScrollablePanel markupsPanel = new ScrollablePanel(); markupsPanel.setLayout(new BoxLayout(markupsPanel, BoxLayout.PAGE_AXIS)); for (int i = 0; i < review.getNounPhrases().size(); ++i) { JScrollPane newMarkupPanel = newMarkupPanel(review.getNounPhrases().get(i), reviewElement); markupsPanel.add(newMarkupPanel); } JScrollPane scrollMarkupsPanel = new JScrollPane(markupsPanel); //Add Dimension for scrolling Dimension curScreenDimen = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); scrollMarkupsPanel.setPreferredSize(new Dimension((int) curScreenDimen.getWidth() - 50, 400)); reviewPanel.add(scrollMarkupsPanel); //MODEL reviewElement.reviewTextArea = reviewContentTxtArea; reviewElements.add(reviewElement); reviewPanel.add(new JSeparator(SwingConstants.HORIZONTAL)); reviewPanel.add(Box.createVerticalStrut(20)); JScrollPane scrollReviewPanel = new JScrollPane(reviewPanel); return scrollReviewPanel; }
From source file:edu.ku.brc.specify.tasks.subpane.LabelsPane.java
private void showErrorMsgs() { CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "f:p:g")); JTextArea ta = createTextArea(40, 80); pb.add(createScrollPane(ta, true), cc.xy(1, 1)); pb.setDefaultDialogBorder();// w w w .jav a2s .c o m ta.setText(errThrowable != null ? getStackTrace(errThrowable) : ""); ta.setEditable(false); CustomDialog dlg = new CustomDialog((Frame) getMostRecentWindow(), getResourceString("Error"), true, CustomDialog.OK_BTN, pb.getPanel()); dlg.setOkLabel(getResourceString("CLOSE")); centerAndShow(dlg); }
From source file:com.limegroup.gnutella.gui.LicenseWindow.java
/** * Builds a new JTextArea with the appropriate values set. *///from w w w. ja v a2 s .c o m private JTextArea newTextArea(String msg) { JTextArea text = new JTextArea(); text.setLineWrap(true); text.setWrapStyleWord(true); text.setEditable(false); text.setFont(UIManager.getFont("Table.font")); JLabel label = new JLabel(); text.setForeground(label.getForeground()); text.setBackground(label.getBackground()); text.setText(msg); return text; }
From source file:testFileHandler.java
public void encrypt(String message, String secretKey, javax.swing.JTextArea ciphertextField) throws Exception { MessageDigest md = MessageDigest.getInstance("SHA-1"); byte[] digestOfPassword = md.digest(secretKey.getBytes("utf-8")); byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24); SecretKey key = new SecretKeySpec(keyBytes, "DESede"); Cipher cipher = Cipher.getInstance("DESede"); cipher.init(Cipher.ENCRYPT_MODE, key); // Encode the string into bytes using utf-8 byte[] plainTextBytes = message.getBytes("utf-8"); // Encrypt// ww w.j a v a 2s . co m byte[] buf = cipher.doFinal(plainTextBytes); // Encode bytes to base64 to get a string byte[] base64Bytes = Base64.encodeBase64(buf); String base64EncryptedString = new String(base64Bytes); ciphertextField.setText(base64EncryptedString); }
From source file:edu.ku.brc.specify.plugins.ipadexporter.InstitutionConfigDlg.java
/** * @return//from w w w . j a v a 2s.co m */ private JPanel createPicturePanel() { AppPreferences remotePrefs = AppPreferences.getRemote(); String picturelocation = remotePrefs.get(getRemotePicturePrefName(), ""); JTextArea explainTextArea = UIHelper.createTextArea(); explainTextArea.setEditable(false); explainTextArea.setText(getResourceString("PICTURE_EXPLAIN")); explainTextArea.setOpaque(false); final String thumbnailPicMsg = getResourceString("THUMBNAIL_PIC"); imageView = new ImageDisplay(200, 200, true, true); imageView.setThumbnailMsg(thumbnailPicMsg); if (StringUtils.isNotEmpty(picturelocation)) { String fullPath = UIRegistry.getAppDataDir() + File.separator + picturelocation; File urlFile = new File(fullPath); if (urlFile.exists()) { imageView.setValue(urlFile.toURI().toASCIIString(), null); } } JButton clearBtn = UIHelper.createI18NButton("CLEAR_PICTURE"); clearBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { imageView.setValue(null, null); imageView.setThumbnailMsg(thumbnailPicMsg); imageView.repaint(); } }); CellConstraints cc = new CellConstraints(); PanelBuilder epb = new PanelBuilder(new FormLayout("f:p:g", "top:p:g,4px,p")); epb.add(explainTextArea, cc.xy(1, 1)); PanelBuilder bpb = new PanelBuilder(new FormLayout("p", "f:p:g,p")); bpb.add(clearBtn, cc.xy(1, 2)); epb.add(bpb.getPanel(), cc.xy(1, 3)); PanelBuilder pb = new PanelBuilder(new FormLayout("p,8px,f:p:g", "f:p:g")); pb.add(imageView, cc.xy(1, 1)); pb.add(epb.getPanel(), cc.xy(3, 1)); return pb.getPanel(); }
From source file:PostTest.java
public PostTestFrame() { setTitle("PostTest"); northPanel = new JPanel(); add(northPanel, BorderLayout.NORTH); northPanel.setLayout(new GridLayout(0, 2)); northPanel.add(new JLabel("Host: ", SwingConstants.TRAILING)); final JTextField hostField = new JTextField(); northPanel.add(hostField);/*from w ww.j a v a 2 s . c o m*/ northPanel.add(new JLabel("Action: ", SwingConstants.TRAILING)); final JTextField actionField = new JTextField(); northPanel.add(actionField); for (int i = 1; i <= 8; i++) northPanel.add(new JTextField()); final JTextArea result = new JTextArea(20, 40); add(new JScrollPane(result)); JPanel southPanel = new JPanel(); add(southPanel, BorderLayout.SOUTH); JButton addButton = new JButton("More"); southPanel.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { northPanel.add(new JTextField()); northPanel.add(new JTextField()); pack(); } }); JButton getButton = new JButton("Get"); southPanel.add(getButton); getButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { result.setText(""); final Map<String, String> post = new HashMap<String, String>(); for (int i = 4; i < northPanel.getComponentCount(); i += 2) { String name = ((JTextField) northPanel.getComponent(i)).getText(); if (name.length() > 0) { String value = ((JTextField) northPanel.getComponent(i + 1)).getText(); post.put(name, value); } } new SwingWorker<Void, Void>() { protected Void doInBackground() throws Exception { try { String urlString = hostField.getText() + "/" + actionField.getText(); result.setText(doPost(urlString, post)); } catch (IOException e) { result.setText("" + e); } return null; } }.execute(); } }); pack(); }