/** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user changed the service filter option
   if (e.getSource() == service_box) {
     service_list.setEnabled(service_box.isSelected());
     service_list.clearSelection();
     remove_service_button.setEnabled(false);
     add_service_field.setEnabled(service_box.isSelected());
     add_service_field.setText("");
     add_service_button.setEnabled(false);
   }
   // Check if the user pressed the add service button
   if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) {
     String text = add_service_field.getText();
     if ((text != null) && (text.length() > 0)) {
       service_data.addElement(text);
       service_list.setListData(service_data);
     }
     add_service_field.setText("");
     add_service_field.requestFocus();
   }
   // Check if the user pressed the remove service button
   if (e.getSource() == remove_service_button) {
     Object[] sels = service_list.getSelectedValues();
     for (int i = 0; i < sels.length; i++) {
       service_data.removeElement(sels[i]);
     }
     service_list.setListData(service_data);
     service_list.clearSelection();
   }
 }
Exemplo n.º 2
0
  void handleScanFiles(JTextField field, String[] extensions) {
    String[] dataFiles = scanDataFolderForFilesByType(extensions);
    if (dataFiles == null || dataFiles.length == 0) return;

    String[] oldFileList = field.getText().trim().split(",");
    ArrayList<String> newFileList = new ArrayList<String>();
    for (String c : oldFileList) {
      c = c.trim();
      if (!c.equals("") && newFileList.indexOf(c) == -1) // TODO check exists() here?
      {
        newFileList.add(c);
      }
    }
    for (String c : dataFiles) {
      c = c.trim();
      if (!c.equals("") && newFileList.indexOf(c) == -1) {
        newFileList.add(c);
      }
    }
    Collections.sort(newFileList);
    String finalFileList = "";
    int i = 0;
    for (String s : newFileList) {
      finalFileList += (i > 0 ? ", " : "") + s;
      i++;
    }
    field.setText(finalFileList);
  }
Exemplo n.º 3
0
  public void save() {
    for (String key : fields.keySet()) {
      JComponent comp = fields.get(key);

      if (comp instanceof JTextField) {
        JTextField c = (JTextField) comp;

        if (c.getText().trim().equals("")) {
          sketch.configFile.unset(key);
        } else {
          sketch.configFile.set(key, c.getText());
        }
      } else if (comp instanceof JTextArea) {
        JTextArea c = (JTextArea) comp;

        if (c.getText().trim().equals("")) {
          sketch.configFile.unset(key);
        } else {
          sketch.configFile.set(key, c.getText());
        }
      }
    }

    sketch.saveConfig();
  }
Exemplo n.º 4
0
  private void setupInputListeners(final JTextField currentInput) {
    currentInput.addKeyListener(
        new KeyAdapter() {
          // Plot the graph.

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER && currentInput.isFocusOwner()) {
              try {
                String[] equations = new String[nInputs];
                for (int i = 0; i < nInputs; i++) {
                  equations[i] = input[i].getText();
                }
                addPlot(
                    equations,
                    templateFunc.getColor(),
                    gridOP.getGridBounds(),
                    gridOP.getGridStepSize());
              } catch (IllegalExpressionException e1) {
                signalAll(new ActionEvent(e1, -1, ""));
              }
            }
          }
        });
    currentInput.addFocusListener(
        new FocusAdapter() {

          @Override
          public void focusGained(FocusEvent arg0) {
            setSelected(templateFunc);
          }
        });
  }
 private boolean readyToClose() {
   File f;
   if (newFile.isSelected()) {
     if (newNameTf.getText().isEmpty()) {
       if (tableModel.getRowCount() > 0) {
         JOptionPane.showMessageDialog(
             this,
             Localization.lang("You must choose a filename to store journal abbreviations"),
             Localization.lang("Store journal abbreviations"),
             JOptionPane.ERROR_MESSAGE);
         return false;
       } else {
         return true;
       }
     } else {
       f = new File(newNameTf.getText());
       return !f.exists()
           || (JOptionPane.showConfirmDialog(
                   this,
                   Localization.lang("'%0' exists. Overwrite file?", f.getName()),
                   Localization.lang("Store journal abbreviations"),
                   JOptionPane.OK_CANCEL_OPTION)
               == JOptionPane.OK_OPTION);
     }
   }
   return true;
 }
 // Clear text fields
 public void returnToRental() {
   idTextField.setText("");
   quantityTextField.setText("");
   dateTextField.setText("MM/DD/YYYY");
   totalItems.setText("");
   totalCost.setText("");
 }
 private void loadFloor() {
   if (currentFloor == null) return;
   isLoading = true;
   blendingCheckbox.setSelected(currentFloor.occlude);
   switch (previewBox.getMode()) {
     case RT3_GAME:
       gameColour.setColour(currentFloor.colour2);
       gameTexture.setValue(currentFloor.texture);
       gameName.setText(currentFloor.name);
       break;
     case RT3_MAP:
       gameColour.setColour(currentFloor.minimapColour);
       gameTexture.setValue(currentFloor.texture);
       gameName.setText(currentFloor.name);
       break;
     case RT4P_OVERLAY:
       gameColour.setColour(currentFloor.hdColour);
       gameTexture.setValue(currentFloor.hdTexture);
       // gameName.setText(currentFloor.name);
       break;
     case RT4P_UNDERLAY:
       gameColour.setColour(currentFloor.hdUlColour);
       gameTexture.setValue(currentFloor.hdUlTexture);
       // gameName.setText(currentFloor.name);
       break;
   }
   isLoading = false;
   previewBox.repaint();
 }
Exemplo n.º 8
0
  void applyDirectives() {
    findRemoveDirectives(true);

    StringBuffer buffer = new StringBuffer();
    String head = "", toe = "; \n";

    if (crispBox.isSelected()) buffer.append(head + "crisp=true" + toe);
    if (!fontField.getText().trim().equals(""))
      buffer.append(head + "font=\"" + fontField.getText().trim() + "\"" + toe);
    if (globalKeyEventsBox.isSelected()) buffer.append(head + "globalKeyEvents=true" + toe);
    if (pauseOnBlurBox.isSelected()) buffer.append(head + "pauseOnBlur=true" + toe);
    if (!preloadField.getText().trim().equals(""))
      buffer.append(head + "preload=\"" + preloadField.getText().trim() + "\"" + toe);
    /*if ( transparentBox.isSelected() )
    buffer.append( head + "transparent=true" + toe );*/

    Sketch sketch = editor.getSketch();
    SketchCode code = sketch.getCode(0); // first tab
    if (buffer.length() > 0) {
      code.setProgram("/* @pjs " + buffer.toString() + " */\n\n" + code.getProgram());
      if (sketch.getCurrentCode() == code) // update textarea if on first tab
      {
        editor.setText(sketch.getCurrentCode().getProgram());
        editor.setSelection(0, 0);
      }

      sketch.setModified(false);
      sketch.setModified(true);
    }
  }
