Example usage for java.awt TextArea TextArea

List of usage examples for java.awt TextArea TextArea

Introduction

In this page you can find the example usage for java.awt TextArea TextArea.

Prototype

public TextArea(int rows, int columns) throws HeadlessException 

Source Link

Document

Constructs a new text area with the specified number of rows and columns and the empty string as text.

Usage

From source file:MainClass.java

public MainClass() {
    super("Clipboard Test");
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);/*from   w  ww . ja v  a  2 s .com*/

    srcText = new TextArea(8, 32);
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.CENTER;
    gridbag.setConstraints(srcText, c);
    add(srcText);

    copyButton = new Button("Copy Above");
    copyButton.setActionCommand("copy");
    copyButton.addActionListener(this);
    c.gridy = 1;
    c.gridwidth = 1;
    gridbag.setConstraints(copyButton, c);
    add(copyButton);

    pasteButton = new Button("Paste Below");
    pasteButton.setActionCommand("paste");
    pasteButton.addActionListener(this);
    pasteButton.setEnabled(false);
    c.gridx = 1;
    gridbag.setConstraints(pasteButton, c);
    add(pasteButton);

    dstText = new TextArea(8, 32);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 2;
    gridbag.setConstraints(dstText, c);
    add(dstText);

    pack();
}

From source file:GUIManagerQuery.java

/***************************************************************************
 * Construct the GUIManagerQuery object, constructing the various components
 * and laying them out on the screen./*from w w  w .  j a  v  a2s  . co m*/
 **************************************************************************/
public GUIManagerQuery() {
    super("GUIManagerQuery");
    setLayout(new BorderLayout());

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    versionLabel = new Label("JMF v" + Manager.getVersion());
    add(versionLabel, "North");

    Panel lower = new Panel();
    lower.add(new Label("Content/Protocol"));
    contentsField = new TextField(32);
    lower.add(contentsField);
    add(lower, "South");

    results = new TextArea(20, 80);
    results.setEditable(false);
    add(results, "Center");

    Panel controls = new Panel();
    controls.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    hintsButton = new Button("Hints");
    gbc.gridx = 0;
    gbc.gridy = 0;
    controls.add(hintsButton, gbc);
    hintsButton.addActionListener(this);

    playersButton = new Button("Players");
    gbc.gridy = 1;
    controls.add(playersButton, gbc);
    playersButton.addActionListener(this);

    processorsButton = new Button("Processors");
    gbc.gridy = 2;
    controls.add(processorsButton, gbc);
    processorsButton.addActionListener(this);

    sourcesButton = new Button("DataSources");
    gbc.gridy = 3;
    controls.add(sourcesButton, gbc);
    sourcesButton.addActionListener(this);

    add(controls, "East");
}

From source file:LamePrintThread.java

public void init() {
    //Create the text area and make it uneditable.
    display = new TextArea(1, 80);
    display.setEditable(false);//from www  .  ja v  a2 s .c om

    //Set the layout manager so that the text area
    //will be as wide as possible.
    setLayout(new GridLayout(1, 0));

    //Add the text area to the applet.
    add(display);

    //Find the platform-dependent newline character.
    newline = System.getProperty("line.separator");
    addItem("init: " + threadInfo(Thread.currentThread()));
}

From source file:PrintThread.java

public void init() {
    //Create the text area and make it uneditable.
    display = new TextArea(1, 80);
    display.setEditable(false);/*from  ww w.  j  av  a 2 s  .c  om*/

    //Set the layout manager so that the text area
    //will be as wide as possible.
    setLayout(new java.awt.GridLayout(1, 0));

    //Add the text area to the applet.
    add(display);

    //Find the platform-dependent newline character.
    newline = System.getProperty("line.separator");

    addItem("init: " + threadInfo(Thread.currentThread()));
}

From source file:GetApplets.java

public void init() {
    Button b = new Button("Click to call getApplets()");
    b.addActionListener(this);

    setLayout(new BorderLayout());
    add("North", b);

    textArea = new TextArea(5, 40);
    textArea.setEditable(false);//from  www .  j  a v a2  s.  c  o m
    add("Center", textArea);

    newline = System.getProperty("line.separator");
}

From source file:GUIMediaStatistics.java

/**********************************************************************
* Construct the GUIMediaStatistics object, constructing the various
* components and laying them out on the screen.
**********************************************************************/
public GUIMediaStatistics() {
    super("GUIMediaStatistics");
    setLayout(new BorderLayout());

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from  ww w . j a v a  2 s.c o  m
        }
    });

    Panel filePanel = new Panel();

    filePanel.add(new Label("File:"));
    mediaField = new TextField(40);
    filePanel.add(mediaField);

    browseButton = new Button("browse...");
    filePanel.add(browseButton);
    browseButton.addActionListener(this);

    getStatsButton = new Button("get stats...");
    filePanel.add(getStatsButton);
    getStatsButton.addActionListener(this);

    add(filePanel, "North");

    results = new TextArea(80, 10);
    results.setEditable(false);
    add(results, "Center");
}

From source file:ClipboardTest.java

