{"id":20405451,"url":"https://github.com/parubok/swing-fx-properties","last_synced_at":"2025-07-09T09:04:25.177Z","repository":{"id":41434805,"uuid":"272687971","full_name":"parubok/swing-fx-properties","owner":"parubok","description":"Adaptation of JavaFX properties for Swing.","archived":false,"fork":false,"pushed_at":"2024-01-04T20:01:17.000Z","size":1838,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T09:22:03.025Z","etag":null,"topics":["java","javafx","property-binding","swing","swing-gui"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parubok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-16T11:18:50.000Z","updated_at":"2024-12-07T14:14:36.000Z","dependencies_parsed_at":"2022-07-25T05:15:04.962Z","dependency_job_id":"7f2920ad-8069-4701-8151-427937aa9d2b","html_url":"https://github.com/parubok/swing-fx-properties","commit_stats":{"total_commits":323,"total_committers":1,"mean_commits":323.0,"dds":0.0,"last_synced_commit":"ff4c8d437a0a864ed765038e58076cb4413cff6b"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parubok%2Fswing-fx-properties","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parubok%2Fswing-fx-properties/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parubok%2Fswing-fx-properties/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parubok%2Fswing-fx-properties/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parubok","download_url":"https://codeload.github.com/parubok/swing-fx-properties/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586227,"owners_count":21128995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","javafx","property-binding","swing","swing-gui"],"created_at":"2024-11-15T05:10:52.097Z","updated_at":"2025-04-12T14:53:10.819Z","avatar_url":"https://github.com/parubok.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Java CI with Maven](https://github.com/parubok/swing-fx-properties/workflows/Java%20CI%20with%20Maven/badge.svg)\n[![Latest Version](https://img.shields.io/maven-central/v/io.github.parubok/swing-fx-properties)](https://search.maven.org/search?q=a:swing-fx-properties)\n[![javadoc](https://javadoc.io/badge2/io.github.parubok/swing-fx-properties/javadoc.svg)](https://javadoc.io/doc/io.github.parubok/swing-fx-properties)\n\n# swing-fx-properties\nAdaptation of [JavaFX properties](https://docs.oracle.com/javafx/2/binding/jfxpub-binding.htm) for [Swing](https://en.wikipedia.org/wiki/Swing_(Java)).\n\nJavaFX introduced an improved approach to component properties handling.\nIn JavaFX, component properties are type safe, referenced by method (and not via string name like in Swing) and, what is probably the most significant improvement, support [binding](https://docs.oracle.com/javase/8/javafx/properties-binding-tutorial/binding.htm).\n\nThe JavaFX properties implementation, in fact, is not JavaFX specific - it is a generic property mechanism which can be used for any JavaBean (see [`JavaBeanObjectPropertyBuilder`](https://javadoc.io/doc/io.github.parubok/swing-fx-properties/latest/io/github/parubok/swingfx/beans/property/adapter/JavaBeanObjectPropertyBuilder.html)).\n\nThis project took the relevant pieces of JavaFX properties code and added support for Swing - to allow usage of JavaFX-style properties and related functionality with Swing components.\n\n**Note:** The default JavaFX handling of binding evaluation errors was changed from logging the error and returning some default value to throwing [`BindingEvaluationException`](https://javadoc.io/doc/io.github.parubok/swing-fx-properties/latest/io/github/parubok/swingfx/beans/binding/BindingEvaluationException.html). For some cases, this library also provides alternative methods which allow to specify a default value which is returned instead of throwing `BindingEvaluationException`.\nExample:\n- `Bindings.valueAt(ObservableList\u003cE\u003e op, int index)` - throws [`BindingEvaluationException`](https://javadoc.io/doc/io.github.parubok/swing-fx-properties/latest/io/github/parubok/swingfx/beans/binding/BindingEvaluationException.html) in case of invalid index.\n- `Bindings.valueAt(ObservableList\u003cE\u003e op, int index, E defaultValue)` - returns the specified default value in case of invalid index.\n\nThe Swing properties are obtained via static methods of class [`SwingPropertySupport`](https://javadoc.io/doc/io.github.parubok/swing-fx-properties/latest/io/github/parubok/fxprop/SwingPropertySupport.html).\n\nExample 1 (bind 'enabled' property of a label to 'selected' property of a checkbox, so the label is disabled when the checkbox is unselected and vice versa):\n\n```java\nimport static io.github.parubok.fxprop.SwingPropertySupport.enabledProperty;\nimport static io.github.parubok.fxprop.SwingPropertySupport.selectedProperty;\n\nJCheckBox checkBox = new JCheckBox(); // unselected checkbox\nJLabel label = new JLabel();\nenabledProperty(label).bind(selectedProperty(checkBox));\n// label is now disabled since the checkbox is not selected\ncheckBox.setSelected(true);\n// label is now enabled\n```\n\nExample 2 (bind 'enabled' property of an action to 'selectedRowCount' property of a table, so the action is disabled when the table has no selected rows and vice versa):\n\n```java\nimport static io.github.parubok.fxprop.SwingPropertySupport.enabledProperty;\nimport static io.github.parubok.fxprop.SwingPropertySupport.selectedProperty;\n\nAction action = ...; // for example, 'delete table rows' action\nJTable table = ...;\nenabledProperty(action).bind(selectedRowCountProperty(table).greaterThanOrEqualTo(1));\n```\n\nThe following APIs were added to the original APIs of JavaFX:\n- `Bindings.createObjectBinding(ObservableValue\u003cK\u003e value1, ObservableValue\u003cT\u003e value2, BiFunction\u003cK, T, D\u003e func)`\n- `Bindings.createObjectBinding(ObservableValue\u003cD\u003e value1, ObservableValue\u003cF\u003e value2, ObservableValue\u003cG\u003e value3, TriFunction\u003cD, F, G, R\u003e func)`\n- `Bindings.stringValueAt(ObservableMap\u003cK, String\u003e op, K key, String defaultValue)`\n- `Bindings.valueAt(ObservableMap\u003cK, V\u003e op, K key, V defaultValue)`\n- `Bindings.valueAt(ObservableList\u003cE\u003e op, int index, E defaultValue)`\n- `Bindings.valueAt(ObservableList\u003cE\u003e op, ObservableIntegerValue index, E defaultValue)`\n- `ObservableMap.valueAt(K key, V defaultValue)`\n- `ObservableList.valueAt(int index, E defaultValue)`\n- `ObservableValue.asObject(Function\u003cT, K\u003e func)`\n- `ObservableValue.asBoolean(Predicate\u003cT\u003e predicate)`\n- `ObservableValue.asStringExpression(String format)`\n\n**Note:** As specified in `bind` [method JavaDoc](https://docs.oracle.com/javase/8/javafx/api/javafx/beans/property/Property.html#bind-javafx.beans.value.ObservableValue-), JavaFX has all the bind calls implemented through weak listeners. This means the bound property can be garbage collected and stopped from being updated unless there is a strong reference pointing to it.\n\nIncludes a stand-alone demo `io.github.parubok.fxprop.demo.Demo` under `test` source sub-root. \n\nSince [JavaFX](https://github.com/openjdk/jfx) is licensed under [GPL v2 with the Classpath exception](http://openjdk.java.net/legal/gplv2+ce.html), the same license applies to this project.\n\nThis project has no dependencies (except JUnit 5, for testing).\n\nRequires Java 8 or later.\n\n### Installation\n\nReleases are available in [Maven Central](https://repo1.maven.org/maven2/io/github/parubok/swing-fx-properties/)\n\n#### Maven\n\nAdd this snippet to the pom.xml `dependencies` section:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.parubok\u003c/groupId\u003e\n    \u003cartifactId\u003eswing-fx-properties\u003c/artifactId\u003e\n    \u003cversion\u003e1.25\u003c/version\u003e\n\u003c/dependency\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparubok%2Fswing-fx-properties","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparubok%2Fswing-fx-properties","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparubok%2Fswing-fx-properties/lists"}