Exemplo n.º 9
0
  @Override
  public void keyPressed(KeyEvent e) {
    // frm.repaint();
    strgr = txter.getText();
    taken = strgr.length();

    chl = strgr.charAt(taken - 1);
    // strgr = "";
    txter.setText(strgr);
    if (chl == 'a') {
      my_car.row -= 10;
      System.out.println(my_car.row);
    }
    if (chl == 'd') {
      my_car.row += 10;
      System.out.println(my_car.row);
    }
    if (chl == 'w') {
      my_car.col -= 10;
      System.out.println(my_car.col);
    }
    if (chl == 's') {
      my_car.col += 10;
      System.out.println(my_car.col);
    }
    System.out.println(chl);
  }
  /** Loads the default settings from Preferences to set up the dialog. */
  public void legacyLoadDefaults() {
    String defaultsString = Preferences.getDialogDefaults(getDialogName());

    if ((defaultsString != null) && (newImage != null)) {

      try {
        StringTokenizer st = new StringTokenizer(defaultsString, ",");

        textSearchWindowSide.setText("" + MipavUtil.getInt(st));
        textSimilarityWindowSide.setText("" + MipavUtil.getInt(st));
        textNoiseStandardDeviation.setText("" + MipavUtil.getFloat(st));
        textDegree.setText("" + MipavUtil.getFloat(st));
        doRician = MipavUtil.getBoolean(st);
        doRicianCheckBox.setSelected(doRician);
        textDegree.setEnabled(doRician);
        labelDegree.setEnabled(doRician);
        image25DCheckBox.setSelected(MipavUtil.getBoolean(st));

        if (MipavUtil.getBoolean(st)) {
          newImage.setSelected(true);
        } else {
          replaceImage.setSelected(true);
        }

      } catch (Exception ex) {

        // since there was a problem parsing the defaults string, start over with the original
        // defaults
        Preferences.debug("Resetting defaults for dialog: " + getDialogName());
        Preferences.removeProperty(getDialogName());
      }
    }
  }
