我尝试使用GluonMobile做一个应用程序,当我单击TextField时,键盘不显示。
我尝试了一些我在网上找到的东西,但是没有任何效果。
我尝试将参数放在VM选项中,什么也没有。
我在带有GluonMobile(带有IntelliJ)的Java8上运行 谢谢
更新 这是我的build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.18'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
mavenCentral()
}
dependencies {
compile 'com.jfoenix:jfoenix:8.0.8'
}
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.agathe.AgatheApp'
dependencies {
compile 'com.gluonhq:charm:5.0.2'
}
jfxmobile {
downConfig {
version = '3.8.2'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
androidSdk = 'C:\\Users\\aitech\\android-sdk'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.agathe.**.*',
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import com.gluonhq.charm.glisten.mvc.View?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXPasswordField?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.control.TextField?>
<View fx:id="login" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="350.0" stylesheets="@login.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.agathe.views.LoginPresenter">
<StackPane fx:id="layout">
<VBox alignment="CENTER" fillWidth="false" prefHeight="200.0" prefWidth="350.0" spacing="25.0" BorderPane.alignment="CENTER">
<children>
<JFXTextField fx:id="userId" labelFloat="true" prefWidth="235.0" promptText="Nom D'utilisateur" stylesheets="@login.css" />
<JFXPasswordField fx:id="passId" labelFloat="true" prefWidth="235.0" promptText="Mot de passe" stylesheets="@login.css" />
<JFXButton fx:id="loginBtn" styleClass="jfButton" prefWidth="150.0" text="Login" onAction="#tryConn"/>
</children>
<TextField fx:id="text"/>
</VBox>
</StackPane>
</View>
控制器
package com.agathe.views;
import com.gluonhq.charm.glisten.mvc.View;
import com.jfoenix.controls.*;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.scene.control.TextField;
import java.awt.*;
public class LoginPresenter {
@FXML
private View login;
@FXML
private JFXTextField userId;
@FXML
private JFXPasswordField passId;
@FXML
private JFXButton loginBtn;
@FXML
private StackPane layout;
@FXML
private TextField text;
public void initialize(){
}
@FXML
public void tryConn(ActionEvent event){
text.requestFocus();
// JFXDialogLayout content = new JFXDialogLayout();
// content.setHeading(new Text("Erreur"));
// content.setBody(new Text("Le nom d'u"));
//
// JFXDialog dialog = new JFXDialog(layout, content, JFXDialog.DialogTransition.CENTER);
//
//
// JFXButton btn = new JFXButton("OK");
//// btn.setDefaultButton(true);
//
// btn.setOnAction(actionEvent ->{
// dialog.close();
// });
//
// content.setActions(btn);
// dialog.show();
}
}
和视图
package com.agathe.views;
import com.gluonhq.charm.glisten.mvc.View;
import com.gluonhq.charm.glisten.visual.MaterialDesignIcon;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
import java.io.IOException;
public class LoginView {
public View getView() {
try {
View view = FXMLLoader.load(PrimaryView.class.getResource("login.fxml"));
return view;
} catch (IOException e) {
System.out.println("IOException: " + e);
return new View();
}
}
}