/** 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(); } }
private void checkInput() { if (0 == userNameField.getText().trim().length()) { JOptionPane.showMessageDialog(this, "用户名不能为空", "警告", JOptionPane.WARNING_MESSAGE); userNameField.requestFocus(); return; } if (0 == passwordField.getPassword().length) { JOptionPane.showMessageDialog(this, "密码不能为空", "警告", JOptionPane.WARNING_MESSAGE); passwordField.requestFocus(); return; } if (!new String(confirmPasswordField.getPassword()) .equals(new String(passwordField.getPassword()))) { JOptionPane.showMessageDialog(this, "两次密码不相同", "警告", JOptionPane.WARNING_MESSAGE); passwordField.requestFocus(); return; } if (0 == nickNameField.getText().trim().length()) { JOptionPane.showMessageDialog(this, "昵称不能为空", "警告", JOptionPane.WARNING_MESSAGE); nickNameField.requestFocus(); return; } }
/** * Clears and focuses the search field if it is not focused. Otherwise, cycles to the next search * type. */ public void startSearch() { if (increment.isSelected() && incSearch) { repeatIncremental(); return; } if (!searchField.hasFocus()) { // searchField.setText(""); searchField.selectAll(); searchField.requestFocus(); } else { if (increment.isSelected()) { floatSearch.setSelected(true); } else if (floatSearch.isSelected()) { hideSearch.setSelected(true); } else if (hideSearch.isSelected()) { showResultsInDialog.setSelected(true); } else if (showResultsInDialog.isSelected()) { searchAllBases.setSelected(true); } else { increment.setSelected(true); } increment.revalidate(); increment.repaint(); searchField.requestFocus(); } }
public void loadTags() { if (this.tagFilenames != null && this.tagFilenames.length > 0 && viewer.getSwingGUI().getCurrentPage() > 0) { // grab tag text and update tags currentTagFilename = this.tagFilenames[viewer.getSwingGUI().getCurrentPage() - 1] + ".txt"; try (FileReader fr = new FileReader(currentTagFilename); BufferedReader br = new BufferedReader(fr)) { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append(System.lineSeparator()); line = br.readLine(); } tags.setText(sb.toString()); } catch (FileNotFoundException ex) { // just don't do anything, the tag file doesn't exist which is ok. // expected result: keep whatever text is in 'tags' UI element } catch (IOException ex) { Logger.getLogger(PDFViewer.class.getName()).log(Level.SEVERE, null, ex); } } // request focus for tags tags.requestFocus(); }
/** * Se encarga de armar el dialogo con los requerimientos de un CLiente de banco. * * @param padre El marco principal de la ventana emergente. * @param mensaje El mensaje que lleva la ventana. */ private void armaDialogo(JFrame padre, String mensaje) { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(5, 2)); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel etiqueta = new JLabel(mensaje, SwingConstants.RIGHT); panel.add(etiqueta); panel.add(new JLabel("")); etiqueta = new JLabel("Nombre:", SwingConstants.RIGHT); panel.add(etiqueta); inNombre = new JTextField(20); panel.add(inNombre); etiqueta = new JLabel("RFC:", SwingConstants.RIGHT); panel.add(etiqueta); inRFC = new JTextField(20); panel.add(inRFC); etiqueta = new JLabel("Telefono:", SwingConstants.RIGHT); panel.add(etiqueta); inTelefono = new JTextField(20); panel.add(inTelefono); aceptar = new JButton("Aceptar"); cancelar = new JButton("Cancelar"); panel.add(aceptar); panel.add(cancelar); getContentPane().add(panel); pack(); inNombre.setRequestFocusEnabled(true); inNombre.requestFocus(); this.setLocationRelativeTo(padre); }
public Console() { super("Javacalculus Test GUI"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setResizable(false); System.setOut(new PrintStream(new consoleOutputStream())); // System.setErr(new PrintStream(new consoleOutputStream(true))); inputLabel.setLabelFor(input); input.setPreferredSize(new Dimension(300, 20)); input.setBorder(BorderFactory.createLoweredBevelBorder()); input.addKeyListener(this); commandHistory.add(""); execute.addActionListener(this); execute.setBackground(Color.GREEN); execute.setForeground(Color.WHITE); console.setLineWrap(true); console.setWrapStyleWord(true); console.setEditable(false); console.setFont(new Font("Dialog", Font.BOLD, 14)); JScrollPane consolePane = new JScrollPane( console, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); consolePane.setPreferredSize(new Dimension(600, 300)); consolePane.setBorder(BorderFactory.createLoweredBevelBorder()); // error.setLineWrap(true); // error.setWrapStyleWord(true); // error.setEditable(false); // error.setFont(new Font("Dialog", Font.ITALIC, 12)); // JScrollPane errorPane = new JScrollPane(error, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, // JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); // errorPane.setBorder(BorderFactory.createLoweredBevelBorder()); // errorPane.setPreferredSize(new Dimension(600,300)); // content.setPreferredSize(new Dimension(400,400)); content.setLayout(new GridBagLayout()); content.setBorder(BorderFactory.createLoweredBevelBorder()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.fill = GridBagConstraints.BOTH; content.add(inputLabel, c); c.gridx = 1; c.gridy = 0; content.add(input, c); c.gridx = 2; c.gridy = 0; content.add(execute, c); c.gridx = 0; c.gridy = 1; c.gridwidth = 3; content.add(consolePane, c); // c.gridx = 0; c.gridy = 2; // content.add(errorPane, c); add(content); pack(); setVisible(true); input.requestFocus(); }
/** * Sets the focus on the user name field if no user name entered otherwise, sets the focus on the * password field. */ public void requestFocusOnField() { if (loginAttempt) return; setControlsEnabled(true); String txt = user.getText(); if (txt == null || txt.trim().length() == 0) user.requestFocus(); else pass.requestFocus(); }
public void Update(String event) { if (event.equals("time")) { MODEL.time = "<html>Elapsed Time: <font color =\"GREEN\">" + MODEL.watch.getElapsedTimeSecs() + "</font> Seconds</html>"; timeLab.setText(MODEL.time); } else if (event.equals("invalid")) { MODEL.answerInvalid(); msg.setText(MODEL.msg); } else if (event.equals("correct")) { MODEL.answerCorrect(); score.setText(MODEL.str); msg.setText(MODEL.msg); problem.setText(MODEL.prb); entry.setText(""); entry.requestFocus(); } else if (event.equals("wrong")) { MODEL.answerWrong(); msg.setText(MODEL.msg); } else if (event.equals("replay")) { MODEL.gameReplay(); problem.setText(MODEL.prb); score.setText(MODEL.str); msg.setText(MODEL.msg); timeLab.setText(MODEL.time); } else System.out.println("Invalid Update Command"); }
void jListOnlineUsers_mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { jTextFieldTargetUser.setText(((HostItem) jListOnlineUsers.getSelectedValue()).name); Flasher.instance().flashBackground(jTextFieldTargetUser, Color.yellow, 2); jTextFieldSendMessages.requestFocus(); } }
private void logPortValueException(Exception e) { my(BlinkingLights.class) .turnOn( LightType.ERROR, "Invalid Port Value: " + _portTF.getText(), e.getMessage(), e, 20000); my(Logger.class).log("Invalid Port Value: {}", _portTF.getText()); _portTF.requestFocus(); }
private void startEdit(int index) { if (index < 0) { return; } LibraryPlaylistsListCell cell = (LibraryPlaylistsListCell) _model.getElementAt(index); _selectedIndexToRename = cell.getPlaylist() != null ? index : -1; String text = cell.getText(); Rectangle rect = _list.getUI().getCellBounds(_list, index, index); Dimension lsize = rect.getSize(); Point llocation = rect.getLocation(); _textName.setSize(lsize); _textName.setLocation(llocation); _textName.setText(text); _textName.setSelectionStart(0); _textName.setSelectionEnd(text.length()); _textName.setVisible(true); _textName.requestFocusInWindow(); _textName.requestFocus(); }
private final void setPrompt(boolean b) { prompt.setEnabled(b); if (b) { prompt.requestFocus(); prompt.setBackground(Color.black); } else prompt.setBackground(Color.darkGray); }
private void persiapanEntriDataBaru() { kodeagama.setText(""); namaagamaField.setText(""); IDlogauditField.setText(""); kodeagama.requestFocus(); }
public void limparTela() { codigoCatalogoField.setText(""); tituloField.setText(""); tituloOriginalField.setText(""); escritorField.setText(""); tradutorField.setText(""); anoPrimEdicaoField.setText(""); anoLancamentoField.setText(""); edicaoField.setText(""); qtdPageField.setText(""); linguagemField.setText(""); generoField.setText(""); categoriaField.setText(""); formatoField.setText(""); editoraField.setText(""); paisLancamentoField.setText(""); codigoBarraField.setText(""); codigoCDDField.setText(""); codigoCDUField.setText(""); sinopseArea.setText(""); seriesArea.setText(""); obsArea.setText(""); capaField.setText(""); capaLabel.setIcon(null); // limpa tabela book itens model.limpar(); codigoCatalogoField.setEditable(true); codigoCatalogoField.requestFocus(); }
private boolean add() { // Validation: if (StringUtil.isEmpty(jtf_fileName.getText())) { JOptionPane.showMessageDialog( this, "Name must be present!", "Validation: name empty!", JOptionPane.ERROR_MESSAGE); jtf_fileName.requestFocus(); return false; } // Read values: final String fileName = jtf_fileName.getText(); final ContentType ct = jp_contentType.getContentType(); final File file = new File(jtf_file.getText()); final ReqEntityFilePart part = new ReqEntityFilePartBean(fileName, ct, file); // Trigger all listeners: for (AddMultipartPartListener l : listeners) { l.addPart(part); } // Clear: clear(); // Focus: jb_file.requestFocus(); return true; }
// Function use to Clear all TextFields of Window. void txtClear() { txtNo.setText(""); txtName.setText(""); txtDate.setText(""); txtBal.setText(""); txtNo.requestFocus(); }
public void delimeterChanged(ActionEvent e) { int index = delimCombo.getSelectedIndex(); boolean enableCustom = (index == 4); customDelimField.setEnabled(enableCustom); if (enableCustom) { customDelimField.requestFocus(); } }
public static void GetPersonID( JTextField textID, JTextField textNama, JRadioButton radioLakilaki, JRadioButton radioPerempuan, JTextField textKota, JTextField textTanggal, JComboBox comboBulan, JTextField textTahun, JTextField textKontak, JTextField textAlamat) { String id, nama, kelamin, kota, tglLeft, tglMid, tglRight, kontak, alamat; id = PeoplesLog.getId(); nama = PeoplesLog.getNama(); kelamin = PeoplesLog.getKelamin(); kota = PeoplesLog.getKota(); tglLeft = PeoplesLog.getTglLeft(); tglMid = PeoplesLog.getTglMid(); tglRight = PeoplesLog.getTglRight(); kontak = PeoplesLog.getKontak(); alamat = PeoplesLog.getAlamat(); textID.setText(id); textNama.setText(nama); switch (kelamin) { case "Laki-laki": ChooseGender(true, radioLakilaki, radioPerempuan); break; default: ChooseGender(false, radioLakilaki, radioPerempuan); break; } textKota.setText(kota); int iBulan, iTanggal; iBulan = Integer.parseInt(tglMid); iTanggal = Integer.parseInt(tglRight); String tanggal; if (iTanggal < 10) { tanggal = "0" + iTanggal; } else { tanggal = tglRight; } textTanggal.setText(tanggal); LoadBulan(comboBulan); DateMax(comboBulan); comboBulan.setSelectedIndex(iBulan); textTahun.setText(tglLeft); textKontak.setText(kontak); textAlamat.setText(alamat); textID.requestFocus(); }
// Constructor public DeleteArchiveFrame(AmazonGlacierClient client, String vaultName, int region) { super("Delete Archive"); int width = 200; int height = 170; Color wc = Color.WHITE; deleteClient = client; deleteVault = vaultName; JLabel label1 = new JLabel("ArchiveID to Delete from " + Endpoint.getTitleByIndex(region) + ":"); jtfDeleteField = new JTextField(100); jbtDelete = new JButton("Delete"); jbtBack = new JButton("Back"); JPanel p1 = new JPanel(); p1.setLayout(new FlowLayout()); p1.add(label1); p1.setBackground(wc); JPanel p2 = new JPanel(); p2.setLayout(new FlowLayout()); p2.add(jtfDeleteField); jtfDeleteField.addMouseListener(new ContextMenuMouseListener()); jtfDeleteField.setFocusable(true); p2.setBackground(wc); JPanel p3 = new JPanel(); p3.setLayout(new FlowLayout()); p3.add(jbtDelete); jbtDelete.addActionListener(this); jbtDelete.setBackground(wc); p3.add(jbtBack); jbtBack.addActionListener(this); jbtBack.setBackground(wc); p3.setBackground(wc); JPanel p4 = new JPanel(); p4.setLayout(new BorderLayout()); p4.setBackground(wc); p4.add(p1, BorderLayout.NORTH); p4.add(p2, BorderLayout.CENTER); p4.add(p3, BorderLayout.SOUTH); setContentPane(p4); // Prepare for display pack(); if (width < getWidth()) // prevent setting width too small width = getWidth(); if (height < getHeight()) // prevent setting height too small height = getHeight(); centerOnScreen(width, height); jtfDeleteField.setText(""); jtfDeleteField.requestFocus(); }
@Override public void keyPressed(KeyEvent key) { // TODO Auto-generated method stub if (key.getKeyCode() == KeyEvent.VK_ENTER) { control.send_message(textField.getText()); textField.setText(""); textField.requestFocus(); } }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == button_send) { control.send_message(textField.getText()); textField.setText(""); textField.requestFocus(); } }
/** affiche un textfield */ void modeTextField() { remove(label); repaint(); add(textField, BorderLayout.SOUTH); textField.selectAll(); textField.requestFocus(); repaint(); }
/** * This will be called when the user clicks the "Send" button or presses return in the text-input * box. It posts the contents of the input box to the transcript. If the thread is not running, it * creates and starts a new thread. */ public void actionPerformed(ActionEvent evt) { postMessage("SENT: " + input.getText()); input.selectAll(); input.requestFocus(); if (running == false) { runner = new Thread(this); running = true; runner.start(); } }
@Override public void actionPerformed(ActionEvent arg0) { print(c.execute(input.getText())); commandHistory.remove(commandHistory.size() - 1); commandHistory.add(input.getText()); commandHistory.add(""); commandHistoryIndex = commandHistory.size() - 1; input.setText(""); input.requestFocus(); }
/** Select the strategy for matching. */ public void selectStrategy() { _currentStrategy = _strategies.get(_strategyBox.getSelectedIndex()); removeListener(); _pim.setStrategy(_currentStrategy); updateTextField(); updateExtensionLabel(); updateList(); addListener(); _textField.requestFocus(); }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == jbtDelete) { if ((jtfDeleteField.getText().trim().equals(""))) { JOptionPane.showMessageDialog( null, "Enter the Archive ID of the file to be deleted.", "Error", JOptionPane.ERROR_MESSAGE); } else { try { String archiveId = jtfDeleteField.getText().trim(); // Banish the extra chars printed in early logs. String sendThis = archiveId.replaceAll("[^\\p{Print}]", ""); String vaultName = deleteVault; // Delete the archive. deleteClient.deleteArchive( new DeleteArchiveRequest().withVaultName(vaultName).withArchiveId(sendThis)); JOptionPane.showMessageDialog( null, "Deleted archive successfully.", "Success", JOptionPane.INFORMATION_MESSAGE); } catch (AmazonServiceException k) { JOptionPane.showMessageDialog( null, "The server returned an error. Wait 24 hours after submitting an archive to attempt a delete. Also check that correct location of archive has been set on the previous page.", "Error", JOptionPane.ERROR_MESSAGE); System.out.println("" + k); } catch (AmazonClientException i) { JOptionPane.showMessageDialog( null, "Client Error. Check that all fields are correct. Archive not deleted.", "Error", JOptionPane.ERROR_MESSAGE); } catch (Exception j) { JOptionPane.showMessageDialog( null, "Archive not deleted. Unspecified Error.", "Error", JOptionPane.ERROR_MESSAGE); } jtfDeleteField.setText(""); jtfDeleteField.requestFocus(); } } else if (e.getSource() == jbtBack) { this.setVisible(false); dispose(); } else { JOptionPane.showMessageDialog(this, "Please choose a valid action."); } }
/** * Creates the terminal for interaction with client from server * * @param s */ public Terminal(Server s) { mServer = s; TextFieldListener tfListener = new TextFieldListener(); input.addActionListener(tfListener); Display = new javax.swing.JLayeredPane(); input.setColumns(50); output.setColumns(50); output.setRows(30); output.setEditable(false); output.setBackground(Color.BLACK); output.setForeground(Color.WHITE); input.requestFocus(); // start with focus on this field output.setBounds(0, 0, 550, 310); Display.add(output, javax.swing.JLayeredPane.DEFAULT_LAYER); input.setBounds(0, 320, 550, 25); Display.add(input, javax.swing.JLayeredPane.DEFAULT_LAYER); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addComponent( Display, javax.swing.GroupLayout.PREFERRED_SIZE, 550, javax.swing.GroupLayout.PREFERRED_SIZE))); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent( Display, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE)))); pack(); }
public void initialize() { initializePropertyTable(); initializeWidgets(); initializeFlags(); setupKeys(); setVisible(true); this.setTitle(TITLE); nameField_.requestFocus(); setFocusable(true); update(); }
public boolean toggle() { boolean visible = !isVisible(); setVisible(visible); if (visible) { searchField.requestFocus(); searchField.selectAll(); } else { rTextArea.requestFocus(); } return visible; }
public void fokusniSe() { Container panel = null; for (Container comp = this; comp != null; comp = comp.getParent()) { if (comp instanceof JTabbedPane) { final JTabbedPane tabpane = (JTabbedPane) comp; tabpane.setSelectedComponent(panel); break; } panel = comp; } jtext.requestFocus(); }