Exemplo n.º 11
0
 private void sendRequest(BlockPdu pdu) {
   setButton.setEnabled(false);
   getButton.setEnabled(false);
   getNextButton.setEnabled(false);
   lmessage.setText("Sending request ..");
   lmessage.setBackground(Color.white);
   try {
     varbind var = pdu.getResponseVariableBinding();
     AsnObjectId oid = var.getOid();
     AsnObject res = var.getValue();
     if (res != null) {
       toid.setText(oid.toString());
       tvalue.setText(res.toString());
       lmessage.setText("Received aswer ");
       lmessage.setBackground(Color.white);
     } else {
       lmessage.setText("Received no aswer ");
       lmessage.setBackground(Color.red);
     }
   } catch (PduException exc) {
     lmessage.setText("PduException: " + exc.getMessage());
     lmessage.setBackground(Color.red);
     exc.printStackTrace();
   } catch (java.io.IOException exc) {
     lmessage.setText("IOException: " + exc.getMessage());
     lmessage.setBackground(Color.red);
     exc.printStackTrace();
   }
   setButton.setEnabled(true);
   getButton.setEnabled(true);
   getNextButton.setEnabled(true);
 }
Exemplo n.º 12
0
  public void actionPerformed(ActionEvent evt) {
    Object src = evt.getSource();

    try {
      if (src == propDialog) {
        propDialog_actionPerformed(evt);
      } else {
        pdu = new BlockPdu(context);
        if (src == setButton) {
          pdu.setPduType(BlockPdu.SET);
          pdu.addOid(toid.getText(), new AsnOctets(tvalue.getText()));
        } else if (src == getButton) {
          pdu.setPduType(BlockPdu.GET);
          pdu.addOid(toid.getText());
        } else if (src == getNextButton) {
          pdu.setPduType(BlockPdu.GETNEXT);
          pdu.addOid(toid.getText());
        }
        sendRequest(pdu);
      }
    } catch (Exception exc) {
      exc.printStackTrace();
      lmessage.setText("Exception: " + exc.getMessage());
      lmessage.setBackground(Color.red);
    }
  }
Exemplo n.º 13
0
 public void clrFields() {
   tfClave.setText("");
   tfNombre.setText("");
   tfExistencia.setText("");
   tfMarca.setText("");
   tfPrecio.setText("");
 }
Exemplo n.º 14
0
  // ボタンが押されたときのイベント処理
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd.equals("submit")) { // 送信
      sendMessage("msg " + msgTextField.getText());
      msgTextField.setText("");
    } else if (cmd.equals("rename")) { // 名前の変更
      sendMessage("setName " + nameTextField.getText());
    } else if (cmd.equals("addRoom")) { // 部屋を作成
      String roomName = nameTextField.getText();
      sendMessage("addRoom " + roomName);
      enteredRoom(roomName);
      sendMessage("getUsers " + roomName);
    } else if (cmd.equals("enterRoom")) { // 入室
      Object room = roomList.getSelectedValue();
      if (room != null) {
        String roomName = room.toString();
        sendMessage("enterRoom " + roomName);
        enteredRoom(roomName);
      }
    } else if (cmd.equals("exitRoom")) { // 退室
      sendMessage("exitRoom " + roomName);
      exitedRoom();
    }
  }
