コード例 #1
0
ファイル: First_GUI.java プロジェクト: head1km/CMU-Coursework
  // TextArea Text;
  public void init() {

    // Tell the applet not to use a layout manager.
    setSize(500, 500);
    setLayout(null);

    // initialze the button and give it a text.
    Rubric = new Button("Rubric Editor");
    GradeSheet = new Button("Grade Sheet Editor");
    TextArea text = new TextArea("Please Choose one of the following");

    // now we will specify the positions of the GUI components.
    // this is done by specifying the x and y coordinate and
    // the width and height.
    Rubric.setBounds(100, 275, 100, 30);
    GradeSheet.setBounds(230, 275, 150, 30);
    text.setBounds(100, 225, 300, 50);
    text.setEditable(false);
    (text).getScrollbarVisibility();
    // now that all is set we can add these components to the applet
    add(text);
    add(Rubric);
    add(GradeSheet);
    Rubric.addActionListener(this);
    GradeSheet.addActionListener(this);
  }
コード例 #2
0
  // DO NOT call this directly, go through Sysout
  public void printInstructions(String[] instructions) {
    // Clear out any current instructions
    instructionsText.setText("");

    // Go down array of instruction strings

    String printStr, remainingStr;
    for (int i = 0; i < instructions.length; i++) {
      // chop up each into pieces maxSringLength long
      remainingStr = instructions[i];
      while (remainingStr.length() > 0) {
        // if longer than max then chop off first max chars to print
        if (remainingStr.length() >= maxStringLength) {
          // Try to chop on a word boundary
          int posOfSpace = remainingStr.lastIndexOf(' ', maxStringLength - 1);

          if (posOfSpace <= 0) posOfSpace = maxStringLength - 1;

          printStr = remainingStr.substring(0, posOfSpace + 1);
          remainingStr = remainingStr.substring(posOfSpace + 1);
        }
        // else just print
        else {
          printStr = remainingStr;
          remainingStr = "";
        }

        instructionsText.append(printStr + "\n");
      } // while
    } // for
  } // printInstructions()
コード例 #3
0
 /*
  * Test method for 'java.awt.TextArea.TextArea()'
  */
 public void testTextArea() {
   assertNotNull(area);
   assertEquals("", area.getText());
   assertEquals(0, area.getColumns());
   assertEquals(0, area.getRows());
   assertEquals(TextArea.SCROLLBARS_BOTH, area.getScrollbarVisibility());
 }
コード例 #4
0
ファイル: Irc.java プロジェクト: jeanyves-b/javanaise
  /**
   * IRC Constructor
   *
   * @param jo the JVN object representing the Chat
   */
  public Irc(JvnObject jo) {
    sentence = jo;
    frame = new JFrame();
    frame.setLayout(new GridLayout(1, 1));
    text = new TextArea(10, 60);
    text.setEditable(false);
    text.setForeground(Color.red);
    frame.add(text);
    data = new TextField(40);
    frame.add(data);
    Button read_button = new Button("read");
    read_button.addActionListener(new readListener(this));
    frame.add(read_button);
    Button write_button = new Button("write");
    write_button.addActionListener(new writeListener(this));
    frame.add(write_button);
    frame.setSize(545, 201);
    // frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            System.out.println("Closed");
            try {
              JvnServerImpl.jvnGetServer().jvnTerminate();
            } catch (Exception exc) {
              System.out.println("An exception: " + exc);
            }

            e.getWindow().dispose();
          }
        });
    text.setBackground(Color.black);
    frame.setVisible(true);
  }
