本文整理匯總了Java中java.awt.TextField.select方法的典型用法代碼示例。如果您正苦於以下問題:Java TextField.select方法的具體用法?Java TextField.select怎麽用?Java TextField.select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.TextField
的用法示例。
在下文中一共展示了TextField.select方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import java.awt.TextField; //導入方法依賴的package包/類
@Override
public void init() {
tf = new TextField(20);
tf.setText("0123456789");
tf.select(0, 6);
final TextArea ta = new TextArea("INSTRUCTIONS:\n"
+ "The text 012345 should be selected in the TextField.\n"
+ "If this is what you observe, then the test passes.\n"
+ "Otherwise, the test fails.", 40, 5,
TextArea.SCROLLBARS_NONE);
ta.setEditable(false);
ta.setPreferredSize(new Dimension(300, 70));
final Panel panel = new Panel();
panel.setLayout(new FlowLayout());
panel.add(tf);
setLayout(new BorderLayout());
add(ta, BorderLayout.CENTER);
add(panel, BorderLayout.PAGE_END);
}
示例2: initTestWindow
import java.awt.TextField; //導入方法依賴的package包/類
public static void initTestWindow() {
mainFrame = new Frame();
p1 = new Panel();
mainFrame.setTitle("TestWindow");
mainFrame.setBounds(700, 10, 400, 100);
tf = new TextField(20);
tf.select(0, 10);
bt = new Button("Disable textfield");
p1.add(tf);
p1.add(bt);
mainFrame.add(p1);
bt.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
tf.setEditable(false);
}
});
mainFrame.setVisible(true);
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: initTestWindow
import java.awt.TextField; //導入方法依賴的package包/類
public static void initTestWindow() {
mainFrame = new Frame("ScrollSelectionTest frame");
mainFrame.setBounds(500, 0, 400, 200);
textField = new TextField(40);
textField.setText("abcdefghijklmnopqrstuvwxyz");
mainFrame.add(textField);
mainFrame.setLayout(new FlowLayout());
textField.select(0, 20);
mainFrame.setVisible(true);
}