Exemplo n.º 15
0
  /** Creates new form SIPHeadersParametersFrame */
  public StackPanel(ConfigurationFrame configurationFrame, ProxyLauncher proxyLauncher) {
    super();
    this.parent = configurationFrame;
    this.proxyLauncher = proxyLauncher;

    listeningPointsList = new ListeningPointsList(proxyLauncher);

    initComponents();

    // Init the components input:
    try {
      Configuration configuration = proxyLauncher.getConfiguration();
      if (configuration == null) return;
      if (configuration.stackName != null) proxyStackNameTextField.setText(configuration.stackName);
      if (configuration.stackIPAddress != null)
        proxyIPAddressTextField.setText(configuration.stackIPAddress);

      if (configuration.outboundProxy != null)
        outboundProxyTextField.setText(configuration.outboundProxy);
      if (configuration.routerPath != null) routerClassTextField.setText(configuration.routerPath);
      if (configuration == null) listeningPointsList.displayList(new Hashtable());
      else listeningPointsList.displayList(configuration.listeningPoints);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * Closes dialog box when the OK button is pressed, sets variables and calls algorithm.
   *
   * @param event Event that triggers function.
   */
  public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    Object source = event.getSource();

    if (command.equals("OK")) {

      if (setVariables()) {
        callAlgorithm();
      }
    } else if (command.equals("Cancel")) {
      dispose();
    } else if (command.equals("Help")) {
      // MipavUtil.showHelp("");
    } else if (source.equals(doRicianCheckBox)) {
      if (doRicianCheckBox.isSelected()) {
        labelDegree.setEnabled(true);
        textDegree.setEnabled(true);
      } else {
        labelDegree.setEnabled(false);
        textDegree.setEnabled(false);
      }
    } else { // else if (source == thresholdCheckbox)
      super.actionPerformed(event);
    }
  }
Exemplo n.º 17
0
    public boolean stopCellEditing() {
      Object descrip = null, costo = null;
      JTextField campo = ((JTextField) this.getComponent());
      String codigo = campo.getText();
      if (codigo == "") {
        return false;
      }
      descrip =
          Almacenes.groovyPort(
              "omoikane.principal.Articulos.getArticulo('codigo = \""
                  + codigo
                  + "\"').descripcion");
      costo =
          Almacenes.groovyPort(
              "omoikane.principal.Articulos.getArticulo('select * from articulos,precios where articulos.codigo = \""
                  + codigo
                  + "\" "
                  + "and articulos.id_articulo = precios.id_articulo and precios.id_almacen = '+omoikane.principal.Principal.config.idAlmacen[0].text()).costo");

      if (descrip == null) {
        Dialogos.lanzarAlerta("El artículo que capturó no exíste");
        campo.setText("");
        return false;
      } else {
        tablaPrincipal.setValueAt(
            descrip, tablaPrincipal.getEditingRow(), tablaPrincipal.getEditingColumn() + 1);
        tablaPrincipal.setValueAt(
            costo, tablaPrincipal.getEditingRow(), tablaPrincipal.getEditingColumn() + 2);
        return super.stopCellEditing();
      }
    }
Exemplo n.º 18
0
 public void syncPanel() {
   panelPat.syncPanel();
   regionAButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.A);
   regionBButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.B);
   regionCButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.C);
   elevBox.setText(dlg.panelMain.mark.getElevation());
   heightBox.setText(dlg.panelMain.mark.getObjectHeight());
   sourceBox.setText(dlg.panelMain.mark.getSource());
   infoBox.setText(dlg.panelMain.mark.getInfo());
   for (Sts sts : statuses.keySet()) {
     int item = statuses.get(sts);
     if (dlg.panelMain.mark.getStatus() == sts) statusBox.setSelectedIndex(item);
   }
   for (Cns cns : constructions.keySet()) {
     int item = constructions.get(cns);
     if (dlg.panelMain.mark.getConstr() == cns) constrBox.setSelectedIndex(item);
   }
   for (Con con : conspicuities.keySet()) {
     int item = conspicuities.get(con);
     if (dlg.panelMain.mark.getConsp() == con) conBox.setSelectedIndex(item);
   }
   for (Con con : reflectivities.keySet()) {
     int item = reflectivities.get(con);
     if (dlg.panelMain.mark.getRefl() == con) reflBox.setSelectedIndex(item);
   }
 }