コード例 #5
0
 private void AbrirProyectoActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_AbrirProyectoActionPerformed
   // TODO add your handling code here:
   JFileChooser CargarProy = new JFileChooser();
   String leerl = "", filecomplete = "";
   javax.swing.filechooser.FileFilter filtro =
       new FileNameExtensionFilter("Proyecto (.java)", "java");
   CargarProy.setFileFilter(filtro);
   CargarProy.setFileSelectionMode(JFileChooser.FILES_ONLY);
   CargarProy.showOpenDialog(this);
   if (CargarProy.getSelectedFile() != null) {
     Errores.InicializarTablaDeErrores();
     Proyecto = CargarProy.getSelectedFile();
     try {
       FileReader fr = new FileReader(Proyecto);
       BufferedReader br = new BufferedReader(fr);
       while ((leerl = br.readLine()) != null) {
         filecomplete = filecomplete + "\n" + leerl;
       }
     } catch (IOException ex) {
       Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
     }
     TextArea a = new TextArea();
     a.setEditable(true);
     a.setText(filecomplete);
     a.setEnabled(true);
     archivos.add(Proyecto);
     TAREAS.add(a);
     this.jTP.add(a);
     this.Guardados = true;
   } // GEN-LAST:event_AbrirProyectoActionPerformed
 }
コード例 #6
0
ファイル: GenericDialog.java プロジェクト: aschain/ImageJA
 /** Returns the contents of the next textarea. */
 public String getNextText() {
   String text;
   if (textAreaIndex == 0 && textArea1 != null) {
     // textArea1.selectAll();
     text = textArea1.getText();
     textAreaIndex++;
     if (macro) text = Macro.getValue(macroOptions, "text1", text);
     if (recorderOn) {
       String text2 = text;
       String cmd = Recorder.getCommand();
       if (cmd != null && cmd.equals("Convolve...")) {
         text2 = text.replaceAll("\n", "\\\\n");
         if (!text.endsWith("\n")) text2 = text2 + "\\n";
       } else text2 = text.replace('\n', ' ');
       Recorder.recordOption("text1", text2);
     }
   } else if (textAreaIndex == 1 && textArea2 != null) {
     textArea2.selectAll();
     text = textArea2.getText();
     textAreaIndex++;
     if (macro) text = Macro.getValue(macroOptions, "text2", text);
     if (recorderOn) Recorder.recordOption("text2", text.replace('\n', ' '));
   } else text = null;
   return text;
 }
コード例 #7
0
ファイル: DictAWTView.java プロジェクト: amake/jdictserver
 void lookup(String s, boolean append) {
   if (s.length() > 25) {
     return;
   }
   history[pos++ % history.length] = s;
   f.toFront();
   // ta.requestFocus();
   String dbID = "*";
   int dbIndex = db.getSelectedIndex();
   if (dbIndex < engine.getDatabases().length) {
     dbID = engine.getDatabases()[dbIndex].getID();
   }
   IAnswer[] a = engine.defineMatch(dbID, s, null, true, IDatabase.STRATEGY_NONE);
   StringWriter w = new StringWriter();
   PrintWriter out = new PrintWriter(w);
   IRequest req = new SimpleRequest("", "word=" + s);
   try {
     org.dict.kernel.answer.printer.PlainPrinter.printAnswers(engine, req, a, false, out);
     out.flush();
   } catch (Exception e) {
     e.printStackTrace(out);
   }
   if (append) {
     ta.append(w.toString());
   } else {
     ta.setText(w.toString());
   }
 }
コード例 #8
0
ファイル: DictAWTView.java プロジェクト: amake/jdictserver
 private void showHistory() {
   ta.setText("");
   for (int i = 0; i < history.length; i++) {
     String sep = i == 10 ? "\n" : " | ";
     if (history[i] != null) ta.append(history[i] + sep);
   }
 }
コード例 #9
0
 void setCutText(String text) {
   selection = text;
   textArea.setText(text);
   if (isVisible()) {
     textArea.selectAll();
   }
 }
コード例 #10
0
 // Script Editor
 private void scriptEditor() {
   scriptfield.setEditable(true);
   scriptfield.setFont(font);
   scriptfield.setPreferredSize(new Dimension(800, 900));
   scriptfield.setCursor(null);
   script.add(scriptfield);
 }
