List of usage examples for javax.swing JTextField setText
@BeanProperty(bound = false, description = "the text of this component") public void setText(String t)
TextComponent
to the specified text. From source file:tools.help.java
/** * kontrolor na double tie meni bodku ?iarku * * @param Y Jtext field vstup/*from ww w . j a va2s . co m*/ * @param output ak je Y kokoina tak vyhodi tuto hodnotu * @return */ public static double ReadCheckDouble(javax.swing.JTextField Y, double output) { String hodnota1 = Y.getText(); hodnota1 = hodnota1.replace(" ", ""); String hodnota2 = hodnota1.replace(",", "."); if (hodnota1.equals(hodnota2)) { } else { Y.setText(hodnota2); } Double value; try { value = Double.parseDouble(hodnota2); Y.setForeground(Color.black); return value; } catch (NumberFormatException | NullPointerException e) { Y.setForeground(Color.red); return value = output; } }
From source file:tools.help.java
/** * vyluje to iste ?islo po kontrole a ak je kokotnia tak vrati hodnotu aout * put, a ete ak je kokotina tak vyhodi error sigh * * @param Y Jtext field// w w w . java 2 s. co m * @param output * @return */ public static double ReadCheckDoubleErrorSign(javax.swing.JTextField Y, double output) { String hodnota1 = Y.getText(); hodnota1 = hodnota1.replace(" ", ""); String hodnota2 = hodnota1.replace(",", "."); if (hodnota1.equals(hodnota2)) { } else { Y.setText(hodnota2); } Double value; try { value = Double.parseDouble(hodnota2); Y.setForeground(Color.black); return value; } catch (NumberFormatException | NullPointerException e) { Y.setForeground(Color.red); help.warning1row(language_help.LangLabel(constants.getLanguage_option(), 3)); return value = output; } }
From source file:tools.help.java
public static int ReadCheckIntErrorSign(javax.swing.JTextField Y, int output, String error) { String hodnota1 = Y.getText(); hodnota1 = hodnota1.replace(" ", ""); String hodnota2 = hodnota1.replace(",", "."); if (hodnota1.equals(hodnota2)) { } else {/*from w w w .j ava2 s. c o m*/ Y.setText(hodnota2); } int value; try { value = Integer.parseInt(hodnota2); Y.setForeground(Color.black); return value; } catch (NumberFormatException | NullPointerException e) { Y.setForeground(Color.red); help.warning1row(error); return value = output; } }
From source file:tools.help.java
/** * vlozi hodnotu to text fildu a upravi jej pocet des miest * * @param Y text field vstup/* w w w .ja va 2s . c o m*/ * @param input value ktoru chem zobrazit v textfielde * @param pocetDesMiest pocet desatinnich miest na ktore bude zaukruhlovat * cislo */ public static void DisplayDouble(javax.swing.JTextField Y, double input, int pocetDesMiest) { String symbol = "###."; for (int cl0 = 0; cl0 < pocetDesMiest; cl0++) { symbol = symbol + "#"; } DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(); otherSymbols.setDecimalSeparator('.'); DecimalFormat df = new DecimalFormat(symbol, otherSymbols); // definovany po?et desatinnych miest Y.setText(df.format(input)); }
From source file:TrabajoFinalJava.DescargaFichero.java
@Override public void run() { //************************INICIO****INTERFAZ************************************************************************** JFrame principal = new JFrame("GESTOR DESCARGAS"); //Colores// ww w. java 2 s .c o m Color nuevoColor = new Color(167, 220, 231); principal.getContentPane().setBackground(nuevoColor); JLabel tituloPrincipal = new JLabel("GESTOR DESCARGAS"); JLabel tituloVentana = new JLabel("DESCARGA FICHERO FTP"); //Recojo la fuente que se esta utilizando actualmente. Font auxFont = tituloPrincipal.getFont(); //Aplico la fuente actual, y al final le doy el tamao del texto... tituloPrincipal.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 30)); tituloVentana.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 30)); //tituloVentana.setAlignmentY(0); JLabel nombreArchivo = new JLabel("INTRODUCE EL NOMBRE DEL FICHERO A DESCARGAR."); JTextField nombreArchivoIn = new JTextField(); JButton descarga = new JButton("DESCARGA FICHERO."); JButton atras = new JButton("ATRAS"); JButton salir = new JButton("Salir"); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); //Asignamos la constante EXIT_ON_CLOSE, cierra la ventana al pulsar la X. principal.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Asignamos al JFrame el Layout que usaremos, GridBagLayout principal.setLayout(gridbag); //aadir botones al layout gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; // La fila 0 debe estirarse, le ponemos un 1.0 gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(tituloPrincipal, gbc); gbc.gridx = 1; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; // La fila 0 debe estirarse, le ponemos un 1.0 gbc.fill = GridBagConstraints.NONE; principal.add(tituloVentana, gbc); gbc.gridx = 1; gbc.gridy = 2; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(nombreArchivo, gbc); gbc.gridx = 1; gbc.gridy = 3; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(nombreArchivoIn, gbc); gbc.gridx = 1; gbc.gridy = 4; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.NONE; principal.add(descarga, gbc); gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.NONE; principal.add(atras, gbc); gbc.gridx = 1; gbc.gridy = 5; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; // La fila 0 debe estirarse, le ponemos un 1.0 gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(salir, gbc); //Hace visible el panel principal.setVisible(true); principal.setSize(650, 350); principal.setLocationRelativeTo(null); principal.setResizable(false); //principal.pack(); descarga.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (descargasUsuarioLog <= 9) { try { cFtp.connect(ftpSsrver); boolean login = cFtp.login(ftpUser, ftpPass); System.out.print("conexion establecida"); cFtp.enterLocalPassiveMode(); nombreFichero = nombreArchivoIn.getText(); nombrePc = nombreArchivoIn.getText(); CrearListaFicheros listarFicheros = new CrearListaFicheros(); listarFicheros.start(); for (int i = 0; i < CrearListaFicheros.arrayArchivos.size(); i++) { System.out.println(CrearListaFicheros.arrayArchivos.get(i)); } if (CrearListaFicheros.arrayArchivos.contains(nombreFichero)) { FTPFile file = cFtp.mlistFile(nombreFichero); long size = file.getSize(); System.out.println("Tamao del fichero= " + size); if (size > 1000000) { System.out.println("El fichero es muy grande......"); } else { FileOutputStream fos = new FileOutputStream(nombreFichero); cFtp.retrieveFile(nombreFichero, fos); System.out.println(""); System.out.println("Archivo recibido"); nombreArchivoIn.setBackground(Color.green); descargasUsuarioLog = descargasUsuarioLog + 1; System.out.println(descargasUsuarioLog); //modificamos las descargas totales del usuario en la BBDD Connection conn; try { try { Class.forName("com.mysql.jdbc.Driver"); } catch (Exception y) { y.printStackTrace(); } conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/midb", "root", ""); System.out.println("Conn OK!"); stmt = conn.createStatement(); stmt.executeUpdate("UPDATE usuarios SET bajadas = '" + descargasUsuarioLog + "' WHERE usuario = '" + usuarioLog + "';"); System.out.print("Descargas modificadas correctamente."); conn.close(); } catch (Exception i) { System.out.println(e); } } } else { System.out.println("El fichero no existe..."); nombreArchivoIn.setText("El fichero no existe"); } } catch (IOException r) { r.printStackTrace(); } } else { System.out.println( "No te quedan descargas... por favor comuniquese con el administrador del servidor. Gracias."); nombreArchivoIn.setText( "No te quedan descargas... por favor comuniquese con el administrador del servidor. Gracias."); } } }); atras.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FormularioAccesoFtp accesoFtp = new FormularioAccesoFtp(); accesoFtp.inicioFtp(); principal.setVisible(false); } }); salir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(1000); } }); }
From source file:ucar.unidata.ui.HttpFormEntry.java
/** * Open a file browser associated with the text field * * @param fld the JTextField/* w w w. j a v a 2s. c o m*/ */ public void browse(JTextField fld) { String f = fld.getText(); JFileChooser chooser = new FileManager.MyFileChooser(f); if (chooser.showOpenDialog(fld) == JFileChooser.APPROVE_OPTION) { fld.setText(chooser.getSelectedFile().toString()); } }
From source file:uk.ac.liverpool.narrative.SolutionGraph.java
/** * @param template/*from w w w .j a v a 2 s. co m*/ * @param out * @param in * @param current * @return * @throws IOException */ private StringBuilder mainLoop(final Template template, final JTextArea out, final JTextField in, STRIPSState current) throws IOException { Collection<Action> aa = ggraph.getOutEdges(current); StringBuilder ssf = new StringBuilder(); if (aa == null) { out.append("No action from the start?\n"); return ssf; } do { if (aa.size() == 1) { Action a = aa.iterator().next(); out.append(actionToString(template, a)); ssf.append(actionToString(template, a)); if (a != null) { current = ggraph.getOpposite(current, a); } } else if (aa.size() > 1) { int n = 0; final Map<Integer, Action> hm = new MapWrapper<Integer, Action>(); out.append(" Please select the next action: " + "\n"); Iterator<Action> it = aa.iterator(); while (it.hasNext()) { n++; Action a = it.next(); out.append(" " + n + ") " + actionToString(template, a)); hm.put(n, a); } out.append("" + "\n"); final STRIPSState c2 = current; in.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_ENTER) return; int a = 0; String s = in.getText(); try { a = Integer.parseInt(s); } catch (Exception x) { } try { a = Integer.parseInt(s); Action a2 = hm.get(a); if (a2 != null) { out.append(actionToString(template, a2)); in.removeKeyListener(this); in.setText(""); mainLoop(template, out, in, ggraph.getOpposite(c2, a2)); } } catch (Exception x) { return; } super.keyReleased(e); } }); return ssf; } else { break; } aa = ggraph.getOutEdges(current); } while (aa.size() > 0); out.append("The end"); return ssf; }
From source file:uk.ac.ucl.chime.wrappers.RMTreeConstructor.java
private void addTextBox(String content) { JTextField fld = new JTextField(); _panelToFill.add(fld);/* w w w. ja v a2 s . co m*/ fld.setBounds(_lastX + 30 + 200, _lastY - (_defaultHeight + _verticalGap), 150, _defaultHeight); fld.setText(content); _panelToFill.revalidate(); }
From source file:us.paulevans.basicxslt.BasicXSLTFrame.java
/** * Helper method that populates aTextField by presenting a file-open dialog * to the user.//from w ww. j av a 2 s .c o m * @param aTextField */ public void populateTFFromFileDialog(JTextField aTextField) throws IOException { int returnVal; File file; Utils.getInstance().getFileChooser().setDialogType(JFileChooser.OPEN_DIALOG); returnVal = Utils.getInstance().getFileChooser().showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { file = Utils.getInstance().getFileChooser().getSelectedFile(); setLastFileChosen(file.getAbsolutePath()); aTextField.setText(file.getAbsolutePath()); } }
From source file:us.paulevans.basicxslt.TransformParametersFrame.java
/** * Rebuilds the parameters panel// w w w. j a v a 2 s . c om * */ private void rebuildParametersPanel() { int loop, row, size; JTextField paramNameTf, paramValueTf, paramNamespaceURITf; JCheckBox removeCb; String paramNames[]; ParameterTextFieldGroup paramTfGroup; row = 0; parametersPanel.removeAll(); GUIUtils.add(parametersPanel, new JLabel(stringFactory.getString(LabelStringFactory.PARAMS_FRAME_NAME_LBL)), parametersPanelLayout, parametersPanelConstraints, row, 0, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, GUIUtils.SMALL_INSETS); GUIUtils.add(parametersPanel, new JLabel(stringFactory.getString(LabelStringFactory.PARAMS_FRAME_VALUE_LBL)), parametersPanelLayout, parametersPanelConstraints, row, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, GUIUtils.SMALL_INSETS); GUIUtils.add(parametersPanel, new JLabel(stringFactory.getString(LabelStringFactory.PARAMS_FRAME_NAMESPACE_URI_LBL)), parametersPanelLayout, parametersPanelConstraints, row, 2, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, GUIUtils.SMALL_INSETS); GUIUtils.add(parametersPanel, new JLabel(stringFactory.getString(LabelStringFactory.PARAMS_FRAME_REMOVE_LBL)), parametersPanelLayout, parametersPanelConstraints, row++, 3, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, GUIUtils.SMALL_INSETS); paramNames = parameters.getParameterNames(); size = parameterTextFieldGroups.size(); for (loop = 0; loop < size; loop++) { paramTfGroup = (ParameterTextFieldGroup) parameterTextFieldGroups.get(loop); GUIUtils.add(parametersPanel, paramNameTf = paramTfGroup.getParamNameTf(), parametersPanelLayout, parametersPanelConstraints, row, 0, 1, 1, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, GUIUtils.SMALL_INSETS); GUIUtils.add(parametersPanel, paramValueTf = paramTfGroup.getParamValueTf(), parametersPanelLayout, parametersPanelConstraints, row, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, GUIUtils.SMALL_INSETS); GUIUtils.add(parametersPanel, paramNamespaceURITf = paramTfGroup.getParamNamespaceURITf(), parametersPanelLayout, parametersPanelConstraints, row, 2, 1, 1, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, GUIUtils.SMALL_INSETS); GUIUtils.add(parametersPanel, removeCb = paramTfGroup.getRemoveCb(), parametersPanelLayout, parametersPanelConstraints, row++, 3, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.SMALL_INSETS); removeCb.addActionListener(this); if (loop < paramNames.length) { paramNameTf.setText(TransformParameters.getParameterName(paramNames[loop])); paramValueTf.setText(parameters.getParameter(paramNames[loop]).toString()); paramNamespaceURITf.setText(TransformParameters.getNamespaceURI(paramNames[loop])); } } }