Exemplo n.º 19
0
  private String consultar(
      String elemento) // Se busca si existe y manda el resultado (Nombre o Clave)
      {
    boolean vacia = lista.vacia();

    if (elemento.equals("MARCA")) {
      marca = tfMarca.getText();

      if (marca.equals("")) resultado = "MARCA_VACIA";
      if (vacia == true) resultado = "LISTA_VACIA";

      if ((!marca.equals("")) && (vacia == false)) resultado = lista.consultarMarca(marca);
    }

    if (elemento.equals("CLAVE")) {
      clave = tfClave.getText();

      if (clave.equals("")) resultado = "CLAVE_VACIA";
      if (vacia == true) resultado = "LISTA_VACIA";

      if ((!clave.equals("")) && (vacia == false)) resultado = lista.consultarClave(clave);
    }

    if (elemento.equals("CLAVE_CAPTURAR")) {
      clave = tfClave.getText();
      resultado = lista.consultarClave(clave);
      if (resultado.equals("LISTA_VACIA")) resultado = "CLAVE_NO_ENCONTRADA";
    }

    return resultado;
  }
Exemplo n.º 20
0
  @Override
  public void actionPerformed(ActionEvent arg0) {
    // Pre-creation sanity
    if (gridPanel != null) {
      // Variable declaration
      String name, phone;
      // Make sure the fields have values
      if ((name = nameField.getText()) == "") {
        // Tell the user if not
        JOptionPane.showMessageDialog(null, "Please enter the client's name");
        return;
      }

      if ((phone = phoneField.getText()) == "") {
        JOptionPane.showMessageDialog(null, "Please enter the client's phone number");
        return;
      }

      if (hiddenRadio.isSelected()) {
        JOptionPane.showMessageDialog(null, "Please select the client's smoking preference");
        return;
      }

      // Calculate the party size
      int partySize = partyBox.getSelectedIndex() + 8;

      // Place the reservation
      bookRoom(name, phone, smokingRadio.isSelected(), partySize);
    } else {
      System.out.println("Grid panel is null");
    }
  }
Exemplo n.º 21
0
 public void habilitarCampos(boolean value) {
   tfClave.setEnabled(value);
   tfMarca.setEnabled(value);
   tfNombre.setEnabled(value);
   tfExistencia.setEnabled(value);
   tfPrecio.setEnabled(value);
 }
Exemplo n.º 22
0
  private void realizarVenta() {
    boolean cantidadCorrecta = false;
    String str = "",
        strError =
            "Debes introducir una cantidad válida. Recuerda : \n 1) Sólo debes introducir números enteros; positivos \n 2) Debes dejar a lo más cero artículos en 'stock'";
    String strExistencia = tfExistencia.getText(), clave = "";
    int cantidad = 0;
    int existencia = Integer.parseInt(strExistencia);

    while (cantidadCorrecta == false) {
      str = JOptionPane.showInputDialog(null, "Cantidad a Vender = ");
      try {
        cantidad = Integer.parseInt(str);
        if ((cantidad < 0) || (cantidad > existencia))
          JOptionPane.showMessageDialog(null, strError);
        else {
          cantidadCorrecta = true;
          clave = tfClave.getText();
          resultado = lista.venderArticulos(cantidad, existencia);
          habilitarCampos(true);
          habilitarBotones(true);
          print(resultado);
        }
      } catch (NumberFormatException nfe) {
        System.out.println("Error: " + nfe);
        JOptionPane.showMessageDialog(null, strError);
      }
    }
  }