public ClipboardTest() {
    super("Clipboard Test");
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);// ww  w. j  av a 2s. c o m

    srcText = new TextArea(8, 32);
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.CENTER;
    gridbag.setConstraints(srcText, c);
    add(srcText);

    copyButton = new Button("Copy Above");
    copyButton.setActionCommand("copy");
    copyButton.addActionListener(this);
    c.gridy = 1;
    c.gridwidth = 1;
    gridbag.setConstraints(copyButton, c);
    add(copyButton);

    pasteButton = new Button("Paste Below");
    pasteButton.setActionCommand("paste");
    pasteButton.addActionListener(this);
    pasteButton.setEnabled(false);
    c.gridx = 1;
    gridbag.setConstraints(pasteButton, c);
    add(pasteButton);

    dstText = new TextArea(8, 32);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 2;
    gridbag.setConstraints(dstText, c);
    add(dstText);

    pack();
}

From source file:BenchmarkApplet.java

public void init() {
      tgroup = Thread.currentThread().getThreadGroup();

      Font font = new Font("Courier", Font.PLAIN, 10);
      FontMetrics fm = getFontMetrics(font);
      int lines = Math.max(10, size().height / fm.getHeight() - 4);

      out = new TextArea(lines, spaces.length() + Benchmark.resolutionName.length());
      out.setFont(font);//  w  ww .j  a  v a2  s  .c o m
      out.setEditable(false);
      add(out);

      boolean toobig;
      do {
          testList = new List(--lines, true);
          add(testList, 0);
          validate();
          if (toobig = testList.size().height - out.size().height > 2)
              remove(testList);
      } while (toobig);
      for (int ii = 0; ii < tests.length; ii++)
          testList.addItem(tests[ii].getName());
      testList.select(0); // Calibration benchmark
      testList.select(1); // Mixed benchmark

      timeEstimate = new Label(getTimeEstimate());
      add(timeEstimate);

      add(doit = new Button("Run Benchmark"));
      add(abort = new Button("Stop"));
      add(clear = new Button("Clear"));
      abort.disable();
      clear.disable();

      add(console = new Checkbox("Console"));

      validate();
  }

From source file:width.java

 public void init() {
     GridBagLayout gridBag = new GridBagLayout();
     GridBagConstraints c = new GridBagConstraints();

     setLayout(gridBag);/*from  www.  j a va 2 s  .  c om*/

     Label receiverLabel = new Label("Receiver name:", 
                                     Label.RIGHT);
     gridBag.setConstraints(receiverLabel, c);
     add(receiverLabel);

     nameField = new TextField(getParameter("RECEIVERNAME"),
                                            10);
     c.fill = GridBagConstraints.HORIZONTAL;
     gridBag.setConstraints(nameField, c);
     add(nameField);
     nameField.addActionListener(this);

     Button button = new Button("Send message");
     c.gridwidth = GridBagConstraints.REMAINDER; //end row
     c.anchor = GridBagConstraints.WEST; //stick to the 
                                         //text field
     c.fill = GridBagConstraints.NONE; //keep the button 
                                       //small
     gridBag.setConstraints(button, c);
     add(button);
     button.addActionListener(this);

     status = new TextArea(5, 60);
     status.setEditable(false);
     c.anchor = GridBagConstraints.CENTER; //reset to the default
     c.fill = GridBagConstraints.BOTH; //make this big
     c.weightx = 1.0;
     c.weighty = 1.0;
     gridBag.setConstraints(status, c);
     add(status);

     myName = getParameter("NAME");
     Label senderLabel = new Label("(My name is " + myName + ".)",
                                   Label.CENTER);
     c.weightx = 0.0;
     c.weighty = 0.0;
     gridBag.setConstraints(senderLabel, c);
     add(senderLabel);

newline = System.getProperty("line.separator");
 }

From source file:TalkServerThread.java

public void init() {
        //Get the address of the host we came from.
        host = getCodeBase().getHost();/*from  www  .  j  av  a 2 s  . c o m*/

        //Set up the UI.
        GridBagLayout gridBag = new GridBagLayout();
        GridBagConstraints c = new GridBagConstraints();
        setLayout(gridBag);

        message = new TextField("");
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridwidth = GridBagConstraints.REMAINDER;
        gridBag.setConstraints(message, c);
        message.addActionListener(this);
        add(message);

        display = new TextArea(10, 40);
        display.setEditable(false);
        c.weightx = 1.0;
        c.weighty = 1.0;
        c.fill = GridBagConstraints.BOTH;
        gridBag.setConstraints(display, c);
        add(display);

        Label l = new Label("Enter the port (on host " + host + ") to send the request to:", Label.RIGHT);
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridwidth = 1;
        c.weightx = 0.0;
        c.weighty = 0.0;
        gridBag.setConstraints(l, c);
        add(l);

        portField = new TextField(6);
        c.fill = GridBagConstraints.NONE;
        gridBag.setConstraints(portField, c);
        portField.addActionListener(this);
        add(portField);

        button = new Button("Connect");
        gridBag.setConstraints(button, c);
        button.addActionListener(this);
        add(button);

        newline = System.getProperty("line.separator");
    }