本文整理汇总了Java中java.awt.TextField.addTextListener方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.addTextListener方法的具体用法?Java TextField.addTextListener怎么用?Java TextField.addTextListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.TextField
的用法示例。
在下文中一共展示了TextField.addTextListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addListeners
import java.awt.TextField; //导入方法依赖的package包/类
protected void addListeners( final GenericDialog gd, final TextField tf, final Label label1, final Label label2 )
{
final GenericLoadParseQueryXML< ?,?,?,?,?,? > lpq = this;
// using TextListener instead
tf.addTextListener( new TextListener()
{
@Override
public void textValueChanged( final TextEvent t )
{
if ( t.getID() == TextEvent.TEXT_VALUE_CHANGED )
{
final String xmlFilename = tf.getText();
// try parsing if it ends with XML
tryParsing( xmlFilename, false );
label1.setText( lpq.message1 );
label2.setText( lpq.message2 );
label1.setForeground( lpq.color );
label2.setForeground( lpq.color );
}
}
});
}
示例2: NamesFormularPanel
import java.awt.TextField; //导入方法依赖的package包/类
public NamesFormularPanel(Translator trans, TextListener al) {
super();
//
setLayout(null);
setSize(new Dimension(224, 90));
setBackground(Color.WHITE);
setForeground(Color.BLACK);
//
// text input fields
nameOfPlayerTxtField = new TextField();
nameOfPlayerTxtField.addTextListener(al);
nameOfPlayerTxtField.setFont(systemFont);
nameOfPlayerTxtField.setBounds(5, 5, 210, 22);
add(nameOfPlayerTxtField);
//
nameOfPartyTxtField = new TextField();
nameOfPartyTxtField.addTextListener(al);
nameOfPartyTxtField.setFont(systemFont);
nameOfPartyTxtField.setBounds(5, 50, 210, 22);
add(nameOfPartyTxtField);
//
// ... and their labels
JLabel lbl = new JLabel(trans.word("menu.settings.namePlayer"));
lbl.setBounds(5, 25, 210, 20);
lbl.setFont(SettingsPanel.cursiveFont);
add(lbl);
//
lbl = new JLabel(trans.word("menu.settings.nameParty"));
lbl.setBounds(5, 70, 210, 20);
lbl.setFont(SettingsPanel.cursiveFont);
add(lbl);
}
示例3: addListeners
import java.awt.TextField; //导入方法依赖的package包/类
protected void addListeners(
final GenericDialog gd,
final Vector<?> tf,
final Label label,
final long[] dim )
{
final TextField downsample = (TextField)tf.get( 2 );
downsample.addTextListener(
new TextListener()
{
@Override
public void textValueChanged(TextEvent arg0)
{
int downsampling = Integer.parseInt( downsample.getText() );
final long numPixels = numPixels( dim, downsampling );
final long megabytes = (numPixels * 4) / (1024*1024);
label.setText( "Image size for segmentation: " +
(dim[ 0 ])/downsampling + " x " +
(dim[ 1 ])/downsampling + " x " +
(dim[ 2 ])/downsampling + " pixels, " + megabytes + " MB" );
label.setForeground( GUIHelper.good );
}
} );
}
示例4: initInputPanel
import java.awt.TextField; //导入方法依赖的package包/类
private void initInputPanel(Panel p) {
GridBagConstraints gbc=
new GridBagConstraints();
p.setLayout(new GridBagLayout());
gbc.weightx=100;
gbc.weighty=100;
gbc.gridwidth=1;
gbc.gridheight=1;
gbc.fill=GridBagConstraints.HORIZONTAL;
gbc.anchor=GridBagConstraints.WEST;
gbc.gridx=0;
gbc.gridy=0;
Label typeLabel=new Label("Type");
p.add(typeLabel,gbc);
gbc.gridx=1;
gbc.gridwidth=GridBagConstraints.REMAINDER;
Label valueLabel=new Label("Value");
p.add(valueLabel,gbc);
gbc.gridx=0;
gbc.gridy=1;
Choice type=new Choice();
type.add("Byte");
type.add("Short");
type.add("Character");
type.add("Integer");
type.add("Long");
type.add("Float");
type.add("Double");
type.add("String");
type.add("Object");
type.select("Float");
type.addItemListener(new TypeChoiceCommand());
p.add(type,gbc);
gbc.gridx=1;
gbc.gridwidth=GridBagConstraints.REMAINDER;
value=new ValueChoice();
p.add(value,gbc);
gbc.gridx=0;
gbc.gridy=2;
gbc.gridwidth=1;
gbc.fill=GridBagConstraints.NONE;
Button reset=new Button("Reset");
reset.addActionListener(new ResetCommand());
p.add(reset,gbc);
gbc.gridx=1;
gbc.gridwidth=GridBagConstraints.REMAINDER;
Button position=new Button("Add");
position.addActionListener(new AddCommand());
p.add(position,gbc);
gbc.gridx=0;
gbc.gridy=3;
gbc.gridwidth=1;
gbc.gridheight=GridBagConstraints.REMAINDER;
gbc.fill=GridBagConstraints.HORIZONTAL;
Label format = new Label("Control String");
p.add(format,gbc);
gbc.gridx=1;
TextField formatString = new TextField(40);
gbc.gridwidth=GridBagConstraints.REMAINDER;
formatString.addTextListener(new FormatCommand());
p.add(formatString,gbc);
}
示例5: showParameterDialog
import java.awt.TextField; //导入方法依赖的package包/类
/***
* This dialog is used to setup the parameter for the stack shift.
*
* @param title
* @return OK or CANCEL
*/
private int showParameterDialog(final String title) {
final GenericDialog gd = new GenericDialog(title, IJ.getInstance());
// create 2 numeric fields for each slice of the stack.
final int defaultValue = 0;
final int digits = 0;
// TODO read shift values from a CSV-file
final TextField[] xFields = new TextField[initialImp.getStackSize()];
final TextField[] yFields = new TextField[initialImp.getStackSize()];
for (int i = 0; i < initialImp.getStackSize(); i++) {
String label = initialImp.getStack().getShortSliceLabel(i + 1);
if (label == null) {
label = String.format("slice %d", i + 1);
}
gd.addMessage(label);
final Panel cont = new Panel(new FlowLayout());
cont.add(new Label("x:"));
final TextField tf1 = new TextField(IJ.d2s(defaultValue, digits));
tf1.addActionListener(gd);
tf1.addTextListener(gd);
tf1.addFocusListener(gd);
tf1.addKeyListener(gd);
xFields[i] = tf1;
cont.add(tf1);
cont.add(new Label("y:"));
final TextField tf2 = new TextField(IJ.d2s(defaultValue, digits));
tf2.addActionListener(gd);
tf2.addTextListener(gd);
tf2.addFocusListener(gd);
tf2.addKeyListener(gd);
cont.add(tf2);
yFields[i] = tf2;
gd.addPanel(cont);
}
final String[] labels = { "Optimise image shift", "Create a new image" };
final boolean[] defaults = { true, true };
gd.addCheckboxGroup(2, 1, labels, defaults);
final String[] items = new String[OptimisedStackShifter.MODES
.values().length];
for (int i = 0; i < items.length; i++) {
items[i] = OptimisedStackShifter.MODES.values()[i].toString();
}
gd.addChoice("Border mode:", items, items[0]);
// TODO write the description
final String help = "<html><h3>Stack Shifter</h3><p>description</p></html>";
gd.addHelp(help);
gd.showDialog();
if (gd.wasCanceled() == true) {
return CANCEL;
}
shift = new Point[initialImp.getStackSize()];
for (int i = 0; i < initialImp.getStackSize(); i++) {
shift[i] = new Point(new Integer(xFields[i].getText()), new Integer(
yFields[i].getText()));
}
optimise = gd.getNextBoolean();
createNew = gd.getNextBoolean();
mode = OptimisedStackShifter.MODES.values()[gd.getNextChoiceIndex()];
return OK;
}
示例6: makeAdjustPropertiesDialog
import java.awt.TextField; //导入方法依赖的package包/类
protected GenericDialog makeAdjustPropertiesDialog() {
Rectangle box = getBoundingBox(null);
GenericDialog gd = new GD("Properties of #" + id, this);
gd.addStringField("title: ", title);
gd.addNumericField("x: ", box.x, 2);
gd.addNumericField("y: ", box.y, 2);
gd.addNumericField("scale_x: ", 1, 2);
gd.addNumericField("scale_y: ", 1, 2);
gd.addNumericField("rot (degrees): ", 0, 2);
gd.addSlider("alpha: ", 0, 100, (int)(alpha*100));
gd.addCheckbox("visible", visible);
gd.addSlider("Red: ", 0, 255, color.getRed());
gd.addSlider("Green: ", 0, 255, color.getGreen());
gd.addSlider("Blue: ", 0, 255, color.getBlue());
gd.addCheckbox("locked", locked);
// add slider listener
final Scrollbar alp = (Scrollbar)gd.getSliders().get(0);
final Scrollbar red = (Scrollbar)gd.getSliders().get(1);
final Scrollbar green = (Scrollbar)gd.getSliders().get(2);
final Scrollbar blue = (Scrollbar)gd.getSliders().get(3);
final TextField talp = (TextField)gd.getNumericFields().get(5);
final TextField tred = (TextField)gd.getNumericFields().get(6);
final TextField tgreen = (TextField)gd.getNumericFields().get(7);
final TextField tblue = (TextField)gd.getNumericFields().get(8);
SliderListener sla = new SliderListener() {
public void update() {
setAlpha((float)alp.getValue()/100);
}
};
SliderListener slc = new SliderListener() {
public void update() {
setColor(new Color(red.getValue(), green.getValue(), blue.getValue()));
}
};
alp.addAdjustmentListener(sla);
red.addAdjustmentListener(slc);
green.addAdjustmentListener(slc);
blue.addAdjustmentListener(slc);
talp.addTextListener(sla);
tred.addTextListener(slc);
tgreen.addTextListener(slc);
tblue.addTextListener(slc);
gd.addChoice( "composite mode: ", compositeModes, compositeModes[ compositeMode ] );
return gd;
}