List of usage examples for javax.swing JTextField getText
public String getText()
TextComponent
. From source file:com.mgmtp.perfload.loadprofiles.ui.component.DoubleCellEditor.java
public DoubleCellEditor() { super(new JTextField()); final JTextField textField = (JTextField) getComponent(); textField.setHorizontalAlignment(SwingConstants.RIGHT); delegate = new EditorDelegate() { @Override/*w w w . ja v a2 s. c om*/ public void setValue(final Object value) { textField.setText(value != null ? FORMAT.format(value) : null); } @Override public Object getCellEditorValue() { return textField.getText(); } }; textField.addActionListener(delegate); }
From source file:com.biosis.biosislite.vistas.Configuracion.java
private void guardar(Properties fichero, String urlFichero, JComboBox combo, JTextField txtConexion, JTextField txtUsuario, JTextField txtPassword) { int tipoBD = combo.getSelectedIndex() + 1; // String driver = ParametrosUtil.obtenerDriver(tipoBD); String url = txtConexion.getText(); String usuario = txtUsuario.getText(); String password = txtPassword.getText(); // combo.setSelectedIndex(tipoBD - 1); txtConexion.setText(url);/*w w w . j a v a 2 s . co m*/ txtUsuario.setText(usuario); txtPassword.setText(password); fichero.setProperty("url", url); fichero.setProperty("usuario", usuario); fichero.setProperty("password", Encriptador.encrypt(password)); fichero.setProperty("tipo", tipoBD + ""); PropertiesUtil.guardarProperties(fichero, urlFichero); }
From source file:edu.harvard.mcz.imagecapture.ui.FilteringAgentJComboBox.java
private void init() { // listen for loss of focus on the text field this.getEditor().getEditorComponent().addFocusListener(this); this.setEditable(true); final JTextField textfield = (JTextField) this.getEditor().getEditorComponent(); textfield.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { log.debug(keyEvent);//from w w w . j av a2 s . co m SwingUtilities.invokeLater(new Runnable() { public void run() { filter(textfield.getText(), true); } }); } }); }
From source file:com.willwinder.ugs.nbp.setupwizard.panels.WizardPanelStepCalibration.java
private void updateEstimationFromMesurement(JTextField textFieldMesurement, Axis axis, JLabel label) { if (getBackend().getWorkPosition() != null) { try {/*from w w w .ja v a2 s . c o m*/ double measured = decimalFormat.parse(textFieldMesurement.getText()).doubleValue(); double real = getBackend().getWorkPosition().get(axis); int stepsPerMM = getBackend().getController().getFirmwareSettings().getStepsPerMillimeter(axis); double computed = (real / measured) * ((double) stepsPerMM); if (measured == 0 || real == 0) { computed = 0; } label.setText(Math.abs(Math.round(computed)) + " steps/mm est."); } catch (FirmwareSettingsException | ParseException ignored) { // Never mind } } }
From source file:com.biosis.biosislite.vistas.Configuracion.java
private void guardar(Properties fichero, String urlFichero, JComboBox combo, JTextField txtConexion, JTextField txtUsuario, JTextField txtPassword, boolean selected) { int tipoBD = combo.getSelectedIndex() + 1; // String driver = ParametrosUtil.obtenerDriver(tipoBD); String url = txtConexion.getText(); String usuario = txtUsuario.getText(); String password = txtPassword.getText(); // combo.setSelectedIndex(tipoBD - 1); txtConexion.setText(url);/*from ww w . j a va 2 s. c o m*/ txtUsuario.setText(usuario); txtPassword.setText(password); fichero.setProperty("url", url); fichero.setProperty("usuario", usuario); fichero.setProperty("password", Encriptador.encrypt(password)); fichero.setProperty("tipo", tipoBD + ""); if (selected) { fichero.setProperty("action", "create"); } else { fichero.setProperty("action", "none"); } PropertiesUtil.guardarProperties(fichero, urlFichero); }
From source file:de.codesourcery.jasm16.ide.ui.views.HexDumpView.java
protected JPanel createPanel() { textArea.setEditable(false);//from w w w .j a va 2s . c o m setColors(textArea); textArea.setFont(getMonospacedFont()); textArea.setEditable(false); // dump panel final JPanel dumpPanel = new JPanel(); setColors(dumpPanel); dumpPanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH); dumpPanel.add(textArea, cnstrs); // toolbar panel final JPanel toolbarPanel = new JPanel(); setColors(toolbarPanel); toolbarPanel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); toolbarPanel.add(new JLabel("Goto"), cnstrs); final JTextField gotoTextfield = new JTextField(); gotoTextfield.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String val = gotoTextfield.getText(); Address adr; if (StringUtils.isBlank(val)) { gotoTextfield.setText("0000"); adr = Address.wordAddress(0); } else { try { adr = Address.wordAddress(Misc.parseHexString(val)); } catch (NumberFormatException e1) { gotoTextfield.setText("0000"); adr = Address.wordAddress(0); } } dumpStartAddress = adr; refreshDisplay(); } }); cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL); toolbarPanel.add(gotoTextfield, cnstrs); // create result panel final JPanel result = new JPanel(); setColors(result); result.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, true, GridBagConstraints.BOTH); result.add(dumpPanel, cnstrs); cnstrs = constraints(1, 0, true, true, GridBagConstraints.VERTICAL); result.add(toolbarPanel, cnstrs); textArea.addKeyListener(new PagingKeyAdapter() { @Override protected void onePageUp() { HexDumpView.this.onePageUp(); } @Override protected void onePageDown() { HexDumpView.this.onePageDown(); } @Override protected void oneLineUp() { HexDumpView.this.oneLineUp(); } @Override protected void oneLineDown() { HexDumpView.this.oneLineDown(); } }); result.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { refreshDisplay(); } }); return result; }
From source file:io.github.jeremgamer.editor.ManagerFrame.java
public ManagerFrame(String projectName, final JFrame parent) { dialog = this; ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>(); try {// w w w .j a v a 2s . c o m icons.add(ImageIO.read(ImageGetter.class.getResource("icon16.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon32.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon64.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon128.png"))); } catch (IOException e1) { e1.printStackTrace(); } this.setIconImages((List<? extends Image>) icons); this.setTitle("Grer les projets"); this.setSize(300, 200); this.setModal(true); this.setLocationRelativeTo(parent); this.setResizable(false); final JScrollPane scroll = new JScrollPane(content); scroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); content.setBorder(BorderFactory.createTitledBorder("")); content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS)); for (File project : new File("projects").listFiles()) { if (project.getName().equals(Editor.getProjectName())) { content.add(new ProjectPanel(project.getName(), true, parent, this)); } else { content.add(new ProjectPanel(project.getName(), false, parent, this)); } } try { final JButton add = new JButton("Crer un nouveau projet", new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); newProjectPanel.add(newProjectName); newProjectPanel.add(validate); this.setLayout(new BorderLayout()); scroll.setBorder(null); this.add(scroll, BorderLayout.CENTER); this.add(add, BorderLayout.SOUTH); add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { validate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); parent.dispose(); new Thread(new Runnable() { public void run() { window.getContentPane() .add(new JLabel("", new ImageIcon(ImageGetter.class.getResource("splash.gif")), SwingConstants.CENTER)); window.setBackground(new Color(0, 0, 0, 0)); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); } }).start(); new Thread(new Runnable() { public void run() { new Editor(newProjectName.getText()); window.setVisible(false); } }).start(); } }); CaretListener caretUpdate = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); for (File dir : new File("projects").listFiles()) { if (dir.isDirectory() && text.getText().equals(dir.getName())) { validate.setEnabled(false); validate.setText("Existe dj"); break; } else { validate.setEnabled(true); validate.setText("Crer!"); } } } }; JButton cancel = null; try { cancel = new JButton( new ImageIcon(ImageIO.read(ImageGetter.class.getResource("cancel.png")))); } catch (IOException e1) { e1.printStackTrace(); } newProjectName.addCaretListener(caretUpdate); remove(add); addPanel.setLayout(new BorderLayout()); addPanel.add(newProjectPanel, BorderLayout.CENTER); addPanel.add(cancel, BorderLayout.EAST); add(addPanel, BorderLayout.SOUTH); revalidate(); repaint(); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { newProjectName.setText(""); remove(addPanel); add(add, BorderLayout.SOUTH); revalidate(); repaint(); } }); newProjectName.requestFocusInWindow(); newProjectName.requestFocus(); } }); this.setVisible(true); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.sec.ose.osi.ui.frm.main.identification.JComboProjectName.java
public JComboProjectName() { this.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); this.setEditable(true); this.setPreferredSize(new Dimension(400, 27)); this.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { long start = System.currentTimeMillis(); actionOnProjectSelectedonProjectComboBox(); long end = System.currentTimeMillis(); log.debug(// w w w . ja v a 2s . c om "[JComboProjectName.addActionListener()] Project Loding TIME : " + (end - start) / 1000.0); } }); final JTextField editor = (JTextField) this.getEditor().getEditorComponent(); editor.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); int count = 0; String newProjectName = editor.getText(); if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))) { return; } if (newProjectName.length() <= 0 && ch == KeyEvent.VK_BACK_SPACE) { count++; if (count >= 2) { String projectName = IdentifyMediator.getInstance().getSelectedProjectName(); ((JTextField) JComboProjectName.this.getEditor().getEditorComponent()).setText(projectName); count = 0; return; } } if (JComboProjectName.this.getComponentCount() > 0) { JComboProjectName.this.removeAllItems(); } JComboProjectName.this.addItem(newProjectName); try { Collection<OSIProjectInfo> ProjectsInfo = OSIProjectInfoMgr.getInstance().getAllProjects(); String tmpProName = null; boolean bAnalysis = false; if (newProjectName.length() > 0) { for (OSIProjectInfo projectInfo : ProjectsInfo) { tmpProName = projectInfo.getProjectName(); bAnalysis = projectInfo.isAnalyzed(); if (tmpProName.toLowerCase().contains(newProjectName.toLowerCase()) && bAnalysis) JComboProjectName.this.addItem(tmpProName); } if (JComboProjectName.this.getItemCount() <= 1) { JComboProjectName.this.removeAllItems(); JOptionPane.showOptionDialog(null, "There is no project.", "Project Filter", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, buttonOK, "OK"); } } else { for (OSIProjectInfo projectInfo : ProjectsInfo) { if (projectInfo.isManaged() == true && projectInfo.isAnalyzed()) { JComboProjectName.this.addItem(projectInfo.getProjectName()); } } JComboProjectName.this.addItem(DIVIDER_LINE); for (OSIProjectInfo projectInfo : ProjectsInfo) { if (projectInfo.isManaged() == false && projectInfo.isAnalyzed()) { JComboProjectName.this.addItem(projectInfo.getProjectName()); } } ((JTextField) JComboProjectName.this.getEditor().getEditorComponent()).setText(""); } } catch (Exception e1) { log.warn(e1.getMessage()); } JComboProjectName.this.hidePopup(); if (newProjectName.length() > 0) JComboProjectName.this.showPopup(); } }); }
From source file:edu.harvard.mcz.imagecapture.ui.FilteringGeogJComboBox.java
private void init() { countryLimit = ""; stateprovLimit = ""; cachedModel = null;/*from www . j a v a2 s .com*/ lastTextLength = 0; // listen for loss of focus on the text field this.getEditor().getEditorComponent().addFocusListener(this); this.setEditable(true); final JTextField textfield = (JTextField) this.getEditor().getEditorComponent(); textfield.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { log.debug(keyEvent); SwingUtilities.invokeLater(new Runnable() { public void run() { filter(textfield.getText(), true); } }); } }); }
From source file:com.smanempat.controller.ControllerClassification.java
private void showOnTable(ActionEvent evt, JTextField txtFileDirectory, JTable tablePreview) { try {/* w w w .ja v a2 s . c o m*/ if (txtFileDirectory.getText().endsWith(".xls")) { System.out.println("This File .XLS"); showXLS(txtFileDirectory, tablePreview); } else if (txtFileDirectory.getText().endsWith(".xlsx")) { System.out.println("This File .XLSX"); showXLSX(txtFileDirectory, tablePreview); } else { System.out.println("You must be choosing one of Excel file."); } } catch (Exception e) { } }