Exemplo n.º 23
0
  /**
   * Call this to set a custom gradle executor. We'll enable all fields appropriately and setup the
   * foundation settings. We'll also fire off a refresh.
   *
   * @param file the file to use as a custom executor. Null not to use one.
   */
  private void setCustomGradleExecutor(File file) {
    String storagePath;
    boolean isUsingCustom = false;
    if (file == null) {
      isUsingCustom = false;
      storagePath = null;
    } else {
      isUsingCustom = true;
      storagePath = file.getAbsolutePath();
    }

    // set the executor in the foundation
    if (gradlePluginLord.setCustomGradleExecutor(file)) {
      // refresh the tasks only if we actually changed the executor
      gradlePluginLord.addRefreshRequestToQueue();
    }

    // set the UI values
    useCustomGradleExecutorCheckBox.setSelected(isUsingCustom);
    customGradleExecutorField.setText(storagePath);

    // enable the UI appropriately.
    browseForCustomGradleExecutorButton.setEnabled(isUsingCustom);
    customGradleExecutorField.setEnabled(isUsingCustom);

    // store the settings
    settingsNode.setValueOfChild(CUSTOM_GRADLE_EXECUTOR, storagePath);
  }
Exemplo n.º 24
0
    public void actionPerformed(ActionEvent e) {
      JTextField tf = getTextField();
      final String text = tf.getText();
      final int caretIndex = tf.getCaretPosition();
      String pre = text.substring(0, caretIndex);
      java.util.List<TreeNode> nodes = null; // m_root.search(pre);
      // Collections.sort(nodes);
      if (nodes.isEmpty()) {
        return;
      }

      JPopupMenu jp = new JPopupMenu("options");

      JMenuItem lastItem = null;
      for (TreeNode node : nodes) {
        String nodeName = node.toString();
        String insertion = nodeName.substring(leaf(pre, ".").length());
        lastItem = createInsertAction(nodeName, caretIndex, insertion);
        jp.add(lastItem);
      }
      if (nodes.size() == 0) {
        return;
      }
      if (nodes.size() == 1) {
        lastItem.getAction().actionPerformed(null);
      } else {
        Point pos = tf.getCaret().getMagicCaretPosition();
        pos = pos != null ? pos : new Point(2, 2);
        jp.show(tf, pos.x, pos.y);
      }
    }
Exemplo n.º 25
0
  private Component createCurrentDirectoryPanel() {
    currentDirectoryTextField = new JTextField();
    currentDirectoryTextField.setEditable(false);

    String currentDirectory = settingsNode.getValueOfChild(CURRENT_DIRECTORY, null);
    if (currentDirectory == null || "".equals(currentDirectory.trim())) {
      currentDirectory = gradlePluginLord.getCurrentDirectory().getAbsolutePath();
    }

    currentDirectoryTextField.setText(currentDirectory);
    gradlePluginLord.setCurrentDirectory(new File(currentDirectory));

    JButton browseButton =
        new JButton(
            new AbstractAction("Browse...") {
              public void actionPerformed(ActionEvent e) {
                File file = browseForDirectory(gradlePluginLord.getCurrentDirectory());
                if (file != null) {
                  setCurrentDirectory(file);
                }
              }
            });

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    panel.add(Utility.addLeftJustifiedComponent(new JLabel("Current Directory")));
    panel.add(createSideBySideComponent(currentDirectoryTextField, browseButton));

    return panel;
  }
