Пример #1
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);
    }
  }
Пример #2
0
  public void setEdge(Edge edge_in, Graph graph_in) {
    graph_ = graph_in;
    edge_ = edge_in;
    //  if(edge_ == null)
    //     edge_ = Edge.defaults;

    String title;
    //  if(edge_ == Edge.defaults)
    //     title = "Properties For Newly Created Edges";
    //  else
    title = "Edge " + edge_.tail().id_ + " " + edge_.head().id_;

    setTitle(title);

    style_.select(edge_.getLineStyle());

    //   if(edge_ != Edge.defaults)
    //   {
    labelText_.setText(edge_.getLabel());
    String points_string = new String();
    DPoint3[] points = edge_.points();
    for (int i = 0; i < points.length; i++)
      points_string += points[i].x + " " + points[i].y + " " + points[i].z + "\n";
    pointsText_.setText(points_string);

    // Can't remove items from a Choice in Java 1.0.
    dataPanel_.remove(data_);
    data_ = new Choice();
    dataPanel_.add(data_);
    dataHash_ = (Hashtable) edge_.data_.clone();
    data_.addItem("<NEW>");
    for (Enumeration keys = dataHash_.keys(); keys.hasMoreElements(); ) {
      String key = (String) keys.nextElement();
      data_.addItem(key);
    }
    if (data_.countItems() == 1) // Need at least one item.
    data_.addItem("Data");
    data_.select(1);
    currentData_ = data_.getItem(1);

    String value = (String) dataHash_.get(currentData_);
    if (value == null) value = new String("");
    dataText_.setText(value);

    for (int i = 0; i < ndCount_; i++) notDefault_[i].show();
    //  }
    //  else
    //     for(int i = 0; i < ndCount_; i++)
    //        notDefault_[i].hide();

    pack();
  }
  /**
   * Method declaration
   *
   * @param s
   * @param help
   */
  void showHelp(String help[]) {

    txtCommand.setText(help[0]);
    txtResult.setText(help[1]);

    bHelp = true;

    pResult.removeAll();
    pResult.add("Center", txtResult);
    pResult.doLayout();
    txtCommand.requestFocus();
    txtCommand.setCaretPosition(help[0].length());
  }
Пример #4
0
  public void actionPerformed(ActionEvent e) {

    chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File("C:\\Program Files (x86)\\Tango04\\Dashboards\\Web"));
    chooser.setDialogTitle("Browse...");
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);

    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      textArea.setText("");
      new Exportator().startExporting(chooser.getSelectedFile().getPath(), textArea);
    } else {
      textArea.setText("No Selection");
    }
  }
Пример #5
0
 void setCutText(String text) {
   selection = text;
   textArea.setText(text);
   if (isVisible()) {
     textArea.selectAll();
   }
 }
Пример #6
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
 }
Пример #7
0
 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);
   }
 }
Пример #8
0
 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());
   }
 }
Пример #9
0
  public boolean handleEvent(Event event) {
    // Avoid having everything destroyed.
    if (event.target instanceof InputDialog) {
      String label = (String) event.arg;

      for (int i = 0; i < label.length(); i++) {
        char chr = label.charAt(i);
        if (!(chr >= 'a' && chr <= 'z')
            && !(chr >= 'A' && chr <= 'Z')
            && !(i != 0 && chr >= '0' && chr <= '9')) {
          new MessageDialog(frame_, "Error", "Bad format for new data item name.", true);
          return true;
        }
      }

      data_.addItem(label);
      data_.select(data_.countItems() - 1);
      currentData_ = label;
      dataText_.setText("");
      return true;
    }

    if (event.id == Event.WINDOW_DESTROY) {
      hide();
      return true;
    }
    return super.handleEvent(event);
  }
Пример #10
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;
  }
Пример #11
0
  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);
  }
Пример #12
0
 public void actionPerformed(ActionEvent evt) {
   if (evt.getSource() == clearButton) {
     textArea.setText("");
   } else if (evt.getSource() == closeButton) {
     setVisible(false);
   }
 }
Пример #13
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()
Пример #14
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());
 }
 {
   StringBuffer sb = new StringBuffer();
   StringTokenizer st = new StringTokenizer(cfg.REQPARAM_CONTACT_LIST_LOGIN_IDS, ",");
   while (st.hasMoreTokens()) {
     sb.append(st.nextToken());
     if (st.hasMoreTokens()) sb.append("\n");
   }
   contactList.setText(sb.toString());
 }
