/** 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();
   }
 }
 public void setHook() {
   ComboBoxEditor anEditor = this.getEditor();
   if (anEditor.getEditorComponent() instanceof JTextField) {
     editor = (JTextField) anEditor.getEditorComponent();
     editor.setColumns(TXT_FILENAME_LENGTH);
     editor.addKeyListener(
         new KeyAdapter() {
           public void keyReleased(KeyEvent ev) {
             char key = ev.getKeyChar();
             if (!(Character.isLetterOrDigit(key) || Character.isSpaceChar(key))) {
               return;
             }
             caretPos = editor.getCaretPosition();
             String text = "";
             try {
               text = editor.getText(0, caretPos);
             } catch (Exception ex) {
               Debug.error(me + "setHook: Problem getting image file name\n%s", ex.getMessage());
             }
             int n = getItemCount();
             for (int i = 0; i < n; i++) {
               int ind = ((String) getItemAt(i)).indexOf(text);
               if (ind == 0) {
                 setSelectedIndex(i);
                 return;
               }
             }
           }
         });
   }
 }
 @Override
 public void setSelectedIndex(int ind) {
   super.setSelectedIndex(ind);
   editor.setText(getItemAt(ind).toString());
   editor.setSelectionEnd(caretPos + editor.getText().length());
   editor.moveCaretPosition(caretPos);
 }
 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();
   }
 }
  public void buscarComputadora(JTable table) {
    JTextField marca = new JTextField();
    JTextField clave = new JTextField();
    Object[] mensaje = {
      "Marca:", marca,
      "Clave:", clave
    };

    int opcion =
        JOptionPane.showConfirmDialog(this, mensaje, "Buscar", JOptionPane.OK_CANCEL_OPTION);
    if (opcion == JOptionPane.OK_OPTION) {
      for (int i = 0; i < sistema.getEmpresa().getProductos().size(); i++) {
        try {
          if (marca
                  .getText()
                  .equalsIgnoreCase(sistema.getEmpresa().getProductos().get(i).getMarca())
              && Integer.parseInt(clave.getText())
                  == sistema.getEmpresa().getProductos().get(i).getClave()) {
            table.changeSelection(i, 0, false, false);
            JOptionPane.showMessageDialog(this, "Encontrado");
            return;
          }
        } catch (NumberFormatException ex) {
          JOptionPane.showMessageDialog(this, "Número inválido");
        }
      }
    }
    JOptionPane.showMessageDialog(this, "No se encontró el producto");
  }
 public void testIntProperty() throws Exception {
   JComponent rootComponent = getInstrumentedRootComponent("TestIntProperty.form", "BindingTest");
   assertEquals(1, rootComponent.getComponentCount());
   JTextField textField = (JTextField) rootComponent.getComponent(0);
   assertEquals(37, textField.getColumns());
   assertEquals(false, textField.isEnabled());
 }
Example #7
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();
    }
  }
Example #8
0
 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // 监听事件
   // TODO add your handling code here:
   if (jRadioButton1.isSelected()) {
     jRadioButtonName = jRadioButton1.getText();
   } else if (jRadioButton2.isSelected()) {
     jRadioButtonName = jRadioButton2.getText();
   }
   try {
     fwriter = new FileWriter(filename);
     fwriter.write(jTextField1.getText());
     fwriter.write("\r\n");
     fwriter.write(jTextField2.getText());
     fwriter.write("\r\n");
     fwriter.write(jTextField3.getText());
     fwriter.write("\r\n");
     fwriter.write(jTextField4.getText());
     fwriter.write("\r\n");
     fwriter.write(jRadioButtonName);
     fwriter.write("\r\n");
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     try {
       fwriter.flush();
       fwriter.close();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   this.dispose();
 }
  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();
  }
Example #10
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);
    }
  }
Example #11
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (td.getTabCount() > 0) {
     TextDocument ta = (TextDocument) td.getComponentAt(td.getSelectedIndex());
     Pattern pn = Pattern.compile(tf1.getText());
     Matcher mt = pn.matcher(ta.getText());
     if (e.getSource() == jb2) { // 取代
       ta.setText(mt.replaceAll(tf2.getText()));
     } else if (e.getSource() == jb1) { // 尋找
       Highlighter hl = ta.getHighlighter();
       hl.removeAllHighlights();
       while (mt.find()) {
         try {
           hl.addHighlight(
               mt.start(), mt.end(), new DefaultHighlighter.DefaultHighlightPainter(null));
         } catch (Exception ex) {
         }
       } // 開啟及關閉介面
     } else if (e.getSource() == replace_searchMenuItem) {
       System.out.println("Replace/Search is show:" + !show);
       if (show) {
         getContentPane().remove(jp);
         show = false;
       } else {
         getContentPane().add(jp, BorderLayout.SOUTH);
         show = true;
       }
       validate(); // 刷新容器
     }
   } else if (e.getSource() == replace_searchMenuItem) {
     JOptionPane.showMessageDialog(
         null, "尚無檔案,無法使用!", "Repace/Search error", JOptionPane.ERROR_MESSAGE);
   }
 }
Example #12
0
  private void setComponentsEnabled(boolean enabled) {
    list.setEnabled(enabled);
    process.setEnabled(enabled);
    remove.setEnabled(enabled);
    xres.setEnabled(enabled);
    yres.setEnabled(enabled);
    aspect.setEnabled(enabled);

    boolean b = aspect.isSelected() && enabled;
    colorLabel.setEnabled(b);
    colorBox.setEnabled(b);
    redLabel.setEnabled(b);
    red.setEnabled(b);
    redValue.setEnabled(b);
    greenLabel.setEnabled(b);
    green.setEnabled(b);
    greenValue.setEnabled(b);
    blueLabel.setEnabled(b);
    blue.setEnabled(b);
    blueValue.setEnabled(b);

    format.setEnabled(enabled);
    algorithm.setEnabled(enabled);
    prepend.setEnabled(enabled);
    append.setEnabled(enabled);
    output.setEnabled(enabled);
  }
 public void show_selected() {
   id = table_selected(0);
   T_title.setText(table_selected(1));
   T_director.setText(table_selected(2));
   T_actor.setText(table_selected(3));
   T_actress.setText(table_selected(4));
 }
Example #14
0
 public void actionPerformed(ActionEvent event) {
   if (event.getSource() == joinButton) {
     if (joinButton.isSelected()) {
       mThread =
           new MulticastThread(
               Integer.valueOf(portField.getText()), chatIPField.getText(), chatroomArea, true);
       (new Thread(mThread)).start();
     }
   }
   if (event.getSource() == sendButton) {
     mThread.send(usernameField.getText(), chatMsgField.getText());
     chatMsgField.setText("");
   }
   if (event.getSource() == leaveButton) {
     try {
       joinButton.setSelected(false);
       mThread.leave();
       System.out.println("Disconnected from chat ");
     } catch (Exception e) {
     }
   }
   if (event.getSource() == exitButton) {
     System.exit(0);
   }
 }
  public void getParamsForScript() {
    scriptTextArea = new JTextArea();
    scriptScrollPane = new JScrollPane();
    JPanel scriptTextPane = new JPanel();
    scriptTextPane.add(scriptScrollPane);

    xStartLabel = new JLabel("Start Value");
    xStartField = new JTextField(String.valueOf(xStart));
    xStartField.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              xStart = Double.valueOf(xStartField.getText());
            } catch (NumberFormatException nfe) {
              System.out.println("Number format exception for xStart value");
              nfe.printStackTrace();
            }
          }
        });

    xEndLabel = new JLabel("End Value");
    xEndField = new JTextField(String.valueOf(xEnd));
    xEndField.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              xEnd = Double.valueOf(xEndField.getText());
            } catch (NumberFormatException nfe) {
              System.out.println("Number format exception for xEnd value");
              nfe.printStackTrace();
            }
          }
        });

    JButton proceedButton = new JButton("Proceed to script ");
    proceedButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            xStart = Double.valueOf(xStartField.getText());
            xEnd = Double.valueOf(xEndField.getText());
            scriptCodeGenerationFrame.makescalaSciCodeFromParams(ODEWizardScalaSci.ODESolveMethod);
          };
        });

    JPanel startParamsPanel = new JPanel(new GridLayout(1, 2));
    startParamsPanel.add(xStartLabel);
    startParamsPanel.add(xStartField);
    JPanel endParamsPanel = new JPanel(new GridLayout(1, 2));
    endParamsPanel.add(xEndLabel);
    endParamsPanel.add(xEndField);
    JPanel proceedPanel = new JPanel();
    proceedPanel.add(proceedButton);
    setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
    add(startParamsPanel);
    add(endParamsPanel);
    add(proceedPanel);
    setLocation(100, 100);
    pack();
    setVisible(true);
  }
Example #16
0
  private JPanel initServerChoice() {

    JPanel p = new JPanel();
    p.setLayout(new GridLayout(6, 1, 5, 2));
    p.add(new JLabel("Search At: "));

    chosenServer.setText(server.getHost().getHostName());
    p.add(chosenServer);
    chosenServer.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            try {
              InetAddress newHost = InetAddress.getByName(chosenServer.getText());
              Whois newServer = new Whois(newHost);
              server = newServer;
            } catch (Exception e) {
              // should use an error dialog here, but that
              // doesn't teach much about networking
              chosenServer.setText(server.getHost().getHostName());
            }
          }
        });

    return p;
  }
Example #17
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);
  }
Example #18
0
  // Initialize all the GUI components and display the frame
  private static void initGUI() {
    // Set up the status bar
    statusField = new JLabel();
    statusField.setText(statusMessages[DISCONNECTED]);
    statusColor = new JTextField(1);
    statusColor.setBackground(Color.red);
    statusColor.setEditable(false);
    statusBar = new JPanel(new BorderLayout());
    statusBar.add(statusColor, BorderLayout.WEST);
    statusBar.add(statusField, BorderLayout.CENTER);

    // Set up the options pane
    JPanel optionsPane = initOptionsPane();

    // Set up the chat pane
    JPanel chatPane = new JPanel(new BorderLayout());
    chatText = new JTextArea(10, 20);
    chatText.setLineWrap(true);
    chatText.setEditable(false);
    chatText.setForeground(Color.blue);
    JScrollPane chatTextPane =
        new JScrollPane(
            chatText,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    chatLine = new JTextField();
    chatLine.setEnabled(false);
    chatLine.addActionListener(
        new ActionAdapter() {
          public void actionPerformed(ActionEvent e) {
            String s = chatLine.getText();
            if (!s.equals("")) {
              appendToChatBox("OUTGOING: " + s + "\n");
              chatLine.selectAll();

              // Send the string
              sendString(s);
            }
          }
        });
    chatPane.add(chatLine, BorderLayout.SOUTH);
    chatPane.add(chatTextPane, BorderLayout.CENTER);
    chatPane.setPreferredSize(new Dimension(200, 200));

    // Set up the main pane
    JPanel mainPane = new JPanel(new BorderLayout());
    mainPane.add(statusBar, BorderLayout.SOUTH);
    mainPane.add(optionsPane, BorderLayout.WEST);
    mainPane.add(chatPane, BorderLayout.CENTER);

    // Set up the main frame
    mainFrame = new JFrame("Simple TCP Chat");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setContentPane(mainPane);
    mainFrame.setSize(mainFrame.getPreferredSize());
    mainFrame.setLocation(200, 200);
    mainFrame.pack();
    mainFrame.setVisible(true);
  }
Example #19
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;
 }
Example #20
0
  // Function use to Clear all TextFields of Window.
  void txtClear() {

    txtNo.setText("");
    txtName.setText("");
    txtDate.setText("");
    txtBal.setText("");
    txtNo.requestFocus();
  }
Example #21
0
  // Function which display Record from Array onto the Form.
  void showRec(int intRec) {

    txtNo.setText(records[intRec][0]);
    txtName.setText(records[intRec][1]);
    txtDate.setText(records[intRec][2] + ", " + records[intRec][3] + ", " + records[intRec][4]);
    txtBal.setText(records[intRec][5]);
    recCount = intRec;
  }
Example #22
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;
    }
  }
Example #23
0
 public void enableChat() {
   openChat.setEnabled(false);
   chatWith.setEnabled(false);
   pickText.setEnabled(false);
   desText.setEnabled(false);
   send.setEnabled(true);
   chatText.setEnabled(true);
   new Thread(this).start();
 }
Example #24
0
  /** The listener method. */
  public void actionPerformed(ActionEvent event) {
    Object source = event.getSource();

    if (source == b1) // click button
    {
      try {
        String message = tf.getText();
        server.sendPrivateMessage(parent, selfIdentity, message);
        ta.append("<" + parent.getUserName() + ">: " + message + lineSeparator);
        ta.setCaretPosition(ta.getText().length());
        tf.setText("");
      } catch (RemoteException ex) {
        System.out.print("Exception encountered while sending" + " private message.");
      }
    }

    if (source == tf) // press return
    {
      try {
        String message = tf.getText();
        server.sendPrivateMessage(parent, selfIdentity, message);
        ta.append("<" + parent.getUserName() + ">: " + message + lineSeparator);
        ta.setCaretPosition(ta.getText().length());
        tf.setText("");
      } catch (RemoteException ex) {
        System.out.print("Exception encountered while sending" + " private message.");
      }
    }
    if (source == jMenuItem3) {
      JFileChooser fileChooser = new JFileChooser();

      fileChooser.setDialogTitle("Choose or create a new file to store the conversation");
      fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      fileChooser.setDoubleBuffered(true);

      fileChooser.showOpenDialog(this);

      File file = fileChooser.getSelectedFile();

      try {
        if (file != null) {

          Writer writer = new BufferedWriter(new FileWriter(file));

          writer.write(ta.getText());
          writer.flush();
          writer.close();
        }
      } catch (IOException ex) {
        System.out.println("Can't write to file. " + ex);
      }
    }
    if (source == jMenuItem4) {
      selfRemove();
      this.dispose();
    }
  }
 private void rodytiAutoRinkinius() {
   zonaNeregAuto.setText("");
   for (Automobilis a : rg.neregAuto) zonaNeregAuto.append(a.toString() + "\n");
   zonaRegAuto.setText("");
   for (Map.Entry<String, Automobilis> me : rg.regAuto.entrySet())
     zonaRegAuto.append(String.format("%8s=%s\n", me.getKey(), me.getValue()));
   tfNeregKiekis.setText(Integer.toString(rg.neregAuto.size()));
   tfRegKiekis.setText(Integer.toString(rg.regAuto.size()));
 }
