DEMUX Framework 让 Java 开发在可以构建模块化、跨平台应用,可运行在桌面、Web、移动和嵌入式设备上,基于 OSGi,支持创建 JavaFX 桌面应用、移动应用 (Android, iOS, Windows) 和 Web 应用。
示例代码:
public class HelloView extends DMXAbstractView { // UI stuff private HBox hbox; private Text text; private Button button; // model data private boolean testData; public HelloView(){ hbox = new HBox(); text = new Text("Hello, DEMUX!"); button = new Button("Click me"); hbox.getChildren().add(text); hbox.getChildren().add(button); hbox.setPadding(new Insets(5, 10, 15, 20)); } @Override public void render() { if(testData){ text.setFill(Color.GREEN); } else { text.setFill(Color.RED); } } @Override public String getParentViewId() { return JFXViewManager.JFX_ROOT_VIEW_ID; } @Override public void updateFromModel(Map<String, Object> dataMap) { testData = (Boolean)(dataMap.get("testData")); } @Override public Object getViewUI() { return hbox; } @Override protected void loadDataIds() { dataIds.add("testData"); } }
执行效果: