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


Java JTextField.setName方法代码示例

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


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

示例1: addInputString

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Adds an input field to insert a String
 * @param text text to be shown on a label
 * @param property property to be changed in Defaults
 * @param cont container where input field must be added
 */
protected void addInputString(String text, String property, Container cont) {
	JLabel label = new JLabel(text + ":");
	JTextField field = new JTextField(10);
	field.setName(property);
	label.setLabelFor(field);
	field.setText(Defaults.get(property));
	// Sets maximum size to minimal one, otherwise springLayout will stretch this
	field.setMaximumSize(new Dimension(field.getMaximumSize().width, field.getMinimumSize().height));
	field.addKeyListener(stringListener);
	field.addFocusListener(stringListener);
	registeredStringListener.add(field);
	cont.add(label);
	cont.add(field);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:21,代码来源:DefaultsEditor.java

示例2: addProbability

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Add a probability to an interval Panel If the probability is for
 * interval B the value is displayed as 1-probability
 * 
 * @param intervalPanel
 *            the intervalPanel
 * @param intervalA
 *            if the probability is for interval A or B
 */
protected void addProbability(Container intervalPanel, boolean intervalA) {
	JLabel probLabel = new JLabel(PROBABILITY);
	JTextField probValue = new JTextField();
	Double probability = (Double) current.getParameter(0).getValue();

	// If the interval is interval A display value directly
	// Otherwise display 1-probability
	if (intervalA) {
		probValue.setName(PROBABILITY_INTERVAL_A);
	} else {
		probability = new Double(1 - probability.doubleValue());
		probValue.setName(PROBABILITY_INTERVAL_B);
	}
	probValue.setText(probability.toString());
	probLabel.setLabelFor(probValue);

	probValue.addFocusListener(new ProbabilityAdapter());
	probValue.addKeyListener(new ProbabilityAdapter());

	GridBagConstraints c = new GridBagConstraints();
	c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
	c.fill = GridBagConstraints.NONE; // reset to default
	c.weightx = 0.0; // reset to default
	c.weighty = 1.0;
	intervalPanel.add(probLabel, c);

	c.gridwidth = GridBagConstraints.REMAINDER; // end row
	c.fill = GridBagConstraints.HORIZONTAL;
	c.weightx = 1.0;
	c.weighty = 1.0;
	intervalPanel.add(probValue, c);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:42,代码来源:DistributionsEditor.java

示例3: addProbability

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Add a probability to an interval Panel
 * If the probability is for interval B the value is displayed as 1-probability
 * @param intervalPanel the intervalPanel
 * @param intervalA if the probability is for interval A or B
 */
protected void addProbability(Container intervalPanel, boolean intervalA) {

	JLabel probLabel = new JLabel(PROBABILITY);
	JTextField probValue = new JTextField();
	Double probability = (Double) current.getParameter(0).getValue();

	//If the interval is interval A display value directly
	//Otherwise display 1-probability
	if (intervalA) {
		probValue.setName(PROBABILITY_INTERVAL_A);
	} else {
		probability = new Double(1 - probability.doubleValue());
		probValue.setName(PROBABILITY_INTERVAL_B);
	}
	probValue.setText(probability.toString());
	probLabel.setLabelFor(probValue);

	probValue.addFocusListener(new ProbabilityAdapter());
	probValue.addKeyListener(new ProbabilityAdapter());

	GridBagConstraints c = new GridBagConstraints();
	c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
	c.fill = GridBagConstraints.NONE; // reset to default
	c.weightx = 0.0; // reset to default
	c.weighty = 1.0;
	intervalPanel.add(probLabel, c);

	c.gridwidth = GridBagConstraints.REMAINDER; // end row
	c.fill = GridBagConstraints.HORIZONTAL;
	c.weightx = 1.0;
	c.weighty = 1.0;
	intervalPanel.add(probValue, c);

}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:41,代码来源:DistributionsEditor.java

示例4: getTableCellEditor

import javax.swing.JTextField; //导入方法依赖的package包/类
@Override
public TableCellEditor getTableCellEditor(Engine engine, AccessRules rules,
                                          Attribute attribute) {
    JTextField textField = new JTextField();
    textField.setName("Table.editor");
    return new DefaultCellEditor(textField);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:8,代码来源:TextAttributePlugin.java

示例5: addDistribution

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Adds a distribution to the given panel
 * 
 * @param name
 *            the name to be displayed on the label before the
 *            distribution
 * @param key
 *            to which parameter number in the Burst Distribution this
 *            nested distribution corresponds
 * @param intervalPanel
 *            the panel to which the distribution should be added
 */
protected void addDistribution(String name, int key,
		JPanel intervalPanel) {
	JLabel distributionNameLabel = new JLabel(name);

	// Add the name of the distribution on a single line
	GridBagConstraints c = new GridBagConstraints();
	c.insets = new Insets(10, 0, 0, 0); // top padding
	c.gridwidth = GridBagConstraints.REMAINDER; // end row after this
	// entry
	c.fill = GridBagConstraints.HORIZONTAL;
	// how to fill space when enlarging window vertically
	c.weightx = 1.0;
	c.weighty = 0.0;
	// Add the distribution
	intervalPanel.add(distributionNameLabel, c);

	// Add the edit button
	JButton but = new JButton("Edit");
	but.setAction(new EditButtonAction(key));
	// Specifies the button size to maintain its width in the case that
	// probability text fields are hidden
	// TODO check if the specified values are compatible with all
	// graphical systems
	but.setPreferredSize(new Dimension(65, 24));

	c.insets = new Insets(0, 0, 0, 0); // No space between Name of
	// distribution and Edit button
	// do not finish row because also the label for the distribution has
	// to be added
	c.gridwidth = GridBagConstraints.RELATIVE;
	c.fill = GridBagConstraints.HORIZONTAL; // reset to default
	c.weightx = 0.0; // reset to default
	c.weighty = 0.0;
	// Add the button
	intervalPanel.add(but, c);

	JTextField distributionValueTextField = new JTextField();
	// The name of the field is the parameter number
	distributionValueTextField.setName("" + key);
	// If the distribution != null display
	if (current.getParameter(key).getValue() != null) {
		distributionValueTextField.setText(current.getParameter(key)
				.getValue().toString());
	}
	// The value is not editable directly
	distributionValueTextField.setEditable(false);
	c.gridwidth = GridBagConstraints.REMAINDER; // end row
	c.fill = GridBagConstraints.HORIZONTAL;
	c.weightx = 1.0;
	c.weighty = 1.0;
	intervalPanel.add(distributionValueTextField, c);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:65,代码来源:DistributionsEditor.java

示例6: addDistribution

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Adds a distribution to the given panel
 * @param name the name to be displayed on the label before the distribution
 * @param key to which parameter number in the Burst Distribution this nested distribution corresponds
 * @param intervalPanel the panel to which the distribution should be added
 */
protected void addDistribution(String name, int key, JPanel intervalPanel) {
	JLabel distributionNameLabel = new JLabel(name);

	//Add the name of the distribution on a single line
	GridBagConstraints c = new GridBagConstraints();
	c.insets = new Insets(10, 0, 0, 0); // top padding
	c.gridwidth = GridBagConstraints.REMAINDER; // end row after this entry
	c.fill = GridBagConstraints.HORIZONTAL;
	//how to fill space when enlarging window vertically
	c.weightx = 1.0;
	c.weighty = 0.0;
	//Add the distribution
	intervalPanel.add(distributionNameLabel, c);

	//Add the edit button
	JButton but = new JButton("Edit");
	but.setAction(new EditButtonAction(key));
	//Specifies the button size to maintain its width in the case that probability text fields are hidden
	//TODO check if the specified values are compatible with all graphical systems
	but.setPreferredSize(new Dimension(65, 24));

	c.insets = new Insets(0, 0, 0, 0); //No space between Name of distribution and Edit button
	// don't finish row because also the label for the distribution has to be added
	c.gridwidth = GridBagConstraints.RELATIVE;
	c.fill = GridBagConstraints.HORIZONTAL; // reset to default
	c.weightx = 0.0; // reset to default
	c.weighty = 0.0;
	//Add the button
	intervalPanel.add(but, c);

	JTextField distributionValueTextField = new JTextField();
	//The name of the field is the parameter number
	distributionValueTextField.setName("" + key);
	//If the distribution != null display
	if (current.getParameter(key).getValue() != null) {
		distributionValueTextField.setText(current.getParameter(key).getValue().toString());
	}
	//The value is not editable directly
	distributionValueTextField.setEditable(false);
	c.gridwidth = GridBagConstraints.REMAINDER; // end row
	c.fill = GridBagConstraints.HORIZONTAL;
	c.weightx = 1.0;
	c.weighty = 1.0;
	intervalPanel.add(distributionValueTextField, c);

}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:53,代码来源:DistributionsEditor.java


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