小编Gaa*_*kar的帖子

如何在Javafx的Pane中心显示ProgressIndicator

我有一个带有一些控件和一个按钮的窗格.当我单击按钮时,我希望在窗格中心显示ProgressIndicator而不删除任何控件.

当我在onAction按钮期间向窗格添加ProgressIndicator时,它会将其添加到按钮下方.我希望它覆盖在窗格上.

下图说明了我想要的内容.

进度指标

package fx;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Main extends Application {

@Override
public void start(Stage arg0) throws Exception {
    final VBox bx = new VBox();
    bx.setAlignment(Pos.CENTER);
    TextField userName = new TextField("User Name");
    userName.setMaxWidth(200);
    TextField email = new TextField("Email");
    email.setMaxWidth(200);
    Button submit = new Button("Submit");
    submit.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent event) {
            ProgressIndicator pi = new ProgressIndicator(); …
Run Code Online (Sandbox Code Playgroud)

javafx javafx-8

7
推荐指数
1
解决办法
5502
查看次数

如何使用反射获取匿名类字段

这是我的示例类,我想通过使用这一行中的反射来获取 y 和 z 字段 (Field[] Fields = forName.getDeclaredFields();) 我正在获取空数组。如果 y 和 z 不是类结构的一部分,那么它们属于哪一部分

package test;

import java.lang.reflect.Field;

public class Reflection {

    static ClassLoader classLoader = null;

    public static void main(String[] args) {
        classLoader = Reflection.class.getClassLoader();
        Reflection r = new Reflection();
        r.getAnnClas();
    }

    private void getAnnClas() {
        Class<?> forName = null;
        try {
            forName = classLoader.loadClass("test.Wrirter");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Field[] declaredFields = forName.getDeclaredFields();
        for (Field field : declaredFields) {
            //here i canot find annoumouse calss filed …
Run Code Online (Sandbox Code Playgroud)

java reflection

2
推荐指数
1
解决办法
2555
查看次数

为什么不使用 java.util.List 检查 java.lang.reflect.Field 的实例

我想检查字段类型是否为列表,但这给出了错误:

Incompatible conditional operand types Class<capture#5-of ?> and 
     List
- Incompatible conditional operand types Class<capture#6-of ?> and 
     List
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

private void convert(Class<?> load) {

        Field[] fields = load.getDeclaredFields();
        int i = 0;
        for (Field field : fields) {
            Class<?> type = field.getType();
            if (type instanceof java.util.List) {
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

java reflection

1
推荐指数
1
解决办法
1316
查看次数

标签 统计

java ×2

reflection ×2

javafx ×1

javafx-8 ×1