Пример #16
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());
 }
Пример #17
0
  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;
  }
Пример #18
0
 /*
  * Test method for 'java.awt.TextArea.insertText(String, int)'
  */
 @SuppressWarnings("deprecation")
 public void testInsertText() {
   String text = "text";
   area.setText(text);
   String str = "inserted text\n";
   area.insertText(str, 0);
   assertEquals(str + text, area.getText());
   assertEquals(0, area.getColumns());
   assertEquals(0, area.getCaretPosition());
 }
Пример #19
0
  /*
   * Test method for 'java.awt.TextArea.append(String)'
   */
  public void testAppend() {
    String text = "text";
    area.setText(text);
    String str = "\nappended text";

    area.append(str);
    assertEquals(text + str, area.getText());
    assertEquals(0, area.getRows());
    assertEquals(0, area.getCaretPosition());
  }
Пример #20
0
 /*
  * Test method for 'java.awt.TextArea.replaceText(String, int, int)'
  */
 @SuppressWarnings("deprecation")
 public void testReplaceText() {
   String text = "This is old text";
   area.setText(text);
   String str = "new\n";
   area.replaceText(str, 8, 12);
   assertEquals("This is new\ntext", area.getText());
   assertEquals(0, area.getColumns());
   assertEquals(0, area.getCaretPosition());
 }
Пример #21
0
 /*
  * Test method for 'java.awt.TextArea.replaceRange(String, int, int)'
  */
 public void testReplaceRange() {
   int start = 8;
   int end = 11;
   String text = "This is old text";
   area.setText(text);
   String str = "brand new";
   area.replaceRange(str, start, end);
   assertEquals("This is brand new text", area.getText());
   assertEquals("", area.getSelectedText());
   assertEquals(0, area.getRows());
   assertEquals(0, area.getCaretPosition());
 }
Пример #22
0
  /**
   * This method uses JEP's getValueAsObject() method to obtain the current value of the expression
   * entered.
   */
  private void updateResult() {
    Object result;
    String errorInfo;

    // Get the value
    result = myParser.getValueAsObject();

    // Is the result ok?
    if (result != null) {
      resultLabel.setText(result.toString());
    } else {
      resultLabel.setText("");
    }

    // Get the error information
    if ((errorInfo = myParser.getErrorInfo()) != null) {
      errorTextArea.setText(errorInfo);
    } else {
      errorTextArea.setText("");
    }
  }
Пример #23
0
  @Override
  public void actionPerformed(ActionEvent arg0) {
    // TODO Auto-generated method stub

    int n1, n2;
    n1 = Integer.parseInt(t1.getText());
    n2 = Integer.parseInt(t2.getText());

    String ans = "";
    for (int i = n1; i <= n2; i++) {
      ans += i + " , ";
    }
    txtAns.setText(ans);
  }