コード例 #11
0
  /** Create the dialog. */
  public AlertMessage(String Message) {
    setBounds(100, 100, 300, 200);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new GridLayout(1, 0, 0, 0));
    {
      TextArea textArea = new TextArea(Message);
      textArea.setEditable(false);
      contentPanel.add(textArea);
    }
    {
      JPanel buttonPane = new JPanel();
      buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
      getContentPane().add(buttonPane, BorderLayout.SOUTH);
      {
        JButton okButton = new JButton("OK");
        okButton.addActionListener(
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent arg0) {
                dispose();
              }
            });
        buttonPane.add(okButton);
        getRootPane().setDefaultButton(okButton);
      }
    }
  }
コード例 #12
0
  /*.................................................................................................................*/
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("setToDefaults")) {
      setDefaultTNTCommandsSearchOptions();
      searchField.setText(searchArguments);
      bootstrapSearchField.setText(bootstrapSearchArguments);
      harvestOnlyStrictConsensusBox.setState(harvestOnlyStrictConsensus);
      resamplingAllConsensusTreesBox.setState(!resamplingAllConsensusTrees);
      bootStrapRepsField.setValue(bootstrapreps);

    } else if (e.getActionCommand().equalsIgnoreCase("setToDefaultsOtherOptions")) {
      setDefaultTNTCommandsOtherOptions();
      otherOptionsField.setText(otherOptions);
      convertGapsBox.setState(convertGapsToMissing);
    } else if (e.getActionCommand().equalsIgnoreCase("browseSearchScript")
        && searchScriptPathField != null) {
      MesquiteString directoryName = new MesquiteString();
      MesquiteString fileName = new MesquiteString();
      String path =
          MesquiteFile.openFileDialog("Choose Search Script File", directoryName, fileName);
      if (StringUtil.notEmpty(path)) searchScriptPathField.setText(path);
    } else if (e.getActionCommand().equalsIgnoreCase("browseBootSearchScript")
        && bootSearchScriptPathField != null) {

      MesquiteString directoryName = new MesquiteString();
      MesquiteString fileName = new MesquiteString();
      String path =
          MesquiteFile.openFileDialog(
              "Choose Resampling Search Script File", directoryName, fileName);
      if (StringUtil.notEmpty(path)) bootSearchScriptPathField.setText(path);
    }
  }
コード例 #13
0
  public boolean action(Event event, Object object) {
    if (event.target instanceof Button) {
      if ("Apply".equals(object)) {
        if (setValues_()) hide();
        return true;
      } else if ("Cancel".equals(object)) {
        hide();
        return true;
      }
    } else if (event.target == data_) {
      dataHash_.put(currentData_, dataText_.getText());

      String old_data = currentData_;
      currentData_ = data_.getSelectedItem();
      if (!currentData_.equals("<NEW>")) {
        String value = (String) dataHash_.get(currentData_);
        if (value == null) value = new String("");
        dataText_.setText(value);
      } else {
        new InputDialog(
            frame_,
            "Enter name for new data item " + "(must be a letter followed by letters and numbers).",
            this,
            9999);
        if (data_.getSelectedItem().equals("<NEW>")) data_.select(old_data);
      }
    }

    return false;
  }
コード例 #14
0
ファイル: CBiomAbout.java プロジェクト: kayschwarz/biomorph
  void jbInit() throws Exception {
    panel1.setLayout(borderLayout1);
    panel2.setBackground(Color.yellow);
    panel2.setLayout(borderLayout2);
    ButtonOK.setLabel("OK");
    ButtonOK.addMouseListener(
        new java.awt.event.MouseAdapter() {

          public void mouseClicked(MouseEvent e) {
            ButtonOK_mouseClicked(e);
          }
        });

    String s1 = CallingApp.MotherApplet.GetName();

    textArea1.setBackground(SystemColor.control);
    textArea1.setEditable(false);

    panel1.add(panel2, BorderLayout.CENTER);
    panel2.add(textArea1, BorderLayout.CENTER);
    panel1.add(panel3, BorderLayout.SOUTH);
    panel3.add(ButtonOK, null);
    String s =
        s1
            + " v:"
            + CallingApp.MotherApplet.GetVersionNum()
            + "\n"
            + CallingApp.MotherApplet.GetInfos();
    textArea1.setText(s);
  }