Exemplo n.º 26
0
  /** @param frameName title name for frame */
  public ShowSavedResults(String frameName) {
    super(frameName);
    aboutRes =
        new JTextArea(
            "Select a result set from"
                + "\nthose listed and details"
                + "\nof that analysis will be"
                + "\nshown here. Then you can"
                + "\neither delete or view those"
                + "\nresults using the buttons below.");
    aboutScroll = new JScrollPane(aboutRes);
    ss = new JScrollPane(sp);
    ss.getViewport().setBackground(Color.white);

    //  resMenu.setLayout(new FlowLayout(FlowLayout.LEFT,10,1));
    ClassLoader cl = getClass().getClassLoader();
    rfii = new ImageIcon(cl.getResource("images/Refresh_button.gif"));

    // results status
    resButtonStatus = new JPanel(new BorderLayout());
    Border loweredbevel = BorderFactory.createLoweredBevelBorder();
    Border raisedbevel = BorderFactory.createRaisedBevelBorder();
    Border compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    statusField = new JTextField();
    statusField.setBorder(compound);
    statusField.setEditable(false);
  }
 public void actionPerformed(ActionEvent e) {
   Object jbX = e.getSource();
   if (jbX == jbReg) {
     String an = tfAutoNr.getText();
     if (rg.registruotiAuto(an)) rodytiAutoRinkinius();
     else
       JOptionPane.showMessageDialog(
           this,
           "Registracija neįvyko:\n" + "arba kartojasi auto numeris arba nėra neregistruotų");
   }
   if (jbX == jbRasti) {
     String pag = tfAutoNr.getText();
     Automobilis a = rg.regAuto.get(pag);
     pag += a == null ? " automobilis nerastas" : "=" + a;
     JOptionPane.showMessageDialog(this, pag);
   }
   if (jbX == jbSkaityti) {
     rg.neregAuto.clear();
     String ats = rg.skaitytiNeregAutos("ban.automoto");
     JOptionPane.showMessageDialog(this, ats);
     rodytiAutoRinkinius();
   }
   if (jbX == jbSaveObj) {
     saveObject(rg, "temp.obj");
   }
   if (jbX == jbLoadObj) {
     loadObject("temp.obj");
     rodytiAutoRinkinius();
   }
 }
Exemplo n.º 28
0
 /*
  *Creates the JTextField for the GUI.
  */
 private JTextField inputField() {
   inputField = new JTextField();
   Border inputBorder = BorderFactory.createEtchedBorder();
   inputBorder = BorderFactory.createTitledBorder(inputBorder, "Please type your words here:");
   inputField.setBorder(inputBorder);
   inputField.addActionListener(new ActionListenerField());
   return inputField;
 }
Exemplo n.º 29
0
 @Override
 public void actionPerformed(ActionEvent e) {
   JTextField tf = (JTextField) e.getSource();
   String test = tf.getText().trim();
   if (!test.equals("")) {
     find(test);
   }
 }
Exemplo n.º 30
0
  private void parseDirective(String directive) {
    if (directive == null) {
      System.err.println("Directive is null.");
      return;
    }

    String[] pair = directive.split("=");
    if (pair == null || pair.length != 2) {
      System.err.println("Unable to parse directive: \"" + directive + "\" Ignored.");
      return;
    }

    String key = pair[0].trim(), value = pair[1].trim();

    // clean these, might have too much whitespace around commas
    if (validKeys.indexOf(key) == FONT || validKeys.indexOf(key) == PRELOAD) {
      value = value.replaceAll("[\\s]*,[\\s]*", ",");
    }

    if (validKeys.indexOf(key) == -1) {
      System.err.println("Directive key not recognized: \"" + key + "\" Ignored.");
      return;
    }
    if (value.equals("")) {
      System.err.println("Directive value empty. Ignored.");
      return;
    }

    value = value.replaceAll("^\"|\"$", "").replaceAll("^'|'$", "");

    // System.out.println( key + " = " + value );

    boolean v;
    switch (validKeys.indexOf(key)) {
      case CRISP:
        v = value.toLowerCase().equals("true");
        crispBox.setSelected(v);
        break;
      case FONT:
        fontField.setText(value);
        break;
      case GLOBAL_KEY_EVENTS:
        v = value.toLowerCase().equals("true");
        globalKeyEventsBox.setSelected(v);
        break;
      case PAUSE_ON_BLUR:
        v = value.toLowerCase().equals("true");
        pauseOnBlurBox.setSelected(v);
        break;
      case PRELOAD:
        preloadField.setText(value);
        break;
      case TRANSPARENT:
        v = value.toLowerCase().equals("true");
        // transparentBox.setSelected(v);
        break;
    }
  }