Git Product home page Git Product logo

fxorms's Introduction

f(x)orms

JavaFX form builder.

How to build a form

  1. Create your JavaFX bean:

    public class User {
    
        @ReadOnly
        private IntegerProperty id = new SimpleIntegerProperty();
    
        private StringProperty name = new SimpleStringProperty();
    
        @ReadOnly
        private ObjectProperty<LocalDateTime> lastLogin = new SimpleObjectProperty<>();
    
        private MapProperty<String, Object> preferences = new SimpleMapProperty<>(FXCollections.observableHashMap());
    
        private ReadOnlyBooleanWrapper enabled = new ReadOnlyBooleanWrapper();
    
        public final IntegerProperty idProperty() {
            return this.id;
        }
    
        public final int getId() {
            return this.idProperty().get();
        }
    
        public final void setId(final int id) {
            this.idProperty().set(id);
        }
    
        public final StringProperty nameProperty() {
            return this.name;
        }
    
        public final String getName() {
            return this.nameProperty().get();
        }
    
        public final void setName(final String name) {
            this.nameProperty().set(name);
        }
    
        public final ObjectProperty<LocalDateTime> lastLoginProperty() {
            return this.lastLogin;
        }
    
        public final LocalDateTime getLastLogin() {
            return this.lastLoginProperty().get();
        }
    
        public final void setLastLogin(final LocalDateTime lastLogin) {
            this.lastLoginProperty().set(lastLogin);
        }
    
        public final MapProperty<String, Object> preferencesProperty() {
            return this.preferences;
        }
    
        public final ObservableMap<String, Object> getPreferences() {
            return this.preferencesProperty().get();
        }
    
        public final void setPreferences(final ObservableMap<String, Object> preferences) {
            this.preferencesProperty().set(preferences);
        }
    
        public final javafx.beans.property.ReadOnlyBooleanProperty enabledProperty() {
            return this.enabled.getReadOnlyProperty();
        }
    
        public final boolean isEnabled() {
            return this.enabledProperty().get();
        }
    
    }
  2. Build your form at runtime:

    Form<User> form = new FormBuilder<>(User.class).build();

You can register your own custom adapters with registerFieldAdapter(x) method to render the bean properties as specific UI components.

  1. Add it to your view:

    stage.setTitle("f(x)orms test");
    stage.setScene(new Scene(form));
    stage.show();
  2. Bind a bean to the form:

    User user = new User();
    [...]
    form.bind(user);

    A this is the result:

    screenshot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.