コード例 #15
0
ファイル: ComponentSampleI.java プロジェクト: 161194/Aula01
  ComponentSampleI() {
    // analise o uso do método abaixo
    // tf.setPreferredSize(new Dimension(200,20));

    // insere b e tf no painel
    p.add(b);
    p.add(tf);

    // insere o painel no norte do frame
    add(p, BorderLayout.NORTH);

    // atribui cor ao fundo e às letras na área de texto
    ta.setBackground(Color.cyan);
    ta.setForeground(Color.red);
    ta.setPreferredSize(new Dimension(250, 50));

    x.setBackground(Color.yellow);
    add(x, BorderLayout.CENTER); // estica o componente em ambas as direções

    add(ta, BorderLayout.EAST); // estica o componente na horizontal
    add(l, BorderLayout.SOUTH); // estica o componente na vertical

    // descobre as dimensões do monitor
    d = (Toolkit.getDefaultToolkit()).getScreenSize();

    // calcula e posiciona o frame no centro da tela
    setLocation(
        (d.width - this.getSize().width) / 2 - 150, (d.height - this.getSize().height) / 2 - 200);

    setSize(300, 400);
    setVisible(true);
  }
コード例 #16
0
ファイル: Irc.java プロジェクト: greg5813/projet-sysco
  public Irc(Sentence_itf s) {

    setLayout(new FlowLayout());

    text = new TextArea(10, 60);
    text.setEditable(false);
    text.setForeground(Color.red);
    add(text);

    data = new TextField(60);
    add(data);

    Button write_button = new Button("write");
    write_button.addActionListener(new writeListener(this));
    add(write_button);
    Button read_button = new Button("read");
    read_button.addActionListener(new readListener(this));
    add(read_button);

    setSize(470, 300);
    text.setBackground(Color.black);
    show();

    sentence = s;
  }
 private static void badFetch() {
   final JFrame frame = new JFrame("TestFetchWebGui");
   final JPanel outerPanel = new JPanel(), buttonPanel = new JPanel();
   final JButton fetchButton = new JButton("Fetch"), cancelButton = new JButton("Cancel");
   frame.add(outerPanel);
   outerPanel.setLayout(new BorderLayout());
   buttonPanel.setLayout(new GridLayout(2, 1));
   buttonPanel.add(fetchButton);
   buttonPanel.add(cancelButton);
   outerPanel.add(buttonPanel, BorderLayout.EAST);
   final TextArea textArea = new TextArea(25, 80);
   textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
   outerPanel.add(textArea, BorderLayout.WEST);
   fetchButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           for (String url : urls) {
             System.out.println("Fetching " + url);
             String page = getPage(url, 200);
             textArea.append(String.format("%-40s%7d%n", url, page.length()));
           }
         }
       });
   frame.pack();
   frame.setVisible(true);
 }
コード例 #18
0
ファイル: OS.java プロジェクト: kxk2907/C-Code
 /** displays a line and waits for a button click. */
 public synchronized void println(String line) {
   in.append(line);
   try {
     wait();
   } catch (InterruptedException e) {
   }
   in.append("\n");
 }
コード例 #19
0
 /*
  * Test method for 'java.awt.TextArea.TextArea(int, int)'
  */
 public void testTextAreaIntInt() {
   int cols = 12;
   int rows = 15;
   area = new TextArea(rows, cols);
   assertEquals("", area.getText());
   assertEquals(cols, area.getColumns());
   assertEquals(rows, area.getRows());
 }
コード例 #20
0
ファイル: ChatServer.java プロジェクト: cttiamin/JavaTest
 public void startServer() throws Exception {
   while (true) {
     Socket s = server.accept();
     cClient.add(new ClientConn(s));
     ta.append("NEW-CLIENT " + s.getInetAddress() + ":" + s.getPort());
     ta.append("\n" + "CLIENTS-COUNT: " + cClient.size() + "\n\n");
   }
 }
