jTextField1.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
jTextField1ActionPerformed(e);
}
public void focusLost(FocusEvent e) {
}
void displayMessage(String prefix, FocusEvent e) {
}
});
jTextField1.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
JTextField textField = (JTextField) e.getSource();
String text = textField.getText();
System.err.println("text:" + text);
textField.setText(text.toUpperCase());
}
public void keyTyped(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
}
});
private Locale locale = new Locale("en", "US");
private void jTextField1ActionPerformed(FocusEvent evt) {
System.err.println("Locale is: " + jTextField1.getLocale());
}
System.err.println("Locale was: " + jTextField1.getInputContext().getLocale());
Locale locale = new Locale("ru", "RU");
Locale.setDefault(locale);
jTextField1.setLocale(locale);
System.err.println("Locale changed to: " + jTextField1.getLocale());
Locale was: en_US
Locale changed to: ru_RU
By.cssSelector
package example;
public class Controller {
@FXML
private Button buttonSave;
@FXML
private TextField textField;
public void actionButtonPressed(ActionEvent event) {
Object source = event.getSource();
if (!(source instanceof Button)) {
return;
}
Button button = (Button) source;
System.err.println("Data: " + textField.getText() + " clicked:" + button.getId());
}
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="502.0" prefWidth="529.0" style="-fx-background-color: #FAF9F0;" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="example.Controller">
...
<TextField layoutX="106.0" layoutY="215.0" opacity="0.8" prefHeight="70.0" prefWidth="300.0" promptText="Срок в месяцах"
fx:id="textField">
<font>
<Font name="VAG World Bold" size="11.0" />
</font>
</TextField>
<Button layoutX="106.0" layoutY="303.0" mnemonicParsing="false" prefHeight="70.0" prefWidth="300.0" style="-fx-background-color: #00B850; -fx-cursor: hand;"
text="Посчитать" textFill="WHITE"
fx:id="buttonSave" onAction="#actionButtonPressed">
<font>
<Font name="VAG World Bold" size="20.0" />
</font>
</Button>
final String script = "return arguments[0].value";
WebElement element = driver.findElement(By.cssSelector("input[name=\"clock\"]"));
String value = (String) executeScript(script, element);
System.err.println("current value: " + value);
WebElement element = driver.findElement(By.cssSelector("input[name=\"clock\"]"));
String value = element.getAttribute("value");
System.err.println("current value: " + value);
driver.getPageSource
никогда не будет содержать ничего что этот JavaSrcipt нагенерил - печально но это так.<html>
<head>
<!-- origin: http://www.java2s.com/Tutorials/Javascript/Javascript_Data_Type_How_to/Date_Clock/Create_auto_refresh_clock.htm -->
<script language="JavaScript">
function gettime() {
var date= new Date();
var hr = date.getHours();
var m = date.getMinutes();
var s = date.getSeconds();
if(m < 10)
{
m = "0" + m
}
if(s < 10)
{
s = "0" + s
}
document.clockform.clock.value = hr + ":" + m + ":" + s;
setTimeout("gettime()", 2400)
}
</script>
</head>
<body onload="gettime()">
<form name="clockform">
<input type="text" name="clock">
</form>
</body>
</html>
driver.getPageSource
время которое эта страничка показывает никогда не узнаете
когда зовете
vagrant ssh имя ноды
он делает
ssh -p порт vagrant@127.0.0.1
в этом примере порт (напр 2222) это форвард 22
так и получится туда через nat
не везде (на работе например может нехватать прав) получится создать brigded adapter