解决了基本类型错误bug
This commit is contained in:
892
.idea/workspace.xml
generated
892
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,10 @@ public class FXPlusApplication {
|
|||||||
|
|
||||||
private static BeanBuilder beanBuilder;
|
private static BeanBuilder beanBuilder;
|
||||||
|
|
||||||
|
public static boolean IS_SCENE_BUILDER = true;
|
||||||
|
|
||||||
public static void start(Class clazz, BeanBuilder beanBuilder){
|
public static void start(Class clazz, BeanBuilder beanBuilder){
|
||||||
|
IS_SCENE_BUILDER = false;
|
||||||
FXPlusApplication.beanBuilder = beanBuilder;
|
FXPlusApplication.beanBuilder = beanBuilder;
|
||||||
Annotation []annotations = clazz.getDeclaredAnnotations();
|
Annotation []annotations = clazz.getDeclaredAnnotations();
|
||||||
for(Annotation annotation : annotations){
|
for(Annotation annotation : annotations){
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cn.edu.scau.biubiusuisui.entity;
|
|||||||
|
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||||
import cn.edu.scau.biubiusuisui.config.FXMLLoaderPlus;
|
import cn.edu.scau.biubiusuisui.config.FXMLLoaderPlus;
|
||||||
|
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||||
import cn.edu.scau.biubiusuisui.utils.StringUtils;
|
import cn.edu.scau.biubiusuisui.utils.StringUtils;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
@@ -49,11 +50,12 @@ public class FXBaseController extends Pane {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//load fxml file to show panel in scene builder
|
//load fxml file to show panel in scene builder
|
||||||
if(isController) {
|
if(isController && FXPlusApplication.IS_SCENE_BUILDER == true) {
|
||||||
FXMLLoaderPlus fxmlLoader = new FXMLLoaderPlus(getClass().getClassLoader().getResource(fxController.path()));
|
FXMLLoaderPlus fxmlLoader = new FXMLLoaderPlus(getClass().getClassLoader().getResource(fxController.path()));
|
||||||
fxmlLoader.setRoot(this);
|
fxmlLoader.setRoot(this);
|
||||||
fxmlLoader.setController(this);
|
fxmlLoader.setController(this);
|
||||||
fxmlLoader.setShow(true);
|
fxmlLoader.setShow(true);
|
||||||
|
System.out.println("?");
|
||||||
try {
|
try {
|
||||||
fxmlLoader.load();
|
fxmlLoader.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import javafx.stage.StageStyle;
|
|||||||
* @Date:2019/7/4 11:36
|
* @Date:2019/7/4 11:36
|
||||||
*/
|
*/
|
||||||
@FXController(path = "Main.fxml")
|
@FXController(path = "Main.fxml")
|
||||||
@FXWindow(title = "hello", resizable = true, style = StageStyle.UNDECORATED)
|
@FXWindow(title = "hello", resizable = true, draggable = true)
|
||||||
public class Main2 extends FXBaseController {
|
public class Main2 extends FXBaseController {
|
||||||
|
|
||||||
@FXData
|
@FXData
|
||||||
@@ -31,6 +31,8 @@ public class Main2 extends FXBaseController {
|
|||||||
)
|
)
|
||||||
Student student = new Student();
|
Student student = new Student();
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private PasswordField psw;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label label;
|
private Label label;
|
||||||
@@ -47,19 +49,17 @@ public class Main2 extends FXBaseController {
|
|||||||
@FXML
|
@FXML
|
||||||
private Label usrMsg;
|
private Label usrMsg;
|
||||||
|
|
||||||
@FXML
|
@FXBind("text=${student.name}")
|
||||||
private PasswordField psw;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label pswMsg;
|
private Label pswMsg;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void login(ActionEvent event) {
|
void login(ActionEvent event) {
|
||||||
System.out.println("user:" + student.getName());
|
System.out.println("user:" + student.getName());
|
||||||
System.out.println("psw:"+student.getPassword());
|
System.out.println("psw:" + student.getPassword());
|
||||||
if("admin".equals(student.getName())&&"admin".equals(student.getPassword())){
|
if ("admin".equals(student.getName()) && "admin".equals(student.getPassword())) {
|
||||||
System.out.println("Ok");
|
System.out.println("Ok");
|
||||||
}else{
|
} else {
|
||||||
System.out.println("fail");
|
System.out.println("fail");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package cn.edu.scau.biubiusuisui.example.moveDemo;
|
||||||
|
|
||||||
|
import cn.edu.scau.biubiusuisui.annotation.FXEntity;
|
||||||
|
import cn.edu.scau.biubiusuisui.annotation.FXField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author jack
|
||||||
|
* @Date:2019/7/25 9:24
|
||||||
|
*/
|
||||||
|
@FXEntity
|
||||||
|
public class CircleBean {
|
||||||
|
|
||||||
|
@FXField
|
||||||
|
double x = 0;
|
||||||
|
|
||||||
|
@FXField
|
||||||
|
double y = 0;
|
||||||
|
|
||||||
|
public double getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(double x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setY(double y) {
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CircleBean{" +
|
||||||
|
"x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package cn.edu.scau.biubiusuisui.example.moveDemo;
|
||||||
|
|
||||||
|
import cn.edu.scau.biubiusuisui.annotation.FXScan;
|
||||||
|
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author jack
|
||||||
|
* @Date:2019/6/25 7:05
|
||||||
|
*/
|
||||||
|
@FXScan(base = {"cn.edu.scau.biubiusuisui.example.moveDemo"})
|
||||||
|
//项目目录中带有中文字符会导致无法启动
|
||||||
|
public class Demo extends Application {
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) throws Exception {
|
||||||
|
FXPlusApplication.start(Demo.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package cn.edu.scau.biubiusuisui.example.moveDemo;
|
||||||
|
|
||||||
|
import cn.edu.scau.biubiusuisui.annotation.FXBind;
|
||||||
|
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||||
|
import cn.edu.scau.biubiusuisui.annotation.FXData;
|
||||||
|
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
||||||
|
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||||
|
import cn.edu.scau.biubiusuisui.example.Student;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.PasswordField;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.shape.Circle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author jack
|
||||||
|
* @Date:2019/7/4 11:36
|
||||||
|
*/
|
||||||
|
@FXController(path = "moveDemo.fxml")
|
||||||
|
@FXWindow(title = "hello", resizable = true, draggable = true)
|
||||||
|
public class Main2 extends FXBaseController {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
@FXBind({"layoutX=${bean.x}","layoutY=${bean.y}"})
|
||||||
|
private Circle circle;
|
||||||
|
|
||||||
|
@FXData
|
||||||
|
CircleBean bean = new CircleBean();
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
@FXBind("text=${bean.x}")
|
||||||
|
private TextField xinput;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
@FXBind("text=${bean.y}")
|
||||||
|
private TextField yinput;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button xSub;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button xAdd;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button ySub;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button yAdd;
|
||||||
|
@FXML
|
||||||
|
public void addX(){
|
||||||
|
double x = bean.getX() + 5 ;
|
||||||
|
bean.setX(x);
|
||||||
|
System.out.println("? ? " + bean);
|
||||||
|
}
|
||||||
|
@FXML
|
||||||
|
public void subX(){
|
||||||
|
double x = bean.getX() - 5 ;
|
||||||
|
bean.setX(x);
|
||||||
|
}
|
||||||
|
@FXML
|
||||||
|
public void addY(){
|
||||||
|
double y = bean.getY() + 5 ;
|
||||||
|
bean.setY(y);
|
||||||
|
}
|
||||||
|
@FXML
|
||||||
|
public void subY(){
|
||||||
|
double y = bean.getY() - 5 ;
|
||||||
|
bean.setY(y);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,10 @@ import org.springframework.stereotype.Component;
|
|||||||
@FXWindow(title = "hello", resizable = true, style = StageStyle.UNDECORATED,draggable = true)
|
@FXWindow(title = "hello", resizable = true, style = StageStyle.UNDECORATED,draggable = true)
|
||||||
public class SpringExpressionDemoController extends FXBaseController {
|
public class SpringExpressionDemoController extends FXBaseController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@FXData
|
@FXData
|
||||||
@Autowired
|
@Autowired
|
||||||
@FXBind(
|
@FXBind(
|
||||||
|
|||||||
@@ -100,16 +100,18 @@ public class FXEntityFactory {
|
|||||||
private static Property getFieldProperty(Object object,Field field) throws IllegalAccessException {
|
private static Property getFieldProperty(Object object,Field field) throws IllegalAccessException {
|
||||||
Class type = field.getType();
|
Class type = field.getType();
|
||||||
Object value = field.get(object);
|
Object value = field.get(object);
|
||||||
|
|
||||||
Property property = null;
|
Property property = null;
|
||||||
if(Boolean.class.equals(type)){
|
|
||||||
|
if(Boolean.class.equals(type) || boolean.class.equals(type)){
|
||||||
property = new SimpleBooleanProperty((Boolean) value);
|
property = new SimpleBooleanProperty((Boolean) value);
|
||||||
}else if(Double.class.equals(type)){
|
}else if(Double.class.equals(type)||double.class.equals(type)){
|
||||||
property = new SimpleDoubleProperty((Double) value);
|
property = new SimpleDoubleProperty((Double) value);
|
||||||
}else if (Float.class.equals(type)){
|
}else if (Float.class.equals(type) || float.class.equals(type)){
|
||||||
property = new SimpleFloatProperty((Float) value);
|
property = new SimpleFloatProperty((Float) value);
|
||||||
}else if(Integer.class.equals(type)){
|
}else if(Integer.class.equals(type) || int.class.equals(type)){
|
||||||
property = new SimpleIntegerProperty((Integer) value);
|
property = new SimpleIntegerProperty((Integer) value);
|
||||||
}else if(Long.class.equals(type)){
|
}else if(Long.class.equals(type) || long.class.equals(property)){
|
||||||
property = new SimpleLongProperty((Long) value);
|
property = new SimpleLongProperty((Long) value);
|
||||||
}else if(String.class.equals(type)){
|
}else if(String.class.equals(type)){
|
||||||
property = new SimpleStringProperty((String) value);
|
property = new SimpleStringProperty((String) value);
|
||||||
@@ -123,15 +125,15 @@ public class FXEntityFactory {
|
|||||||
private static Property getFieldDefalutProperty(Field field) throws IllegalAccessException{
|
private static Property getFieldDefalutProperty(Field field) throws IllegalAccessException{
|
||||||
Class type = field.getType();
|
Class type = field.getType();
|
||||||
Property property = null;
|
Property property = null;
|
||||||
if(Boolean.class.equals(type)){
|
if(Boolean.class.equals(type) || boolean.class.equals(type)){
|
||||||
property = new SimpleBooleanProperty();
|
property = new SimpleBooleanProperty();
|
||||||
}else if(Double.class.equals(type)){
|
}else if(Double.class.equals(type)||double.class.equals(type)){
|
||||||
property = new SimpleDoubleProperty();
|
property = new SimpleDoubleProperty();
|
||||||
}else if (Float.class.equals(type)){
|
}else if (Float.class.equals(type) || float.class.equals(type)){
|
||||||
property = new SimpleFloatProperty();
|
property = new SimpleFloatProperty();
|
||||||
}else if(Integer.class.equals(type)){
|
}else if(Integer.class.equals(type) || int.class.equals(type)){
|
||||||
property = new SimpleIntegerProperty();
|
property = new SimpleIntegerProperty();
|
||||||
}else if(Long.class.equals(type)){
|
}else if(Long.class.equals(type) || long.class.equals(property)){
|
||||||
property = new SimpleLongProperty();
|
property = new SimpleLongProperty();
|
||||||
}else if(String.class.equals(type)){
|
}else if(String.class.equals(type)){
|
||||||
property = new SimpleStringProperty();
|
property = new SimpleStringProperty();
|
||||||
|
|||||||
@@ -57,15 +57,15 @@ public class FXEntityProxy implements MethodInterceptor {
|
|||||||
}
|
}
|
||||||
Class type = fxFieldPropertyMapping.getType();
|
Class type = fxFieldPropertyMapping.getType();
|
||||||
if (methodName.startsWith("set")) {
|
if (methodName.startsWith("set")) {
|
||||||
if(Boolean.class.equals(type)){
|
if(Boolean.class.equals(type) || boolean.class.equals(type)){
|
||||||
((SimpleBooleanProperty)property).set((Boolean)objects[0]);
|
((SimpleBooleanProperty)property).set((Boolean)objects[0]);
|
||||||
}else if(Double.class.equals(type)){
|
}else if(Double.class.equals(type)||double.class.equals(type)){
|
||||||
((SimpleDoubleProperty)property).set((Double)objects[0]);
|
((SimpleDoubleProperty)property).set((Double)objects[0]);
|
||||||
}else if (Float.class.equals(type)){
|
}else if (Float.class.equals(type) || float.class.equals(type)){
|
||||||
((SimpleFloatProperty)property).set((Float) objects[0]);
|
((SimpleFloatProperty)property).set((Float) objects[0]);
|
||||||
}else if(Integer.class.equals(type)){
|
}else if(Integer.class.equals(type) || int.class.equals(type)){
|
||||||
((SimpleIntegerProperty)property).set((Integer) objects[0]);
|
((SimpleIntegerProperty)property).set((Integer) objects[0]);
|
||||||
}else if(Long.class.equals(type)){
|
}else if(Long.class.equals(type) ||long.class.equals(type)){
|
||||||
((SimpleLongProperty)property).set((Long)objects[0]);
|
((SimpleLongProperty)property).set((Long)objects[0]);
|
||||||
}else if(String.class.equals(type)){
|
}else if(String.class.equals(type)){
|
||||||
((SimpleStringProperty)property).set((String)objects[0]);
|
((SimpleStringProperty)property).set((String)objects[0]);
|
||||||
|
|||||||
21
src/main/resources/moveDemo.fxml
Normal file
21
src/main/resources/moveDemo.fxml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.Pane?>
|
||||||
|
<?import javafx.scene.shape.Circle?>
|
||||||
|
|
||||||
|
<fx:root prefHeight="600.0" prefWidth="600.0" type="Pane" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="cn.edu.scau.biubiusuisui.example.moveDemo.Main2">
|
||||||
|
<children>
|
||||||
|
<Circle fx:id="circle" fill="DODGERBLUE" layoutX="99.0" layoutY="191.0" radius="39.0" stroke="BLACK" strokeType="INSIDE" />
|
||||||
|
<TextField layoutX="199.0" layoutY="310.0" text="123" fx:id="xinput" />
|
||||||
|
<TextField fx:id="yinput" layoutX="199.0" layoutY="367.0" text="123" />
|
||||||
|
<Label layoutX="14.0" layoutY="315.0" text="X" />
|
||||||
|
<Label layoutX="14.0" layoutY="372.0" text="Y" />
|
||||||
|
<Button layoutX="148.0" layoutY="310.0" mnemonicParsing="false" text="-" fx:id="xSub" onAction="#subX"/>
|
||||||
|
<Button layoutX="415.0" layoutY="310.0" mnemonicParsing="false" text="+" fx:id="xAdd" onAction="#addX"/>
|
||||||
|
<Button fx:id="ySub" layoutX="148.0" layoutY="367.0" mnemonicParsing="false" text="-" onAction="#subY"/>
|
||||||
|
<Button fx:id="yAdd" layoutX="415.0" layoutY="367.0" mnemonicParsing="false" text="+" onAction="#addY"/>
|
||||||
|
</children>
|
||||||
|
</fx:root>
|
||||||
Reference in New Issue
Block a user