コード例 #21
0
  /** Method declaration Adjust this method for large strings...ie multi megabtypes. */
  void execute() {

    String sCmd = null;

    if (4096 <= ifHuge.length()) {
      sCmd = ifHuge;
    } else {
      sCmd = txtCommand.getText();
    }

    if (sCmd.startsWith("-->>>TEST<<<--")) {
      testPerformance();

      return;
    }

    String g[] = new String[1];

    lTime = System.currentTimeMillis();

    try {
      sStatement.execute(sCmd);

      lTime = System.currentTimeMillis() - lTime;

      int r = sStatement.getUpdateCount();

      if (r == -1) {
        formatResultSet(sStatement.getResultSet());
      } else {
        g[0] = "update count";

        gResult.setHead(g);

        g[0] = String.valueOf(r);

        gResult.addRow(g);
      }

      addToRecent(txtCommand.getText());
    } catch (SQLException e) {
      lTime = System.currentTimeMillis() - lTime;
      g[0] = "SQL Error";

      gResult.setHead(g);

      String s = e.getMessage();

      s += " / Error Code: " + e.getErrorCode();
      s += " / State: " + e.getSQLState();
      g[0] = s;

      gResult.addRow(g);
    }

    updateResult();
    System.gc();
  }
コード例 #22
0
 /*
  * Test method for 'java.awt.TextArea.appendText(String)'
  */
 @SuppressWarnings("deprecation")
 public void testAppendText() {
   String text = "text";
   area.setText(text);
   String str = "\nappended text";
   area.appendText(str);
   assertEquals(text + str, area.getText());
   assertEquals(0, area.getColumns());
 }
コード例 #23
0
 /*
  * Test method for 'java.awt.TextArea.insert(String, int)'
  */
 public void testInsert() {
   String text = "text";
   area.setText(text);
   String str = "inserted text\n";
   area.insert(str, 0);
   assertEquals(str + text, area.getText());
   assertEquals(0, area.getRows());
   assertEquals(0, area.getCaretPosition());
 }
コード例 #24
0
 /*
  * Test method for 'java.awt.TextArea.preferredSize(int, int)'
  */
 @SuppressWarnings("deprecation")
 public void testPreferredSizeIntInt() {
   frame = new Frame();
   frame.add(area);
   frame.addNotify();
   int rows = 10;
   int cols = 25;
   assertEquals(area.getPreferredSize(rows, cols), area.preferredSize(rows, cols));
 }
コード例 #25
0
 /*
  * Test method for 'java.awt.TextArea.addNotify()'
  */
 public void testAddNotify() {
   frame = new Frame();
   frame.add(area);
   assertNull(area.getGraphics());
   assertFalse(area.isDisplayable());
   frame.addNotify();
   assertTrue(area.isDisplayable());
   assertNotNull(area.getGraphics());
 }
コード例 #26
0
ファイル: SimpleFenetre.java プロジェクト: asanian/GenNet
  private JPanel getContainer() {
    layout = new FlowLayout(); // Instanciation du layout
    layout.setAlignment(FlowLayout.CENTER); // On centre les composants

    container = new JPanel(); // On cr�e notre objet
    container.setLayout(layout); // On applique le layout

    textCycle.setEditable(false);
    textCycle.setPreferredSize(new Dimension(600, 200));
    for (int k = 0; k < cycles.size(); k++) {
      textCycle.setText(
          textCycle.getText()
              + "Cycle no"
              + k
              + " :"
              + cycles.get(k).toString()
              + "\n"
              + "\n"); // On lui donne un texte
      container.add(textCycle); // On l'ajoute au container
    }

    btnPath = new JButton(); // Cr�ation du bouton
    btnPath.setPreferredSize(new Dimension(200, 25)); // On lui donne une taille
    btnPath.setText("Show path"); // On lui donne un texte
    btnPath.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnPath); // On l'ajoute � la fen�tre

    oneState =
        new JComboBox(listOneState); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    oneState.setPreferredSize(new Dimension(140, 25)); // On lui donne une taille
    container.add(oneState); // on l'ajoute � la fen�tre

    twoStates =
        new JComboBox(listTwoStates); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    twoStates.setPreferredSize(new Dimension(140, 25)); // On lui donne une taille
    container.add(twoStates); // on l'ajoute � la fen�tre

    btnCycle = new JButton(); // Cr�ation du bouton
    btnCycle.setPreferredSize(new Dimension(300, 25)); // On lui donne une taille
    btnCycle.setText("Show cycle"); // On lui donne un texte
    btnCycle.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnCycle); // On l'ajoute � la fen�tre

    cyclesBox =
        new JComboBox(listCycles); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    cyclesBox.setPreferredSize(new Dimension(120, 25)); // On lui donne une taille
    container.add(cyclesBox); // on l'ajoute � la fen�tre

    btnReset = new JButton(); // Cr�ation du bouton
    btnReset.setPreferredSize(new Dimension(400, 25)); // On lui donne une taille
    btnReset.setText("Clear"); // On lui donne un texte
    btnReset.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnReset); // On l'ajoute � la fen�tre

    return container;
  }