Example #26
0
 private void resetInterface() {
   for (JCheckBox b :
       new JCheckBox[] {crispBox, globalKeyEventsBox, pauseOnBlurBox /*, transparentBox*/}) {
     b.setSelected(false);
   }
   for (JTextField f : new JTextField[] {fontField, preloadField}) {
     f.setText("");
   }
 }
Example #27
0
  private void loadPreferences() {
    // grab the preferences so that they can be used to fill out the layout
    ThumbMakerPreferences myPreferences = ThumbMakerPreferences.getInstance();

    // x resolution text box
    xres.setText(myPreferences.getStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME));

    // y resolution text box
    yres.setText(myPreferences.getStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME));

    // aspect ratio checkbox
    aspect.setSelected(
        myPreferences
            .getStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME)
            .equalsIgnoreCase(ThumbMakerPreferences.BOOLEAN_TRUE_STRING));

    // load the color values from the preferences
    int redValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME);
    int greenValueNumber =
        myPreferences.getIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME);
    int blueValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME);

    // set the background color image
    colorBox.setBackground(new Color(redValueNumber, greenValueNumber, blueValueNumber));

    // red slider
    red.setValue(redValueNumber);
    redValue.setText("" + redValueNumber);

    // green slider
    green.setValue(greenValueNumber);
    greenValue.setText("" + greenValueNumber);

    // blue slider
    blue.setValue(blueValueNumber);
    blueValue.setText("" + blueValueNumber);

    // algorithm combo box
    algorithm.setSelectedIndex(
        myPreferences.getIntegerPref(ThumbMakerPreferences.RESIZE_ALG_PREF_NAME));

    // format combo box
    format.setSelectedIndex(
        myPreferences.getIntegerPref(ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME));

    // prepend field
    prepend.setText(myPreferences.getStringPref(ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME));

    // append field
    append.setText(myPreferences.getStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME));

    // output folder field
    output.setText(
        (new File(myPreferences.getStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME)))
            .getAbsolutePath());
  }
 /**
  * Will register this server on the port number portNumber. Will not start waiting for
  * connections. For this you should call waitForConnectionFromClient().
  */
 private void registerOnPort() {
   try {
     serverSocket = new ServerSocket(Integer.parseInt(portNumber.getText()));
   } catch (IOException e) {
     serverSocket = null;
     System.err.println("Cannot open server socket on port number" + portNumber.getText());
     System.err.println(e);
     System.exit(-1);
   }
 }
Example #29
0
 /** Update button enable/disable state according enableCheckBox. */
 private void updateButtonsState() {
   sipProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   jabberProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   rtpProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   ice4jProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   fileCountField.setEnabled(enableCheckBox.isSelected());
   fileSizeField.setEnabled(enableCheckBox.isSelected());
   fileSizeLabel.setEnabled(enableCheckBox.isSelected());
   fileCountLabel.setEnabled(enableCheckBox.isSelected());
 }
Example #30
-1
  private void saveItem() {

    File f = new File("config.txt");

    if (f.exists() && !f.isDirectory()) {

      try (PrintWriter out =
          new PrintWriter(new BufferedWriter(new FileWriter("config.txt", true)))) {
        if (!searchName.getText().equals("") && !item.getText().equals("")) {

          out.println(
              searchName.getText()
                  + ","
                  + "http://www.reddit.com/r/hardwareswap/search?q="
                  + item.getText()
                  + "&sort=new&restrict_sr=on");
          addItem();

        } else {

          results.setText("Please provide all info for Search Name and Item");
        }

      } catch (IOException e1) {
        results.append("Error saving to file.");
      }

    } else {
      Main.checkFiles();
    }
  }