当前位置: 首页>>代码示例>>Java>>正文


Java JTextField.getText方法代码示例

本文整理汇总了Java中javax.swing.JTextField.getText方法的典型用法代码示例。如果您正苦于以下问题:Java JTextField.getText方法的具体用法?Java JTextField.getText怎么用?Java JTextField.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTextField的用法示例。


在下文中一共展示了JTextField.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doFind

import javax.swing.JTextField; //导入方法依赖的package包/类
/** This method performs Edit->Find. */
private Runner doFind() {
    if (wrap) return wrapMe();
    JTextField x = OurUtil.textfield(lastFind,30);
    x.selectAll();
    JCheckBox c = new JCheckBox("Case Sensitive?",lastFindCaseSensitive);
    c.setMnemonic('c');
    JCheckBox b = new JCheckBox("Search Backward?",!lastFindForward);
    b.setMnemonic('b');
    if (!OurDialog.getInput("Find", "Text:", x, " ", c, b)) return null;
    if (x.getText().length() == 0) return null;
    lastFind = x.getText();
    lastFindCaseSensitive = c.getModel().isSelected();
    lastFindForward = !b.getModel().isSelected();
    doFindNext();
    return null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:18,代码来源:SimpleGUI.java

示例2: edit

import javax.swing.JTextField; //导入方法依赖的package包/类
public boolean edit() {
  descriptionField = new JTextField(description);
  addressField = new JTextField(address);
  portField = new JTextField(port);

  final JPanel editPanel = new JPanel(new MigLayout("", "[align right]rel[]", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
  editPanel.add(new JLabel(Resources.getString("Editor.description_label"))); //$NON-NLS-1$
  editPanel.add(descriptionField, "wrap, grow, push"); //$NON-NLS-1$
  editPanel.add(new JLabel(Resources.getString("Chat.ip_address"))); //$NON-NLS-1$
  editPanel.add(addressField, "wrap, grow, push"); //$NON-NLS-1$
  editPanel.add(new JLabel(Resources.getString("ServerAddressBook.port"))); //$NON-NLS-1$
  editPanel.add(portField, "wrap, grow, push"); //$NON-NLS-1$

  final Integer result = (Integer) Dialogs.showDialog(null, Resources.getString("Peer2Peer.add_peer_connection"), //$NON-NLS-1$
      editPanel, JOptionPane.PLAIN_MESSAGE, null, JOptionPane.OK_CANCEL_OPTION,
      null, null, null, null);

  if (result != null && result == 0) {
    description = descriptionField.getText();
    address = addressField.getText();
    port = portField.getText();
    return true;
  }

  return false;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:27,代码来源:DirectPeerPool.java

示例3: verifyDomainRangeUpperBoundInput

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Verify that the x-value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyDomainRangeUpperBoundInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		double domainUpperBound;
		if (inputString.startsWith("-")) {
			domainUpperBound = Double.parseDouble(inputString.substring(1));
			domainUpperBound = -domainUpperBound;
		} else {
			domainUpperBound = Double.parseDouble(inputString);
		}
		// TODO: fix check for actual ranges
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:ManageZoomDialog.java

示例4: verifyDomainRangeLowerBoundInput

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Verify that the y-value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyDomainRangeLowerBoundInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		double domainLowerBound;
		if (inputString.startsWith("-")) {
			domainLowerBound = Double.parseDouble(inputString.substring(1));
			domainLowerBound = -domainLowerBound;
		} else {
			domainLowerBound = Double.parseDouble(inputString);
		}
		// TODO: fix check for actual ranges
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:ManageZoomDialog.java

示例5: validateTextField

import javax.swing.JTextField; //导入方法依赖的package包/类
private double validateTextField(JTextField textField,
        double def, double min, double max) {
    double value = def;
    String text = textField.getText();
    if (!text.equals("") && !text.equals(" ")) {
        try {
            value = Double.parseDouble(text);
            if (value < min) {
                value = min;
            }
            if (value > max) {
                value = max;
            }
        } catch (NumberFormatException e) {
        }
    }
    textField.setText(String.format("%1.2f", value));
    return value;
}
 
开发者ID:vimerzhao,项目名称:gchisto,代码行数:20,代码来源:PlaybackFrame.java

示例6: verifyValueRangeUpperBoundInput

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Verify that the height value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyValueRangeUpperBoundInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		double valueUpperBound;
		if (inputString.startsWith("-")) {
			valueUpperBound = Double.parseDouble(inputString.substring(1));
			valueUpperBound = -valueUpperBound;
		} else {
			valueUpperBound = Double.parseDouble(inputString);
		}
		// TODO: fix check for actual ranges
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:ManageZoomDialog.java

示例7: verifyColorInput

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Verify that the color value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyColorInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		double color;
		if (inputString.startsWith("-")) {
			color = Double.parseDouble(inputString.substring(1));
			color = -color;
		} else {
			color = Double.parseDouble(inputString);
		}
		// TODO: fix check for actual ranges
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:ManageZoomDialog.java

示例8: setQntIng

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Setta la qnt dell'ingrediente che si vuole aggiungere
 * @param jIng
 * @param jQnt
 * @param ing
 * @param qnt
 */
public void setQntIng(JTextField jIng, JTextField jQnt, String ing, int qnt){
     try{
         if(jIng.getText().isEmpty() || jQnt.getText().isEmpty()){
            ing=null;
            qnt=0;
        }else{
            ing = jIng.getText();
            qnt = Integer.valueOf(jQnt.getText());
            p.getIngredienti().add(new Ingredient(ing, qnt));
        }

     }catch(NumberFormatException ex){
         JOptionPane.showMessageDialog(rootPane,"Quantità non valida!");
         controllo = false;
     }
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-N,代码行数:24,代码来源:GuiAddPortata.java

示例9: getPathFromJTextField

import javax.swing.JTextField; //导入方法依赖的package包/类
private File getPathFromJTextField(JTextField tf) {
    File ret = new File(".");
    String text = tf.getText();
    if (text.length() > 0) {
        File f = new File(text);
        if (f != null) {
            if (f.isDirectory()) {
                ret = f;
            } else if (f.isFile()) {
                ret = f.getParentFile();
            }
        }
    }
    return ret;
}
 
开发者ID:spetitjean,项目名称:TuLiPA-frames,代码行数:16,代码来源:InputGUI.java

示例10: richiediNome

import javax.swing.JTextField; //导入方法依赖的package包/类
private void richiediNome() {
    nome = null;
    askNome = new JTextField();
    JButton askNomeButton = new JButton(caricaImmagine("dominio/immagini/fatto.png"));
    JLabel askNomeLabel = new JLabel(caricaImmagine("dominio/immagini/richiediNome.png"));
    ActionListener action_nome_inserito = new ActionListener(){
        @Override
        public void actionPerformed(ActionEvent e) {
            nome = askNome.getText();
        };
    };
        
    askNome.setFont(new Font("nome", 1, 40));
        
    askNome.setBounds(this.getWidth()/2 - 125, 300, 250, 80);
    askNomeButton.setBounds(this.getWidth()/2 - 100, 400, 200, 80);
    askNomeLabel.setBounds(this.getWidth()/2 - 200, 100, 400, 80);
    
    askNome.addActionListener(action_nome_inserito);  
    askNomeButton.addActionListener(action_nome_inserito);
        
    sfondo.add(askNome);
    sfondo.add(askNomeButton);
    sfondo.add(askNomeLabel);            
    sfondo.repaint();
    
    while(nome == null) {
        pausa(100);
    }
        
    sfondo.removeAll(); 
    sfondo.repaint();
        
    fireViewEvent(new SetNome(nome));
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-A,代码行数:36,代码来源:PartitaOfflineGuiView.java

示例11: focusLost

import javax.swing.JTextField; //导入方法依赖的package包/类
@Override
public void focusLost(FocusEvent e) {
    Object source = e.getSource();
    if (source instanceof JTextField) {
        JTextField textField = (JTextField) source;
        String inputText = textField.getText();
        switch(targetToken) {
            case JdbcUrl.TOKEN_HOST:
            case JdbcUrl.TOKEN_DB:
            case JdbcUrl.TOKEN_SID:
            case JdbcUrl.TOKEN_SERVICENAME:
            case JdbcUrl.TOKEN_TNSNAME:
            case JdbcUrl.TOKEN_DSN:
            case JdbcUrl.TOKEN_SERVERNAME:
            case JdbcUrl.TOKEN_INSTANCE:
            case USERINPUT_FIELD:
                textField.setText(inputText.trim());
                break;
            case JdbcUrl.TOKEN_PORT:
                Integer port = null;
                try {
                    port = Integer.valueOf(inputText.trim());
                } catch (NumberFormatException ex) {}
                if(port != null) {
                    textField.setText(Integer.toString(port));
                } else {
                    Matcher numberMatcher = numbers.matcher(inputText);
                    if(numberMatcher.find()) {
                        textField.setText(numberMatcher.group(1));
                    } else {
                        textField.setText("");
                    }
                }
                break;
            default:
                // Unhandled fields are left untouched
                break;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:NewConnectionPanel.java

示例12: verifyYInput

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Verify that the y-value is correct.
 * 
 * @param input
 * @return true if the value is valid; false otherwise
 */
private boolean verifyYInput(JComponent input) {
	JTextField textField = (JTextField) input;
	String inputString = textField.getText();
	try {
		Double.parseDouble(inputString);
	} catch (NumberFormatException e) {
		textField.setForeground(Color.RED);
		return false;
	}

	textField.setForeground(Color.BLACK);
	return true;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:20,代码来源:AddParallelLineDialog.java

示例13: getCredential

import javax.swing.JTextField; //导入方法依赖的package包/类
Credential getCredential(String shost, String suser, String spass) {
	JTextField host = new JTextField(shost);
	JTextField user = new JTextField(suser);
	JPasswordField pass = new JPasswordField(spass);
	Object[] obj = new Object[6];
	obj[0] = getString("HOST");
	obj[1] = host;
	obj[2] = getString("USER_NAME");
	obj[3] = user;
	obj[4] = getString("PASSWORD");
	obj[5] = pass;

	while (JOptionPane.showOptionDialog(null, obj, getString("LBL_CR"),
			JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
			null, null, null) == JOptionPane.OK_OPTION) {
		if (host.getText() == null || host.getText().length() < 1) {
			JOptionPane.showMessageDialog(null, getString("LBL_HOST"));
			continue;
		}
		if (user.getText() == null || user.getText().length() < 1) {
			JOptionPane.showMessageDialog(null, getString("LBL_USER"));
			continue;
		}

		Credential c = new Credential();
		c.host = host.getText();
		c.user = user.getText();
		c.pass = pass.getPassword().length > 0 ? new String(pass
				.getPassword()) : null;
		return c;
	}
	return null;
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:34,代码来源:ConfigDialog.java

示例14: parseNumber

import javax.swing.JTextField; //导入方法依赖的package包/类
private Double parseNumber(JTextField field) throws NumberFormatException {
	if (field.getText() == null || field.getText().length() == 0) {
		throw new NumberFormatException("No value selected for field '" + field.getName() + "'.");
	} else {
		try {
			return Double.valueOf(field.getText());
		} catch (Exception ex) {
			throw new NumberFormatException("Value '" + field.getText() + "' for field '" + field.getName() + "' is not a valid number.");
		}
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:12,代码来源:StatisticalOutputsWindow.java

示例15: getConstantFrom

import javax.swing.JTextField; //导入方法依赖的package包/类
public void getConstantFrom(JComponent cmp) {
    JTextField tf = (JTextField) cmp;
    constant = tf.getText();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:StringFilterCondition.java


注:本文中的javax.swing.JTextField.getText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。