コード例 #27
0
ファイル: DescriptionBox.java プロジェクト: noikiy/owaspbwa
  /*
   * (non-Javadoc)
   *
   * @see br.arca.morcego.Component#paint(java.awt.Graphics)
   */
  public void paint(Graphics g) {
    // TODO: paint a fancy textbox with description of node

    Graphics2D graphic = (Graphics2D) g;

    TextArea textArea = new TextArea(text);

    textArea.setLocation(0, 0);
    textArea.setVisible(true);

    Font font = new Font(null, Font.PLAIN, 10);

    FontRenderContext frc = new FontRenderContext(null, false, false);

    TextLayout l = new TextLayout(text, font, frc);

    Rectangle2D textBounds = l.getBounds();

    int margin = Config.getInteger(Config.descriptionMargin);
    int border = 1;
    int distX = 5;
    int distY = 5;

    int width = (int) textBounds.getWidth() + 2 * margin + 2 * border;
    int height = (int) textBounds.getHeight() + 2 * margin + 2 * border;

    int cornerX = originX - width - distX;
    int cornerY = originY - height - distY;

    if (cornerX < 0) {
      cornerX = 0;
    }
    if (cornerY < 0) {
      cornerY = 0;
    }

    graphic.setColor(Config.getColor(Config.descriptionBorder));
    graphic.fillRect(
        cornerX - margin - border,
        cornerY - margin - border,
        (int) textBounds.getWidth() + 2 * margin + 2 * border,
        (int) textBounds.getHeight() + 2 * margin + 2 * border);

    graphic.setColor(Config.getColor(Config.descriptionBackground));

    graphic.fillRect(
        cornerX - margin,
        cornerY - margin,
        (int) textBounds.getWidth() + 2 * margin,
        (int) textBounds.getHeight() + 2 * margin);

    graphic.setColor(Config.getColor(Config.descriptionColor));
    textArea.paint(g);

    l.draw(graphic, cornerX, cornerY + (int) textBounds.getHeight());
  }
コード例 #28
0
 // --------------------------------------------------
 public void close() {
   try {
     is.close();
     os.close();
     socket.close();
     responseArea.appendText("***Connection closed" + "\n");
   } catch (IOException e) {
     responseArea.appendText("IO Exception" + "\n");
   }
 }
コード例 #29
0
 // --------------------------------------------------
 public void run() {
   String inputLine;
   try {
     while ((inputLine = is.readLine()) != null) {
       responseArea.appendText(inputLine + "\n");
     }
   } catch (IOException e) {
     responseArea.appendText("IO Exception" + "\n");
   }
 }
コード例 #30
0
  /** Returns the output text area. */
  private TextArea getOutput() {
    if (output == null) {
      output = new TextArea(6, 100);
      output.append("Output Goes Here...");
      output.setPreferredSize(new Dimension(580, 120));
      output.setEditable(false);
    }

    return output;
  }