我需要一个.fxml文件来构建我的GUI.我实际上需要让它在没有鼠标的情况下工作,只需要键盘动作....所以,这里是fxml中的按钮:
<HBox spacing="10" alignment="bottom_right"
GridPane.columnIndex="1" GridPane.rowIndex="4">
<Button text="Login"
onAction="#handleSubmitButtonAction"/>
</HBox>
Run Code Online (Sandbox Code Playgroud)
首先,当按下回车键时,我只需要这个按钮来执行"handleSubmitButtonAction"事件.(如果您对次要目标有任何提示:使用箭头键浏览按钮,而不是一切都消失;))
我尝试了一个非常简单的时钟(它的工作原理).但问题是,我得到的时间可以是:18:7,而不是18:07.我尝试用整数测试校正< 10,但由于某种原因,它说它永远不会运行.你能告诉我为什么它不会比较以及我如何纠正它?顺便说一句,这是代码:)
import javafx.animation.*;
import javafx.event.*;
import javafx.scene.control.Label;
import javafx.util.Duration;
import java.util.Calendar;
public class DigitalClock extends Label {
static private String addhour;
static private String addmin;
static private String addmonth;
static private String addday;
// constructor
public DigitalClock() {
bindToTime();
}
void bindToTime() {
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(0),
new EventHandler<ActionEvent>() {
@SuppressWarnings("unused")
@Override
public void handle(ActionEvent actionEvent) {
Calendar time = Calendar.getInstance();
if (Calendar.HOUR_OF_DAY < 10) {
addhour = " 0";
} else {
addhour = …Run Code Online (Sandbox Code Playgroud)