Java Code Examples for javax.swing.JTextArea#setText()
The following examples show how to use
javax.swing.JTextArea#setText() .
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: WebDriverConfigGui.java From jmeter-plugins-webdriver with Apache License 2.0 | 6 votes |
private JPanel createNoProxyPanel() { JPanel noProxyPanel = new VerticalPanel(); JLabel noProxyListLabel = new JLabel("No Proxy for:"); noProxyPanel.add(noProxyListLabel); noProxyList = new JTextArea(3, 10); noProxyList.setText(DEFAULT_NO_PROXY_LIST); noProxyList.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); noProxyList.setEnabled(false); noProxyPanel.add(noProxyList); JLabel noProxyExample = new JLabel("Example: .jmeter.org, .com.au, 192.168.1.0/24"); noProxyPanel.add(noProxyExample); return noProxyPanel; }
Example 2
Source File: Query.java From OpenDA with GNU Lesser General Public License v3.0 | 6 votes |
/** Set the displayed text of an entry that has been added using * addDisplay. * Notify listeners that the value has changed. * @param name The name of the entry. * @param value The string to display. * @exception NoSuchElementException If there is no entry with the * specified name. Note that this is a runtime exception, so it * need not be declared explicitly. * @exception IllegalArgumentException If the entry is not a * display. This is a runtime exception, so it * need not be declared explicitly. */ public void setDisplay(String name, String value) throws NoSuchElementException, IllegalArgumentException { Object result = _entries.get(name); if (result == null) { throw new NoSuchElementException( "No item named \"" + name + " \" in the query box."); } if (result instanceof JTextArea) { JTextArea label = (JTextArea) result; label.setText(value); } else { throw new IllegalArgumentException( "Item named \"" + name + "\" is not a display, and hence cannot be set using " + "setDisplay()."); } _notifyListeners(name); }
Example 3
Source File: ActionMappingsTest.java From netbeans with Apache License 2.0 | 6 votes |
@Test public void testSkipTestsAction() throws Exception { JTextArea area = new JTextArea(); area.setText(""); ActionMappings.SkipTestsAction act = new ActionMappings.SkipTestsAction(area); act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X")); assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true")); area.setText(TestChecker.PROP_SKIP_TEST + "=false"); act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X")); assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true")); area.setText(TestChecker.PROP_SKIP_TEST + " = false\nyyy=xxx"); act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X")); assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true")); area.setText("aaa=bbb\n" + TestChecker.PROP_SKIP_TEST + " = false \nyyy=xxx"); act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X")); assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true")); }
Example 4
Source File: JideTabbedPanePanel.java From marathonv5 with Apache License 2.0 | 6 votes |
private static JideTabbedPane createTabbedPane() { final JideTabbedPane tabbedPane = new JideTabbedPane(JideTabbedPane.TOP); tabbedPane.setOpaque(true); final String[] titles = new String[] { "Mail", "Calendar", "Contacts", "Tasks", "Notes", "Folder List", "Shortcuts", "Journal" }; for (int i = 0; i < titles.length; i++) { JTextArea jtextArea = new JTextArea(); jtextArea.setText("This is " + titles[i] + " tab"); JScrollPane scrollPane = new JScrollPane(jtextArea); scrollPane.setPreferredSize(new Dimension(530, 530)); tabbedPane.addTab(titles[i], scrollPane); } tabbedPane.setEnabledAt(2, false); return tabbedPane; }
Example 5
Source File: GUI.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Browse dir. * * @param f the f */ void browseDir(JTextArea f) { String startingDir = f.getText(); if (startingDir.length() == 0) { // default to user.dir startingDir = System.getProperty("user.dir"); } JFileChooser c = new JFileChooser(startingDir); c.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = c.showOpenDialog(gui); if (returnVal == JFileChooser.APPROVE_OPTION) { try { f.setText(c.getSelectedFile().getCanonicalPath()); Prefs.set(gui); } catch (Exception e) { // do nothing } } }
Example 6
Source File: MissingDragExitEventTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private static void initAndShowUI() { frame = new JFrame("Test frame"); frame.setSize(SIZE, SIZE); frame.setLocationRelativeTo(null); final JTextArea jta = new JTextArea(); jta.setBackground(Color.RED); frame.add(jta); jta.setText("1234567890"); jta.setFont(jta.getFont().deriveFont(150f)); jta.setDragEnabled(true); jta.selectAll(); jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY, new TestdropTargetListener())); jta.addMouseListener(new TestMouseAdapter()); frame.setVisible(true); }
Example 7
Source File: RunConfigurationFlagStateTest.java From intellij with Apache License 2.0 | 6 votes |
@Test public void testNestedQuotesRetainedAfterRoundTripSerialization() { RunConfigurationFlagsState state = new RunConfigurationFlagsState("tag", "field"); RunConfigurationStateEditor editor = state.getEditor(null); JTextArea textArea = getTextField(editor); String originalText = "--where_clause=\"op = 'addshardreplica' AND purpose = 'rebalancing'\""; textArea.setText(originalText); editor.applyEditorTo(state); assertThat(state.getRawFlags()).containsExactly(originalText); editor.resetEditorFrom(state); assertThat(textArea.getText()).isEqualTo(originalText); // test flags generated for commands assertThat(state.getFlagsForExternalProcesses()) .containsExactly("--where_clause=op = 'addshardreplica' AND purpose = 'rebalancing'"); }
Example 8
Source File: ConsoleStatusLoggerGui.java From jmeter-plugins with Apache License 2.0 | 6 votes |
private void init() { setLayout(new BorderLayout(0, 5)); setBorder(makeBorder()); add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), WIKIPAGE), BorderLayout.NORTH); JTextArea info = new JTextArea(); info.setEditable(false); info.setWrapStyleWord(true); info.setOpaque(false); info.setLineWrap(true); info.setColumns(20); JScrollPane jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1.setViewportView(info); jScrollPane1.setBorder(null); info.setText("This is a simple listener that prints short summary log to console while JMeter is running in non-GUI mode. " + "It also writes the same info into jmeter.log in GUI mode." + "\n\nNote that response time and latency values printed are averages."); add(jScrollPane1, BorderLayout.CENTER); }
Example 9
Source File: GltfViewerPanel.java From JglTF with MIT License | 5 votes |
/** * Create the viewer component using the given constructor. * * @param constructor The constructor. */ private void createViewer( Supplier<? extends GltfViewer<? extends Component>> constructor) { disposeGltfViewer(); animationsRunningButton.setSelected(false); animationsRunningButton.setEnabled(false); viewerComponentContainer.removeAll(); try { gltfViewer = constructor.get(); gltfViewer.setAnimationsRunning(false); gltfViewer.addGltfModel(gltfModel); Component renderComponent = gltfViewer.getRenderComponent(); externalCamera.setComponent(renderComponent); gltfViewer.setExternalCamera(externalCamera); viewerComponentContainer.add(renderComponent); animationsRunningButton.setEnabled(true); updateCameraModelsComboBox(); } catch (Throwable t) { // The constructor may throw everything. Particularly, when // the native library can not be found, it will throw an // UnsatisfiedLinkError (oh how we love it...). // All this is handled here, pragmatically... StringWriter stringWriter = new StringWriter(); t.printStackTrace(new PrintWriter(stringWriter)); JTextArea textArea = new JTextArea(); textArea.setFont(new Font("Monospaced", Font.PLAIN, 12)); textArea.setText( "Error while creating viewer:\n" + stringWriter.toString()); viewerComponentContainer.add(new JScrollPane(textArea)); } revalidate(); repaint(); }
Example 10
Source File: TooMuchWheelRotationEventsTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static JPanel createTestPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JTextArea textArea = new JTextArea(20, 20); textArea.setText(getLongString()); JScrollPane scrollPane = new JScrollPane(textArea); panel.add(scrollPane); return panel; }
Example 11
Source File: bug4337267.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void testTextComponent() { System.out.println("testTextComponent:"); JTextArea area1 = new JTextArea(); injectComponent(p1, area1, false); area1.setText(shaped); JTextArea area2 = new JTextArea(); injectComponent(p2, area2, true); area2.setText(text); window.repaint(); printq = new JComponent[] { area1, area2 }; SwingUtilities.invokeLater(printComponents); SwingUtilities.invokeLater(compareRasters); }
Example 12
Source File: MassageYesNo.java From JAVA-MVC-Swing-Monopoly with Apache License 2.0 | 5 votes |
private void addTextArea() { textArea = new JTextArea(); textArea.setText("���˸�ȥ����"); textArea.setBounds(18, 39, 230, 50); textArea.setSelectedTextColor(Color.BLUE); textArea.setOpaque(false); textArea.setEditable(false); textArea.setLineWrap(true); add(textArea); }
Example 13
Source File: MainFrame.java From procamtracker with GNU General Public License v2.0 | 5 votes |
private void readmeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_readmeMenuItemActionPerformed try { JTextArea textArea = new JTextArea(); Font font = textArea.getFont(); textArea.setFont(new Font("Monospaced", font.getStyle(), font.getSize())); textArea.setEditable(false); String text = ""; BufferedReader r = new BufferedReader(new FileReader( myDirectory + File.separator + "../README.md")); String line; while ((line = r.readLine()) != null) { text += line + '\n'; } textArea.setText(text); textArea.setCaretPosition(0); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setColumns(80); // stuff it in a scrollpane with a controlled size. JScrollPane scrollPane = new JScrollPane(textArea); Dimension dim = textArea.getPreferredSize(); dim.height = dim.width*50/80; scrollPane.setPreferredSize(dim); // pass the scrollpane to the joptionpane. JDialog dialog = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE). createDialog(this, "README"); dialog.setResizable(true); dialog.setModalityType(ModalityType.MODELESS); dialog.setVisible(true); } catch (Exception ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } }
Example 14
Source File: TooMuchWheelRotationEventsTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static JPanel createTestPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JTextArea textArea = new JTextArea(20, 20); textArea.setText(getLongString()); JScrollPane scrollPane = new JScrollPane(textArea); panel.add(scrollPane); return panel; }
Example 15
Source File: TestValuePanel.java From zap-extensions with Apache License 2.0 | 5 votes |
public TestValuePanel(RegexModel regexModel, Runnable onTestValueChanged) { super(new BorderLayout()); this.regexModel = regexModel; this.onTestValueChanged = onTestValueChanged; testValueField = new JTextArea(); testValueField.setFont(RegexDialog.monoFont); testValueField.setLineWrap(true); testValueField.setWrapStyleWord(true); testValueField.setText(regexModel.getTestValue()); testValueField.getDocument().addDocumentListener(documentListener); add(new JScrollPane(testValueField), BorderLayout.CENTER); setBorder(RegexDialog.createBorder(TEST_VALUE_HEADER)); }
Example 16
Source File: ShowCodeWindow.java From apkReSign with Apache License 2.0 | 4 votes |
public void init(){ setTitle("基础代码生成"); Container container = getContentPane(); jTextArea = new JTextArea(); JScrollPane scroll = new JScrollPane(jTextArea); jTextArea.setText("import com.robotium.solo.Solo;\n" + "import android.test.ActivityInstrumentationTestCase2;\n" + "import android.test.AndroidTestCase;\n" + "\n" + "/**\n" + " * Created by pengwei08 on 2015/7/5.\n" + " */\n" + "public class "+appName+" extends ActivityInstrumentationTestCase2 {\n" + " private static String mainActivity = \""+SplashActivity+"\";\n" + " private Solo solo;\n" + " private static Class<?> launchActivityClass;\n" + " static {\n" + " try {\n" + " launchActivityClass = Class.forName(mainActivity);\n" + " } catch (ClassNotFoundException e) {\n" + " e.printStackTrace();\n" + " }\n" + " }\n" + "\n" + " public "+appName+"() {\n" + " super(launchActivityClass);\n" + " }\n" + "\n" + " @Override\n" + " public void setUp() throws Exception {\n" + " super.setUp();\n" + " solo = new Solo(getInstrumentation(), getActivity());\n" + " }\n" + "\n" + " @Override\n" + " public void tearDown() throws Exception {\n" + " super.tearDown();\n" + " solo.finishOpenedActivities();\n" + " }\n" + "}\n"); container.add(scroll); setSize(800,500); setLocationRelativeTo(getRootPane()); }
Example 17
Source File: BrowserAddonDlg.java From xdm with GNU General Public License v2.0 | 4 votes |
private void initUI() { setUndecorated(true); try { if (GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) { if (!Config.getInstance().isNoTransparency()) { setOpacity(0.85f); } } } catch (Exception e) { Logger.log(e); } setIconImage(ImageResource.getImage("icon.png")); setSize(getScaledInt(400), getScaledInt(300)); setLocationRelativeTo(null); setAlwaysOnTop(true); getContentPane().setLayout(null); getContentPane().setBackground(ColorResource.getDarkestBgColor()); JPanel titlePanel = new TitlePanel(null, this); titlePanel.setOpaque(false); titlePanel.setBounds(0, 0, getScaledInt(400), getScaledInt(50)); JButton closeBtn = new CustomButton(); closeBtn.setBounds(getScaledInt(365), getScaledInt(5), getScaledInt(30), getScaledInt(30)); closeBtn.setBackground(ColorResource.getDarkestBgColor()); closeBtn.setBorderPainted(false); closeBtn.setFocusPainted(false); closeBtn.setName("CLOSE"); closeBtn.setIcon(ImageResource.getIcon("title_close.png", 20, 20)); closeBtn.addActionListener(this); titlePanel.add(closeBtn); JLabel titleLbl = new JLabel(StringResource.get("BROWSER_MONITORING")); titleLbl.setFont(FontResource.getBiggerFont()); titleLbl.setForeground(ColorResource.getSelectionColor()); titleLbl.setBounds(getScaledInt(25), getScaledInt(15), getScaledInt(200), getScaledInt(30)); titlePanel.add(titleLbl); JLabel lineLbl = new JLabel(); lineLbl.setBackground(ColorResource.getSelectionColor()); lineLbl.setBounds(0, getScaledInt(55), getScaledInt(400), 1); lineLbl.setOpaque(true); add(lineLbl); add(titlePanel); int y = getScaledInt(65); int h = getScaledInt(50); JTextArea lblMonitoringTitle = new JTextArea(); lblMonitoringTitle.setOpaque(false); lblMonitoringTitle.setWrapStyleWord(true); lblMonitoringTitle.setLineWrap(true); lblMonitoringTitle.setEditable(false); lblMonitoringTitle.setForeground(Color.WHITE); lblMonitoringTitle.setText(this.desc); lblMonitoringTitle.setFont(FontResource.getNormalFont()); lblMonitoringTitle.setBounds(getScaledInt(15), y, getScaledInt(370) - getScaledInt(30), h); add(lblMonitoringTitle); y += h; JButton btViewMonitoring = createButton1("CTX_COPY_URL", getScaledInt(15), y); btViewMonitoring.setName("COPY"); add(btViewMonitoring); y += btViewMonitoring.getHeight(); }
Example 18
Source File: DDChangesPanel.java From netbeans with Apache License 2.0 | 4 votes |
/** Initializes the Form */ public DDChangesPanel (String caption, final JButton processButton) { setLayout (new java.awt.BorderLayout (0, 12)); setBorder (new EmptyBorder (12, 12, 11, 0)); JTextArea text = new JTextArea (); text.setEnabled (false); text.setEditable (false); text.setDisabledTextColor (UIManager.getColor ("Label.foreground")); // NOI18N text.setBackground (UIManager.getColor ("Label.background")); // NOI18N text.setLineWrap (true); text.setWrapStyleWord (true); text.setText (caption); add (text, "North"); // NOI18N changesPanel = new JPanel (); changesPanel.setLayout (new java.awt.BorderLayout (5, 5)); JLabel changesLabel = new JLabel (); changesLabel.setText (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList")); changesLabel.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yDesc")); // NOI18N changesPanel.add (changesLabel, "North"); // NOI18N jScrollPane1 = new JScrollPane (); listModel = new DefaultListModel (); changesList = new JList (listModel); changesList.setToolTipText (NbBundle.getMessage (DDChangesPanel.class, "HINT_ChangesList")); changesList.setCellRenderer (new ChangesListCellRenderer ()); changesList.addListSelectionListener (new ListSelectionListener () { public void valueChanged (ListSelectionEvent e) { processButton.setEnabled (!changesList.isSelectionEmpty ()); } }); changesLabel.setLabelFor (changesList); changesLabel.setDisplayedMnemonic (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList_Mnemonic").charAt (0)); getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yPanelDesc")); jScrollPane1.setViewportView (changesList); changesPanel.add (jScrollPane1, "Center"); // NOI18N add (changesPanel, "Center"); // NOI18N }
Example 19
Source File: PropertySheetPage3.java From orbit-image-analysis with GNU General Public License v3.0 | 4 votes |
public PropertySheetPage3() { setLayout( LookAndFeelTweaks.createVerticalPercentLayout() ); JTextArea message = new JTextArea(); message.setText( PropertySheetMain.RESOURCE.getString( "Main.sheet1.message" ) ); LookAndFeelTweaks.makeMultilineLabel( message ); add( message ); final Colorful data = new Colorful(); data.setColor( new Color( 255, 153, 102 ) ); DefaultProperty level0 = new NoReadWriteProperty(); level0.setDisplayName("Level 0"); level0.setCategory("A category"); DefaultProperty level1 = new NoReadWriteProperty(); level1.setDisplayName("Level 1"); level1.setCategory("Another category"); level0.addSubProperty(level1); DefaultProperty level2 = new NoReadWriteProperty(); level2.setDisplayName("Level 2"); level1.addSubProperty(level2); DefaultProperty level21 = new NoReadWriteProperty(); level21.setDisplayName("Level 3"); level1.addSubProperty(level21); DefaultProperty level211 = new NoReadWriteProperty(); level211.setDisplayName("Level 3.1"); level21.addSubProperty(level211); DefaultProperty root = new NoReadWriteProperty(); root.setDisplayName("Root"); final PropertySheetPanel sheet = new PropertySheetPanel(); sheet.setMode( PropertySheet.VIEW_AS_FLAT_LIST ); sheet.setProperties( new Property[] { new ColorProperty(), level0, root } ); sheet.readFromObject( data ); sheet.setDescriptionVisible( true ); sheet.setSortingCategories( true ); sheet.setSortingProperties( true ); add( sheet, "*" ); // everytime a property change, update the button with it PropertyChangeListener listener = new PropertyChangeListener() { public void propertyChange( PropertyChangeEvent evt ) { Property prop = (Property) evt.getSource(); prop.writeToObject( data ); System.out.println( "Updated object to " + data ); } }; sheet.addPropertySheetChangeListener( listener ); JButton button = new JButton(new AbstractAction("Click to setWantsExtraIndent(true)") { public void actionPerformed(ActionEvent e) { sheet.getTable().setWantsExtraIndent(!sheet.getTable().getWantsExtraIndent()); putValue(NAME, "Click to setWantsExtraIndent(" + !sheet.getTable().getWantsExtraIndent() + ")"); } }); add(button); }
Example 20
Source File: ErrorDialog.java From binnavi with Apache License 2.0 | 4 votes |
private void createGui() { final JPanel topPanel = new JPanel(new BorderLayout()); final JPanel messagePanel = new JPanel(new BorderLayout()); final JTextField messageField = new JTextField(); messageField.setEditable(false); messageField.setText(message); messageField.setBackground(Color.WHITE); messagePanel.add(messageField); messagePanel.setBorder(new TitledBorder("Error Message")); topPanel.add(messagePanel, BorderLayout.NORTH); final JTabbedPane tabbedPane = new JTabbedPane(); final JTextArea descriptionArea = new JTextArea(); descriptionArea.setEditable(false); descriptionArea.setText(description); descriptionArea.setLineWrap(true); descriptionArea.setWrapStyleWord(true); tabbedPane.addTab("Description", descriptionArea); if (exception != null) { final JTextArea traceArea = new JTextArea(); traceArea.setEditable(false); traceArea.setText(StackTrace.toString(exception.getStackTrace())); tabbedPane.addTab("Stack Trace", new JScrollPane(traceArea)); } add(topPanel, BorderLayout.NORTH); add(tabbedPane); final JPanel bottomButtonPanel = new JPanel(new BorderLayout()); final JPanel leftButtonPanelBottom = new JPanel(); final JButton reportButton = new JButton(new ReportAction()); reportButton.setMinimumSize(new Dimension(180, reportButton.getHeight())); leftButtonPanelBottom.add(reportButton); bottomButtonPanel.add(leftButtonPanelBottom, BorderLayout.WEST); final JPanel rightButtonPanelBottom = new JPanel(); final JButton okButton = new JButton(new CloseButtonListener()); getRootPane().setDefaultButton(okButton); rightButtonPanelBottom.add(okButton); bottomButtonPanel.add(rightButtonPanelBottom, BorderLayout.EAST); add(bottomButtonPanel, BorderLayout.SOUTH); }