Пример #24
0
  /**
   * opens the chosen file, reads in the file, and prints out a receipt
   *
   * @param chosenFile
   */
  private void readSource(File chosenFile) {
    String chosenFileName = chosenFile.getName();
    TextFileInput inFile = new TextFileInput(chosenFileName);
    Container myContentPane = jframe.getContentPane();
    // chosenFile TextArea myTextArea = new TextArea();
    myContentPane.add(myTextArea);

    int count = 0;
    float priceTotal = 0.0f;
    Database db = new Database("database2.txt");
    String[] transaction = new String[100];
    String line = inFile.readLine();
    DecimalFormat df = new DecimalFormat("#00.00");
    while (line != null) {
      StringTokenizer tokenized = new StringTokenizer(line, ",");
      String code = tokenized.nextToken();
      float weight = Float.parseFloat(tokenized.nextToken());
      String name;
      float price;

      try {
        name = db.getName(code);

      } catch (ItemNotFoundException e) {
        name = JOptionPane.showInputDialog(null, "Item " + code + " not found. Enter Name: ");
      }
      try {
        price = db.getPrice(code);
      } catch (ItemNotFoundException e) {
        price =
            Float.valueOf(
                JOptionPane.showInputDialog(
                    null, "Price for " + name + " not found. Enter price: "));
      }
      float itemTotal = weight * price;
      priceTotal += itemTotal;
      transaction[count] =
          name + "\t" + price + "\t" + df.format(weight) + "\t $" + df.format(itemTotal);
      count++;
      line = inFile.readLine();
    } // while
    myTextArea.setText("ITEM: \t PRICE\\LB: \t POUNDS: \t TOTAL:");
    myTextArea.append("\n");
    for (int i = 0; i < count; i++) {
      myTextArea.append(transaction[i]);
      myTextArea.append("\n");
    }
    myTextArea.append("\t\t   TOTAL: $" + df.format(priceTotal));
    jframe.setVisible(true);
  } // openFile
 String[] getContactList() {
   java.util.List cl = new java.util.LinkedList();
   StringTokenizer st = new StringTokenizer(contactList.getText());
   StringBuffer sb = new StringBuffer();
   StringBuffer dbg = new StringBuffer("test applet contactlist: ");
   while (st.hasMoreTokens()) {
     String loginId = st.nextToken().trim();
     if (loginId.length() == 0) continue;
     dbg.append("'" + loginId + "' ");
     cl.add(loginId);
     sb.append(loginId).append('\n');
   }
   CAT.info(dbg.toString());
   contactList.setText(sb.toString());
   return (String[]) cl.toArray(new String[cl.size()]);
 }
  /** Method declaration */
  void insertTestData() {

    try {
      DatabaseManagerCommon.createTestTables(sStatement);
      refreshTree();
      txtCommand.setText(DatabaseManagerCommon.createTestData(sStatement));
      refreshTree();

      for (int i = 0; i < DatabaseManagerCommon.testDataSql.length; i++) {
        addToRecent(DatabaseManagerCommon.testDataSql[i]);
      }

      execute();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Пример #27
0
  public memoDialog(Frame fr, Field f) {
    super(fr, f.getName(), true);
    addWindowListener(this);
    f1 = f;

    text.setText(f1.get());
    this.add("Center", text);

    Panel p = new Panel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15));
    p.add(Okay);
    Okay.addActionListener(this);
    this.add("East", p);
    p.add(Cancel);
    Cancel.addActionListener(this);
    this.add("West", p);
    this.pack();
  }
Пример #28
0
 // Item Listener stuff
 public void showMessages(ItemEvent e) {
   int index = 0;
   if (e != null) index = ((Integer) e.getItem()).intValue();
   allmessagesTextArea.setText("");
   TracesSession tS = tracesSessions.elementAt(index);
   for (int i = 0; i < tS.size(); i++) {
     TracesMessage tM = tS.elementAt(i);
     // allmessagesTextArea.setForeground(Color.red);
     // allmessagesTextArea.setFont(new Font ("Dialog", 1, 18));
     allmessagesTextArea.append(
         "Message " + (i + 1) + " from " + tM.getFrom() + " to " + tM.getTo());
     allmessagesTextArea.append("\n\n");
     // allmessagesTextArea.setForeground(Color.black);
     // allmessagesTextArea.setFont(new Font ("Dialog", 1, 14));
     allmessagesTextArea.append(tM.getMessageString());
     allmessagesTextArea.append("\n");
   }
   allmessagesTextArea.select(0, 0);
 }
Пример #29
0
  @Override
  public void run() {

    TextArea textArea = new TextArea(toString());
    textArea.setBackground(Color.BLACK);
    textArea.setForeground(Color.WHITE);

    JFrame janela = new JFrame("JACAS");
    janela.add(textArea);
    janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    janela.setSize(
        new Dimension(new Double(362 * 2.3).intValue(), new Double(373 * 2.3).intValue()));
    janela.setVisible(true);

    while (true) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      textArea.setText(toString());
    }
  }
Пример #30
0
  public static void main(String[] args) {

    Frame AFrame = new Frame("Frame with components");

    Label lblOne = new Label("This is a label");
    Button btn1 = new Button("This is a button");
    TextField tf1 = new TextField();
    TextArea ta1 = new TextArea(12, 40);

    tf1.setText("This is a textbox");
    ta1.setText("Number of columns in this textarea: " + ta1.getColumns());

    // the add() method of the Frame class is
    // used to add components to the frame
    AFrame.add(lblOne);
    AFrame.add(btn1);
    AFrame.add(tf1);
    AFrame.add(ta1);

    AFrame.setSize(450, 300);
    AFrame.setLayout(new FlowLayout());
    AFrame.setVisible(true);
    AFrame.addWindowListener(new demo());
  }