本文整理汇总了Java中java.awt.TextField.getText方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.getText方法的具体用法?Java TextField.getText怎么用?Java TextField.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.TextField
的用法示例。
在下文中一共展示了TextField.getText方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixtext
import java.awt.TextField; //导入方法依赖的package包/类
private void fixtext(final TextField textfield) {
String string = textfield.getText();
string = string.replace('\"', '#');
final String string330 = "\\";
String string331 = "";
int i = 0;
int i332 = -1;
rd.setFont(new Font("Arial", 1, 12));
ftm = rd.getFontMetrics();
for (/**/; i < string.length(); i++) {
final String string333 = "" + string.charAt(i);
if (string333.equals("|") || string333.equals(",") || string333.equals("(") || string333.equals(")") || string333.equals("#") || string333.equals(string330) || string333.equals("!") || string333.equals("?") || string333.equals("~") || string333.equals(".") || string333.equals("@") || string333.equals("$") || string333.equals("%") || string333.equals("^") || string333.equals("&") || string333.equals("*") || string333.equals("+") || string333.equals("=") || string333.equals(">") || string333.equals("<") || string333.equals("/") || string333.equals(";") || string333.equals(":") || ftm.stringWidth(string331) > 274) {
i332 = i;
} else {
string331 = "" + string331 + string333;
}
}
if (i332 != -1) {
textfield.setText(string331);
textfield.select(i332, i332);
}
}
示例2: fixtext
import java.awt.TextField; //导入方法依赖的package包/类
private void fixtext(final TextField textfield) {
String string = textfield.getText();
string = string.replace('\"', '#');
final String string64 = "\\";
String string65 = "";
int i = 0;
int i66 = -1;
for (/**/ ; i < string.length(); i++) {
final String string67 = "" + string.charAt(i);
if (string67.equals("|") || string67.equals(",") || string67.equals("(") || string67.equals(")") || string67.equals("#") || string67.equals(string64) || string67.equals("!") || string67.equals("?") || string67.equals(" ") || string67.equals("~") || string67.equals("$") || string67.equals("%") || string67.equals("^") || string67.equals("&") || string67.equals("*") || string67.equals("+") || string67.equals("=") || string67.equals(">") || string67.equals("<") || string67.equals("/") || string67.equals("'") || string67.equals(";") || string67.equals(":") || string67.equals("\u00a0")) {
i66 = i;
} else {
string65 = "" + string65 + string67;
}
}
if (i66 != -1) {
textfield.setText(string65);
textfield.select(i66, i66);
}
}
示例3: fixtext
import java.awt.TextField; //导入方法依赖的package包/类
private void fixtext(final TextField textfield) {
String string = textfield.getText();
string = string.replace('\"', '#');
final String string360 = "\\";
String string361 = "";
int i = 0;
int i362 = -1;
for (/**/; i < string.length(); i++) {
final String string363 = "" + string.charAt(i);
if (string363.equals("|") || string363.equals(",") || string363.equals("(") || string363.equals(")") || string363.equals("#") || string363.equals(string360) || string363.equals("!") || string363.equals("?") || string363.equals("~") || string363.equals(".") || string363.equals("@") || string363.equals("$") || string363.equals("%") || string363.equals("^") || string363.equals("&") || string363.equals("*") || string363.equals("+") || string363.equals("=") || string363.equals(">") || string363.equals("<") || string363.equals("/") || string363.equals("'") || string363.equals(";") || string363.equals(":") || i > 15) {
i362 = i;
} else {
string361 = "" + string361 + string363;
}
}
if (i362 != -1) {
textfield.setText(string361);
textfield.select(i362, i362);
}
}
示例4: mouseClicked
import java.awt.TextField; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() > 1 && e.getSource() instanceof TextField) // Double-click
{
TextField tf = (TextField) e.getSource();
String path = tf.getText();
boolean recording = Recorder.record;
Recorder.record = false;
if (tf == textParamFile)
{
path = Utils.getFilename("Choose_a_parameter_file", path);
}
else
{
path = Utils.getDirectory("Choose_a_directory", path);
}
Recorder.record = recording;
if (path != null)
tf.setText(path);
}
}
示例5: validateFloatEdit
import java.awt.TextField; //导入方法依赖的package包/类
private static boolean validateFloatEdit(
TextField theField,
double minValue,
double maxValue) {
StringTokenizer fieldTokenizer
= new StringTokenizer(theField.getText());
if (!fieldTokenizer.hasMoreElements()) {
theField.setText("Error--No Data");
return false;
}
else {
String fieldString =
fieldTokenizer.nextToken();
try {
double fieldValue =
new Double(fieldString)
.doubleValue();
if (fieldValue < minValue ) {
theField.setText("Value Too Low");
return false;
}
else if (fieldValue < minValue ) {
theField.setText("Value Too High");
return false;
}
}
catch (Throwable e ) {
theField.setText("Data Error");
return false;
}
}
if (fieldTokenizer.hasMoreElements()) {
theField.setText("Data Error");
return false;
}
else {
return true;
}
}
示例6: getFieldDouble
import java.awt.TextField; //导入方法依赖的package包/类
private static double getFieldDouble(
TextField theField
) {
StringTokenizer fieldTokenizer
= new StringTokenizer(theField.getText());
String fieldString =
fieldTokenizer.nextToken();
return (new Double(fieldString)).doubleValue();
}
示例7: validateIntegerEdit
import java.awt.TextField; //导入方法依赖的package包/类
private static boolean validateIntegerEdit(
TextField theField,
int minValue,
int maxValue) {
StringTokenizer fieldTokenizer
= new StringTokenizer(theField.getText());
if (!fieldTokenizer.hasMoreElements()) {
theField.setText("Error--No Data");
return false;
}
else {
String fieldString =
fieldTokenizer.nextToken();
try {
int fieldValue =
new Integer(fieldString)
.intValue();
if (fieldValue < minValue ) {
theField.setText("Value Too Low");
return false;
}
else if (fieldValue > maxValue ) {
theField.setText("Value Too High");
return false;
}
}
catch (Throwable e ) {
theField.setText("Data Error");
return false;
}
}
if (fieldTokenizer.hasMoreElements()) {
theField.setText("Data Error");
return false;
}
else {
return true;
}
}
示例8: getFieldInt
import java.awt.TextField; //导入方法依赖的package包/类
private static int getFieldInt(
TextField theField
) {
StringTokenizer fieldTokenizer
= new StringTokenizer(theField.getText());
String fieldString =
fieldTokenizer.nextToken();
return (new Integer(fieldString)).intValue();
}
示例9: FIREDialogListener
import java.awt.TextField; //导入方法依赖的package包/类
FIREDialogListener(ExtendedGenericDialog gd, PrecisionHistogram histogram, QPlot qplot,
Workflow<WorkSettings, Object> workflow)
{
time = System.currentTimeMillis() + 1000;
this.workflow = workflow;
this.defaultMean = histogram.mean;
this.defaultSigma = histogram.sigma;
this.defaultQValue = qplot.qValue;
isMacro = Utils.isMacro();
// For the reset
tf1 = (TextField) gd.getNumericFields().get(0);
tf2 = (TextField) gd.getNumericFields().get(1);
tf3 = (TextField) gd.getNumericFields().get(2);
cb = (Checkbox) (gd.getCheckboxes().get(0));
// Sliders
sl1 = (Scrollbar) gd.getSliders().get(0);
sl2 = (Scrollbar) gd.getSliders().get(1);
sl3 = (Scrollbar) gd.getSliders().get(2);
sl1.addMouseListener(this);
sl2.addMouseListener(this);
sl3.addMouseListener(this);
m = tf1.getText();
s = tf2.getText();
q = tf3.getText();
// Implement a delay to allow typing.
// This is also applied to the sliders which we do not want.
// Ideally we would have no delay for sliders (since they are in the correct place already
// but a delay for typing in the text field). Unfortunately the AWTEvent raised by ImageJ
// for the slider is actually from the TextField so we cannot tell the difference.
// For now just have no delay.
//if (!isMacro)
// workflow.startPreview();
}
示例10: mouseClicked
import java.awt.TextField; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e)
{
// Show the result that was double clicked in the result table
if (e.getClickCount() > 1)
{
// Double-click on the multi-mode dialog text fields
if (e.getSource() instanceof TextField)
{
TextField tf = (TextField) e.getSource();
String path = tf.getText();
final boolean recording = Recorder.record;
Recorder.record = false;
path = Utils.getDirectory("Choose_a_directory", path);
Recorder.record = recording;
if (path != null)
tf.setText(path);
}
// Double-click on the result table
else if (lastImp != null && lastImp.isVisible())
{
// An extra line is added at the end of the results so remove this
int rank = resultsWindow.getTextPanel().getLineCount() -
resultsWindow.getTextPanel().getSelectionStart() - 1;
// Show the result that was double clicked. Results are stored in reverse order.
if (rank > 0 && rank <= lastResults.size())
{
showResult(lastImp, lastMask, lastResults.get(rank - 1).options);
}
}
}
}
示例11: intFieldError
import java.awt.TextField; //导入方法依赖的package包/类
private static boolean intFieldError(
TextField theField,
double minValue,
double maxValue ) {
StringTokenizer fieldTokenizer
= new StringTokenizer(theField.getText());
if (!fieldTokenizer.hasMoreElements()) {
theField.setText("Error");
return true;
}
else {
String fieldString =
fieldTokenizer.nextToken();
try {
int fieldValue =
new Integer(fieldString)
.intValue();
if (fieldValue < minValue ) {
theField.setText("Error");
return true;
}
else if (fieldValue > maxValue ) {
theField.setText("Error");
return true;
}
}
catch (Throwable e ) {
theField.setText("Error");
return true;
}
}
if (fieldTokenizer.hasMoreElements()) {
theField.setText("Error");
return true;
}
else {
return false;
}
}
示例12: getIntegerValue
import java.awt.TextField; //导入方法依赖的package包/类
private static int getIntegerValue(
TextField theField ) {
StringTokenizer fieldTokenizer
= new StringTokenizer(theField.getText());
String fieldString =
fieldTokenizer.nextToken();
return new Integer(fieldString).intValue();
}
示例13: loadNumber
import java.awt.TextField; //导入方法依赖的package包/类
private int loadNumber(TextField tf) {
String text = tf.getText();
int number = 0;
try {
number = Integer.parseInt(text);
if (number > 4095)
number = 4095;
} catch (NumberFormatException e) {
System.out.println("Not a correct number");
}
return number;
}
示例14: format
import java.awt.TextField; //导入方法依赖的package包/类
protected void format(String tag, TextField pane) {// TODO
final int start = pane.getSelectionStart();
final int end = pane.getSelectionEnd();
final String text = pane.getText();
pane.setText(selectionInTag(text, start, end, tag));
}