List of usage examples for javax.swing JTextArea JTextArea
public JTextArea()
From source file:application.draw.SaveButtonDebuggFrame.java
private void initGUI() { try {/* w ww . j a v a2s . c o m*/ { getContentPane().setLayout(null); } { saveButton = new JButton(); getContentPane().add(saveButton); saveButton.setText("save"); saveButton.setBounds(0, 0, 75, 31); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveButtonActionPerformed(evt); } }); } { clearButton = new JButton(); getContentPane().add(clearButton); clearButton.setText("clear message"); clearButton.setBounds(75, 0, 132, 31); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { clearButtonActionPerformed(evt); } }); } { messagePane = new JScrollPane(); getContentPane().add(messagePane); messagePane.setBounds(5, 107, 527, 502); { messageTextArea = new JTextArea(); messagePane.setViewportView(messageTextArea); messageTextArea.setBounds(236, 172, 61, 12); messageTextArea.setPreferredSize(new java.awt.Dimension(521, 501)); messagePane.setAutoscrolls(true); } } { inputField = new JTextField(); getContentPane().add(inputField); inputField.setBounds(4, 66, 455, 39); } { sendButton = new JButton(); getContentPane().add(sendButton); sendButton.setText("send"); sendButton.setBounds(459, 66, 73, 38); sendButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { sendButtonActionPerformed(evt); } }); } { urlField = new JTextField(); getContentPane().add(urlField); urlField.setBounds(5, 32, 454, 34); } { connectButton = new JButton(); getContentPane().add(connectButton); connectButton.setText("con"); connectButton.setBounds(459, 31, 74, 36); connectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { connectButtonActionPerformed(evt); } }); } { editPageButton = new JButton(); getContentPane().add(editPageButton); editPageButton.setText("edit"); editPageButton.setBounds(285, 0, 75, 31); editPageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPageButtonActionPerformed(evt); } }); } { updateButton = new JButton(); getContentPane().add(updateButton); updateButton.setText("update"); updateButton.setBounds(360, 0, 84, 31); updateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { updateButtonActionPerformed(evt); } }); } { paramButton = new JButton(); getContentPane().add(paramButton); paramButton.setText("params"); paramButton.setBounds(444, 0, 91, 31); paramButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { paramButtonActionPerformed(evt); } }); } { readFigButton = new JButton(); getContentPane().add(readFigButton); readFigButton.setText("read"); readFigButton.setBounds(207, 1, 78, 30); readFigButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { readFigButtonActionPerformed(evt); } }); } { this.setSize(551, 650); } } catch (Exception e) { e.printStackTrace(); } }
From source file:medsavant.uhn.cancer.SetCommentStatusDialog.java
private JPanel getMainPanel() { JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); //Status box. mainPanel.add(getStatusEditorPanel()); //Comment box. JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.add(Box.createHorizontalGlue()); comment = new JTextArea(); p.add(comment);/*w w w.j a v a 2 s. com*/ p.add(Box.createHorizontalGlue()); mainPanel.add(p); //Button box. p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.add(Box.createHorizontalGlue()); JButton OKButton = new JButton("Update status"); OKButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { updateStatus(); dispose(); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); DialogUtils.displayException("Error", ex.getMessage(), ex); } } }); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); p.add(OKButton); p.add(cancelButton); p.add(Box.createHorizontalGlue()); mainPanel.add(p); return mainPanel; }
From source file:it.unibas.spicygui.vista.BestMappingsTopComponent.java
private void initComponent(Image imageNumber) { setName(NbBundle.getMessage(Costanti.class, Costanti.VIEW_BEST_MAPPINGS_TOP_COMPONENT)); setToolTipText(NbBundle.getMessage(Costanti.class, Costanti.VIEW_BEST_MAPPINGS_TOP_COMPONENT_TOOLTIP)); Image imageDefault = ImageUtilities.loadImage(Costanti.ICONA_VIEW_BEST_MAPPINGS, true); this.setIcon(ImageUtilities.mergeImages(imageDefault, imageNumber, Scenario.X_OFFSET_IMAGE_NUMBER, Scenario.Y_OFFSET_IMAGE_NUMBER)); messageLabel = new JTextArea(); messageLabel.setRows(2);/* ww w . j a va2s . c o m*/ messageLabel.setEditable(false); messageLabel.setBackground(this.getBackground()); tabellaBestMappings = new JTable(); jScrollPane = new JScrollPane(); jScrollPane.setPreferredSize(new DimensionUIResource(150, this.getHeight())); this.setPreferredSize(new Dimension(150, this.getHeight())); this.setLayout(new BorderLayout()); this.add(messageLabel, BorderLayout.NORTH); this.add(jScrollPane, BorderLayout.CENTER); addSelectionListener(); }
From source file:gtu.zcognos.SimpleUI.java
private void initGUI() { try {/* w w w . j a v a 2 s.c o m*/ final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this); { GroupLayout thisLayout = new GroupLayout((JComponent) getContentPane()); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); { projectId = new JTextField(); } { packageId = new JTextField(); } { jLabel1 = new JLabel(); jLabel1.setText("PROJECT_ID"); } { jLabel2 = new JLabel(); jLabel2.setText("PACKAGE_ID"); } { jLabel3 = new JLabel(); jLabel3.setText("DATATABLE"); } { jScrollPane1 = new JScrollPane(); { dataTable = new JTextArea(); jScrollPane1.setViewportView(dataTable); } } { create = new JButton(); create.setText("create"); create.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("create.actionPerformed", evt); } }); } thisLayout.setVerticalGroup(thisLayout.createSequentialGroup().addContainerGap(16, 16) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(projectId, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup().addGroup(GroupLayout.Alignment.LEADING, thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(packageId, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup() .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE) .addComponent(create, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))) .addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 217, GroupLayout.PREFERRED_SIZE) .addContainerGap()); thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup().addContainerGap(31, 31).addGroup( thisLayout.createParallelGroup().addGroup(GroupLayout.Alignment.LEADING, thisLayout .createSequentialGroup() .addGroup(thisLayout.createParallelGroup() .addComponent(jLabel2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup() .addComponent(packageId, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 204, GroupLayout.PREFERRED_SIZE) .addComponent(projectId, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 204, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(create, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE)) .addGroup(thisLayout.createSequentialGroup() .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 417, GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap(17, 17)); } this.setSize(473, 356); swingUtil.addAction("create.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { String project = projectId.getText(); String dataTab = dataTable.getText(); Validate.notEmpty(project); Validate.notEmpty(dataTab); String pkgId = StringUtils.defaultIfEmpty(packageId.getText(), project); List<String> dataTableList = new ArrayList<String>(); StringTokenizer tok = new StringTokenizer(dataTab); for (int ii = 0; tok.hasMoreElements(); ii++) { String column = (String) tok.nextElement(); System.out.format("%d -- %s\n", ii, column); if (StringUtils.isBlank(column)) { continue; } dataTableList.add(column.trim()); } File destDir = new File(CREATE_DEST + "\\" + project); destDir.mkdirs(); Map<String, Object> map = new HashMap<String, Object>(); map.put("PROJECT_ID", project); map.put("PACKAGE_ID", pkgId); map.put("DATATABLE", dataTableList); ConfigCopy.getInstance().applyBaseDir(new File(CREATE_DEST)).applyProjectId(project).execute(); Simple.getInstance()// .applyDestDir(destDir.getAbsolutePath())// .applyParameter(map)// .execute(); JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog(pkgId + " create completed!!\r\n dir : " // + destDir.getAbsolutePath(), pkgId); Desktop.getDesktop().open(destDir); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:components.TextFieldDemo.java
/** This method is called from within the constructor to * initialize the form./*from w w w. j a v a2 s . co m*/ */ private void initComponents() { entry = new JTextField(); textArea = new JTextArea(); status = new JLabel(); jLabel1 = new JLabel(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setTitle("TextFieldDemo"); textArea.setColumns(20); textArea.setLineWrap(true); textArea.setRows(5); textArea.setWrapStyleWord(true); textArea.setEditable(false); jScrollPane1 = new JScrollPane(textArea); jLabel1.setText("Enter text to search:"); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); //Create a parallel group for the horizontal axis ParallelGroup hGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING); //Create a sequential and a parallel groups SequentialGroup h1 = layout.createSequentialGroup(); ParallelGroup h2 = layout.createParallelGroup(GroupLayout.Alignment.TRAILING); //Add a container gap to the sequential group h1 h1.addContainerGap(); //Add a scroll pane and a label to the parallel group h2 h2.addComponent(jScrollPane1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE); h2.addComponent(status, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE); //Create a sequential group h3 SequentialGroup h3 = layout.createSequentialGroup(); h3.addComponent(jLabel1); h3.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED); h3.addComponent(entry, GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE); //Add the group h3 to the group h2 h2.addGroup(h3); //Add the group h2 to the group h1 h1.addGroup(h2); h1.addContainerGap(); //Add the group h1 to the hGroup hGroup.addGroup(GroupLayout.Alignment.TRAILING, h1); //Create the horizontal group layout.setHorizontalGroup(hGroup); //Create a parallel group for the vertical axis ParallelGroup vGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING); //Create a sequential group v1 SequentialGroup v1 = layout.createSequentialGroup(); //Add a container gap to the sequential group v1 v1.addContainerGap(); //Create a parallel group v2 ParallelGroup v2 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE); v2.addComponent(jLabel1); v2.addComponent(entry, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); //Add the group v2 tp the group v1 v1.addGroup(v2); v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); v1.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE); v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); v1.addComponent(status); v1.addContainerGap(); //Add the group v1 to the group vGroup vGroup.addGroup(v1); //Create the vertical group layout.setVerticalGroup(vGroup); pack(); }
From source file:ConsoleWindowTest.java
public static void init() { JFrame frame = new JFrame(); frame.setTitle("ConsoleWindow"); final JTextArea output = new JTextArea(); output.setEditable(false);//from www .j a v a 2 s . c o m frame.add(new JScrollPane(output)); frame.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); frame.setLocation(DEFAULT_LEFT, DEFAULT_TOP); frame.setFocusableWindowState(false); frame.setVisible(true); // define a PrintStream that sends its bytes to the output text area PrintStream consoleStream = new PrintStream(new OutputStream() { public void write(int b) { } // never called public void write(byte[] b, int off, int len) { output.append(new String(b, off, len)); } }); // set both System.out and System.err to that stream System.setOut(consoleStream); System.setErr(consoleStream); }
From source file:TextAreaDemo.java
private void initComponents() { jLabel1 = new JLabel("Try typing 'spectacular' or 'Swing'..."); textArea = new JTextArea(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); textArea.setColumns(20);/*w ww . j a va 2 s .co m*/ textArea.setLineWrap(true); textArea.setRows(5); textArea.setWrapStyleWord(true); jScrollPane1 = new JScrollPane(textArea); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); // Create a parallel group for the horizontal axis ParallelGroup hGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING); // Create a sequential and a parallel groups SequentialGroup h1 = layout.createSequentialGroup(); ParallelGroup h2 = layout.createParallelGroup(GroupLayout.Alignment.TRAILING); // Add a scroll panel and a label to the parallel group h2 h2.addComponent(jScrollPane1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE); h2.addComponent(jLabel1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE); // Add a container gap to the sequential group h1 h1.addContainerGap(); // Add the group h2 to the group h1 h1.addGroup(h2); h1.addContainerGap(); // Add the group h1 to hGroup hGroup.addGroup(Alignment.TRAILING, h1); // Create the horizontal group layout.setHorizontalGroup(hGroup); // Create a parallel group for the vertical axis ParallelGroup vGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING); // Create a sequential group SequentialGroup v1 = layout.createSequentialGroup(); // Add a container gap to the sequential group v1 v1.addContainerGap(); // Add a label to the sequential group v1 v1.addComponent(jLabel1); v1.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED); // Add scroll panel to the sequential group v1 v1.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE); v1.addContainerGap(); // Add the group v1 to vGroup vGroup.addGroup(v1); // Create the vertical group layout.setVerticalGroup(vGroup); pack(); }
From source file:it.unibas.spicygui.vista.RankedTransformationsTopComponent.java
private void initComponent() { messageLabel = new JTextArea(); messageLabel.setRows(2);/*from w w w. java 2s.c om*/ messageLabel.setEditable(false); messageLabel.setBackground(this.getBackground()); tabellaRankedTransformations = new JTable(); jScrollPane = new JScrollPane(); jScrollPane.setPreferredSize(new DimensionUIResource(150, this.getHeight())); this.setPreferredSize(new Dimension(150, this.getHeight())); this.setLayout(new BorderLayout()); this.add(messageLabel, BorderLayout.NORTH); this.add(jScrollPane, BorderLayout.CENTER); addSelectionListener(); }
From source file:ContainerEventDemo.java
public ContainerEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); //Initialize an empty list of buttons. buttonList = new Vector(10, 10); //Create all the components. addButton = new JButton("Add a button"); addButton.setActionCommand(ADD);/*from w w w . j a v a2s . c o m*/ addButton.addActionListener(this); removeButton = new JButton("Remove a button"); removeButton.setActionCommand(REMOVE); removeButton.addActionListener(this); buttonPanel = new JPanel(new GridLayout(1, 1)); buttonPanel.setPreferredSize(new Dimension(200, 75)); buttonPanel.addContainerListener(this); display = new JTextArea(); display.setEditable(false); JScrollPane scrollPane = new JScrollPane(display); scrollPane.setPreferredSize(new Dimension(200, 75)); clearButton = new JButton("Clear text area"); clearButton.setActionCommand(CLEAR); clearButton.addActionListener(this); c.fill = GridBagConstraints.BOTH; //Fill entire cell. c.weighty = 1.0; //Button area and message area have equal height. c.gridwidth = GridBagConstraints.REMAINDER; //end of row gridbag.setConstraints(scrollPane, c); add(scrollPane); c.weighty = 0.0; gridbag.setConstraints(clearButton, c); add(clearButton); c.weightx = 1.0; //Add/remove buttons have equal width. c.gridwidth = 1; //NOT end of row gridbag.setConstraints(addButton, c); add(addButton); c.gridwidth = GridBagConstraints.REMAINDER; //end of row gridbag.setConstraints(removeButton, c); add(removeButton); c.weighty = 1.0; //Button area and message area have equal height. gridbag.setConstraints(buttonPanel, c); add(buttonPanel); setPreferredSize(new Dimension(400, 400)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:com.wafflesoft.kinectcontroller.Main.java
public void run() { KinectUserTracker kinectUserTracker = new KinectUserTracker(_csm); _done = false;/* w w w. j a v a 2 s .c o m*/ _frame = new JFrame("Kinect Controller"); // register to key events _frame.addKeyListener(new KeyListener() { public void keyTyped(KeyEvent arg) { } public void keyReleased(KeyEvent arg) { } public void keyPressed(KeyEvent arg) { if (arg.getKeyCode() == KeyEvent.VK_ESCAPE) { _done = true; } } }); // register to closing event _frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { _done = true; } }); kinectUserTracker.kinectWindow.setSize(800, 600); _frame.add("Center", kinectUserTracker.kinectWindow); _eventWindow = new JTextArea(); _eventWindow.setVisible(!_arguments.hasOption('d')); _frame.add(new JScrollPane(_eventWindow)); _frame.setSize(kinectUserTracker.kinectWindow.getWidth(), kinectUserTracker.kinectWindow.getHeight()); _frame.setVisible(true); while (!_done) { _frame.repaint(); try { Thread.sleep(16); } catch (InterruptedException e) { e.printStackTrace(); } } }