/** 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 search() { hilit.removeAllHighlights(); String s = entry.getText(); if (s.length() <= 0) { message("Nothing to search"); return; } String content = textArea.getText(); int index = content.indexOf(s, 0); if (index >= 0) { try { int end = index + s.length(); hilit.addHighlight(index, end, painter); textArea.setCaretPosition(end); entry.setBackground(entryBg); message("'" + s + "' found. Press ESC to end search"); } catch (BadLocationException e) { e.printStackTrace(); } } else { entry.setBackground(ERROR_COLOR); message("'" + s + "' found. Press ESC to start a new search"); } }
public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) return; optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); if (button1.equals(value)) { try { double a = Double.parseDouble(left.getText()); double b = Double.parseDouble(right.getText()); double err = Double.parseDouble(error.getText()); if (a > b) { JOptionPane.showMessageDialog(this, "A < B!!!", null, JOptionPane.ERROR_MESSAGE); } else { hideIt(); graphic.startApplyingMethod(parentFrame.getSelectedMethod(), err, a, b); } } catch (Exception ex) { JOptionPane.showMessageDialog( this, "Trebuie sa fie numar real!", null, JOptionPane.ERROR_MESSAGE); } } else if (button2.equals(value)) { hideIt(); } } }
/** Updates the information displayed in the fields. */ public void update() { super.update(); // update the common fields InteractiveEntity interactiveEntity = (InteractiveEntity) entity; String sprite = interactiveEntity.getProperty("sprite"); String behavior = interactiveEntity.getProperty("behavior"); EntitySubtype subtype = interactiveEntity.getSubtype(); boolean hasSprite = (!sprite.equals("_none")); withSpriteField.setSelected(hasSprite); spriteField.setSelectedId(hasSprite ? sprite : ""); spriteField.setEnabled(hasSprite); if (behavior.equals("map")) { behaviorField.setSelectedIndex(1); messageField.setEnabled(false); itemField.setEnabled(false); } else if (behavior.substring(0, 5).equals("item#")) { behaviorField.setSelectedIndex(2); messageField.setEnabled(false); itemField.setEnabled(true); itemField.setSelectedId(behavior.substring(5)); } else if (behavior.substring(0, 7).equals("dialog#")) { behaviorField.setSelectedIndex(0); messageField.setEnabled(true); itemField.setEnabled(false); messageField.setText(behavior.substring(7)); } }
/** @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 RFIDGUI() { setLayout(new FlowLayout()); // label = new JTextField(ThreadTwoTestTwo.randomQuestionStatement); Question.setFont(new Font("Serif", Font.BOLD, 18)); // Points.setFont(new Font("Serif", Font.BOLD, 50)); // Question.setBounds(300, 250, 900, 300); // Points.setBounds(1200, 600, 300, 200); // Points.setHorizontalAlignment(JTextField.RIGHT); // Points.set Question.setForeground(Color.blue); // Points.setForeground(Color.red); add(Question); // Question.validate(); // add(Points, BorderLayout.SOUTH); // Points.validate(); // Question.setLocation(0, 0); // Points.setLocation(1600,900); /*while(count<70){ //secondDoneYet = false; while (!secondDoneYet) { //label = new JTextField(ThreadTwoTestTwo.randomQuestionStatement); label.repaint(); secondDoneYet = true; count++; /* * while(ThreadTwoTestTwo.amountOfQuestions <=60){ * label.repaint(); } */ }
/** * Return the string that was entered in the text field. If the user is forced to select an item, * then the text of the item will be returned. * * @return text in text field */ public String getText() { if (_force) { T item = _matchList.getSelectedValue(); return (item == null) ? "" : _currentStrategy.force(item, _textField.getText()); } return _textField.getText(); }
private JPanel createContentPane() { JPanel panel = new JPanel(); combo1 = new JComboBox<>(numData); panel.add(combo1); combo2 = new JComboBox<>(dayData); combo2.setEditable(true); panel.add(combo2); panel.setSize(300, 200); popupMenu = new JPopupMenu(); JMenuItem item; for (int i = 0; i < dayData.length; i++) { item = popupMenu.add(new JMenuItem(dayData[i], mnDayData[i])); item.addActionListener(this); } panel.addMouseListener(new PopupListener(popupMenu)); JTextField field = new JTextField("CTRL+down for Popup"); // CTRL-down will show the popup. field .getInputMap() .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP"); field.getActionMap().put("OPEN_POPUP", new PopupHandler()); panel.add(field); return panel; }
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(); } }
private void onBatch() { final boolean b = useBatchInputCheckbox.isSelected(); orientationComboBox.setEnabled(b); lengthField.setEnabled(b); dpiXField.setEnabled(b); dpiYField.setEnabled(b); startDepthField.setEnabled(b); depthIncField.setEnabled(b); applyToAllButton.setEnabled(b); applyToSelectedButton.setEnabled(b); if (!b) { orientationLabel.setEnabled(b); lengthLabel.setEnabled(b); dpiXLabel.setEnabled(b); dpiYLabel.setEnabled(b); startDepthLabel.setEnabled(b); depthIncLabel.setEnabled(b); } else { orientationLabel.setEnabled(orientationComboBox.getSelectedIndex() != 2); // [Blank] lengthLabel.setEnabled(!lengthField.getText().equals("")); dpiXLabel.setEnabled(!dpiXField.getText().equals("")); dpiYLabel.setEnabled(!dpiYField.getText().equals("")); startDepthLabel.setEnabled(!startDepthField.getText().equals("")); depthIncLabel.setEnabled(!depthIncField.getText().equals("")); } }
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(); }
// Listener method for list selection changes. public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == false) { if (list.getSelectedIndex() == -1) { // No selection: disable delete, up, and down buttons. deleteButton.setEnabled(false); upButton.setEnabled(false); downButton.setEnabled(false); nameField.setText(""); } else if (list.getSelectedIndices().length > 1) { // Multiple selection: disable up and down buttons. deleteButton.setEnabled(true); upButton.setEnabled(false); downButton.setEnabled(false); } else { // Single selection: permit all operations. deleteButton.setEnabled(true); upButton.setEnabled(true); downButton.setEnabled(true); nameField.setText(list.getSelectedValue().toString()); } } }
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); }
@Override public void actionPerformed(ActionEvent e) { JTextField tf = (JTextField) e.getSource(); String test = tf.getText().trim(); if (!test.equals("")) { find(test); } }
public void showIt() { left.setText(null); right.setText(null); setLocationRelativeTo(parentFrame); setVisible(true); }
/* *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; }
public Vector getStrings() { int size = _fields.size(); Vector res = new Vector(size); for (int i = 0; i < size; i++) { JTextField tf = (JTextField) _fields.elementAt(i); res.addElement(tf.getText()); } return res; }
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()); }
private void actionAdd() { URL verifiedUrl = verifyUrl(addTextField.getText()); if (verifiedUrl != null) { tableModel.addDownload(new DownloadFile(verifiedUrl)); addTextField.setText(""); } else { JOptionPane.showMessageDialog( this, "Invalid Download URL", "Error", JOptionPane.ERROR_MESSAGE); } }
void addTextField(JPanel panel, String key, String label) { JLabel lab = new JLabel(label); lab.setAlignmentX(LEFT_ALIGNMENT); panel.add(lab); JTextField field = new JTextField(); field.setText(sketch.configFile.get(key)); field.setMaximumSize(new Dimension(Integer.MAX_VALUE, field.getPreferredSize().height)); fields.put(key, field); panel.add(field); }
/** 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()); }
/** Load the settings of this panel */ private void loadSettings() { uploadPrioTextField.setText(settings.getValue(SettingsClass.FCP2_DEFAULT_PRIO_MESSAGE_UPLOAD)); downloadPrioTextField.setText( settings.getValue(SettingsClass.FCP2_DEFAULT_PRIO_MESSAGE_DOWNLOAD)); useOneConnectionForMessagesCheckBox.setSelected( settings.getBoolValue(SettingsClass.FCP2_USE_ONE_CONNECTION_FOR_MESSAGES)); displayDaysTextField.setText(settings.getValue(SettingsClass.MAX_MESSAGE_DISPLAY)); downloadDaysTextField.setText(settings.getValue(SettingsClass.MAX_MESSAGE_DOWNLOAD)); messageBaseTextField.setText(settings.getValue(SettingsClass.MESSAGE_BASE)); alwaysDownloadBackloadCheckBox.setSelected( settings.getBoolValue(SettingsClass.ALWAYS_DOWNLOAD_MESSAGES_BACKLOAD)); minimumIntervalTextField.setText( settings.getValue(SettingsClass.BOARD_AUTOUPDATE_MIN_INTERVAL)); concurrentUpdatesTextField.setText( settings.getValue(SettingsClass.BOARD_AUTOUPDATE_CONCURRENT_UPDATES)); // this setting is in MainFrame automaticBoardUpdateCheckBox.setSelected( MainFrame.getInstance().isAutomaticBoardUpdateEnabled()); refreshUpdateState(); storeSentMessagesCheckBox.setSelected( settings.getBoolValue(SettingsClass.STORAGE_STORE_SENT_MESSAGES)); silentlyRetryCheckBox.setSelected(settings.getBoolValue(SettingsClass.SILENTLY_RETRY_MESSAGES)); altEditCheckBox.setSelected(settings.getBoolValue(SettingsClass.ALTERNATE_EDITOR_ENABLED)); altEditTextField.setEnabled(altEditCheckBox.isSelected()); altEditTextField.setText(settings.getValue(SettingsClass.ALTERNATE_EDITOR_COMMAND)); }
public void nameFocusLost(java.awt.event.FocusEvent evt) { ctxt.saveState = true; String newName = name.getText(), msg; while (!Library.validateFileName(newName, false)) { msg = "The name '" + newName + "' violates the rules for names:"; msg += "\nIt must have 2 to 28 characters."; msg += "\nYou may not use BackSlash, ForwardSlash, Colon, DoubleQuote"; msg += "\nAsterisk, QuestionMark, LeftAngleBracket, RightAngleBracket,"; msg += "\nor the VerticalBar in a name. TRY AGAIN."; newName = JOptionPane.showInputDialog(msg); } // end of harrass-em-until-they-give-a-good-name name.setText(newName); if (!newName.equals(ctxt.languageName)) { // Made a change msg = "Change this context's language name\nto" + newName + "?"; String[] options = {newName, ctxt.languageName}; int choice = JOptionPane.showOptionDialog( this, msg, "Confirm Changed Language Name", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (choice == 0) { // Change is confirmed ctxt.languageName = newName; msg = "Normally, the file name for a context is the same as the language name " + "\nfor that context. Change this context's file name\n" + "to " + newName + "?"; options[0] = "Change File Name"; options[1] = "Do Not Change"; choice = JOptionPane.showOptionDialog( this, msg, "Confirm Correct File Name", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (choice == 0) { Library.userContextName = newName; if (SIL_Edit.edWin != null && ctxt == Library.contextUnderConstruction) { SIL_Edit.edWin.chart.changeFileName(newName); } } } // end of Change-is-confirmed } // end of change-was-made }
/** * Update the dialog contents. * * @param jheader The job portion of the dialog header. * @param job The queue job. * @param info The current job status information. */ public void updateContents( String jheader, QueueJob job, QueueJobInfo info, SubProcessExecDetails details) { ActionAgenda agenda = job.getActionAgenda(); QueueJobResults results = info.getResults(); String dir = "-"; if ((agenda != null) && (info.getOsType() != null)) dir = agenda.getTargetPath(info.getOsType()).toString(); String hostname = ""; if (info.getHostname() != null) hostname = (" [" + info.getHostname() + "]"); String command = "-"; if (details != null) command = details.getCommand(); TreeMap<String, String> env = new TreeMap<String, String>(); if (details != null) env = details.getEnvironment(); setHeader("Execution Details -" + jheader + hostname); pWorkingDirField.setText(dir); BaseAction action = job.getAction(); pCommandLineLabel.setText( "Action Command: " + action.getName() + " (v" + action.getVersionID() + ")"); pCommandLineArea.setText(command); { Component comps[] = UIFactory.createTitledPanels(); { JPanel tpanel = (JPanel) comps[0]; JPanel vpanel = (JPanel) comps[1]; if (!env.isEmpty()) { String last = env.lastKey(); for (String key : env.keySet()) { String value = env.get(key); JTextField field = UIFactory.createTitledTextField(tpanel, key + ":", sTSize, vpanel, value, sVSize); field.setHorizontalAlignment(JLabel.LEFT); if (!key.equals(last)) UIFactory.addVerticalSpacer(tpanel, vpanel, 3); } } else { tpanel.add(Box.createRigidArea(new Dimension(sTSize, 0))); vpanel.add(Box.createHorizontalGlue()); } } pEnvLabel.setText("Toolset Environment: " + agenda.getToolset()); pEnvScroll.setViewportView(comps[2]); } }
private void updatePreview() { String family = familyField.getText(); int size; try { size = Integer.parseInt(sizeField.getText()); } catch (Exception e) { size = 12; } int style = styleList.getSelectedIndex(); preview.setFont(new Font(family, style, size)); }
/** Constructor */ public ServiceFilterPanel(String text, Vector list) { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); service_box = new JCheckBox(text); service_box.addActionListener(this); service_data = new Vector(); if (list != null) { service_box.setSelected(true); service_data = (Vector) list.clone(); } service_list = new JList(service_data); service_list.setBorder(new EtchedBorder()); service_list.setVisibleRowCount(5); service_list.addListSelectionListener(this); service_list.setEnabled(service_box.isSelected()); service_scroll = new JScrollPane(service_list); service_scroll.setBorder(new EtchedBorder()); remove_service_button = new JButton("Remove"); remove_service_button.addActionListener(this); remove_service_button.setEnabled(false); remove_service_panel = new JPanel(); remove_service_panel.setLayout(new FlowLayout()); remove_service_panel.add(remove_service_button); service_area = new JPanel(); service_area.setLayout(new BorderLayout()); service_area.add(service_scroll, BorderLayout.CENTER); service_area.add(remove_service_panel, BorderLayout.EAST); service_area.setBorder(indent_border); add_service_field = new JTextField(); add_service_field.addActionListener(this); add_service_field.getDocument().addDocumentListener(this); add_service_field.setEnabled(service_box.isSelected()); add_service_button = new JButton("Add"); add_service_button.addActionListener(this); add_service_button.setEnabled(false); add_service_panel = new JPanel(); add_service_panel.setLayout(new BorderLayout()); JPanel dummy = new JPanel(); dummy.setBorder(empty_border); add_service_panel.add(dummy, BorderLayout.WEST); add_service_panel.add(add_service_button, BorderLayout.EAST); add_service_area = new JPanel(); add_service_area.setLayout(new BorderLayout()); add_service_area.add(add_service_field, BorderLayout.CENTER); add_service_area.add(add_service_panel, BorderLayout.EAST); add_service_area.setBorder(indent_border); setLayout(new BorderLayout()); add(service_box, BorderLayout.NORTH); add(service_area, BorderLayout.CENTER); add(add_service_area, BorderLayout.SOUTH); setBorder(empty_border); }
public FenText3() { setTitle("Miroir d’un texte"); setSize(300, 110); Container contenu = getContentPane(); contenu.setLayout(new FlowLayout()); saisie = new JTextField(20); contenu.add(saisie); saisie.getDocument().addDocumentListener(this); copie = new JTextField(20); copie.setEditable(true); copie.setBackground(Color.gray); contenu.add(copie); }
public EventAdapter(JTextField tf, JTable tbl) { boolean autoIme = Project.getBoolean("autoIme", true); if (autoIme) { tf.addFocusListener(AutoKanjiListener.getInstance()); } else { tf.addFocusListener(AutoRomanListener.getInstance()); } tf.addActionListener(EventAdapter.this); tbl.getSelectionModel().addListSelectionListener(EventAdapter.this); tbl.addMouseListener(EventAdapter.this); }
public TextFields() { t1.setDocument(ucd); ucd.addDocumentListener(new T1()); b1.addActionListener(new B1()); b2.addActionListener(new B2()); t1.addActionListener(new T1A()); setLayout(new FlowLayout()); add(b1); add(b2); add(t1); add(t2); add(t3); }
/** * Apply properties * * @return Was successful */ protected boolean applyProperties() { if (!super.applyProperties()) { return false; } try { bins = new Integer(binFld.getText().trim()).intValue(); } catch (NumberFormatException nfe) { LogUtil.userErrorMessage("Bad value for bins: " + binFld.getText()); return false; } // stacked = stackedCbx.isSelected(); return true; }