Skip to main content
  1. Softwares/

OBJ2GUI2

·384 words·2 mins
Table of Contents

About
#

OBJ2GUI2 is a Java library that automatically generates Swing GUI interfaces from annotated Java objects. It uses introspection and a rich annotation system to create dynamic, editable forms with minimal code — perfect for property editors, configuration interfaces, and data entry forms.

It’s based on the experience i made called OBJ2GUI see or here

All input controls are validated automatically to forbid bad input, avoiding developer headache (eg: a TextField bound to an Integer won’t accept non-digit characters).

The difference with OBJ2GUI is that OBJ2GUI2 can support collections of objects instead of just one object: when the selected objects have different values, the difference is highlighted, and the user can apply the value of the last selected object to the whole selection.

Features
#

Core
#

  • Automatic GUI generation - Complete forms from simple annotations, via JPanelMagique
  • Multiple input types - TextFields, Sliders, ComboBoxes, CheckBoxes, DatePickers, file choosers, and more
  • Multi-object editing - Edit multiple objects at once, with difference highlighting (orange)
  • Nested object support - Recursive editing of complex object hierarchies
  • Collection support - Built-in editors for Lists and Arrays

Advanced
#

  • Plugin system - Extend with custom type handlers
  • I18n support - Automatic label management with XML and locale support
  • Validation - Built-in and custom validators
  • Layout control - Flexible layout management with MigLayout
  • Tree view - Hierarchical object navigation
  • Binding system - Map IDs to objects for ComboBoxes
  • Event system - Listeners notified on every object change

Quick Start
#

Annotate your class:

public class Person {

    @PROPERTY_interface(gui_type = gui_type.TEXTFIELD)
    private String name;

    @PROPERTY_interface(gui_type = gui_type.SLIDER, min = 0, max = 120)
    private int age;

    @PROPERTY_interface(gui_type = gui_type.COMBO)
    private Gender gender;

    @PROPERTY_interface(gui_type = gui_type.DATEPICKER)
    private Date birthDate;

    // Getters and setters...
}

Then generate the GUI:

List<Person> persons = Arrays.asList(new Person(), new Person());

JPanelMagique panel = JPanelMagique.GenerateJPanelFromSelectionAndBindings(
    persons, null);

JFrame frame = new JFrame("Person Editor");
frame.add(new JScrollPane(panel));
frame.setSize(400, 300);
frame.setVisible(true);
OBJ2GUI3 preview — the successor of OBJ2GUI2 is in development: a redesigned annotation system on getters (@O2G3Property, @O2G3NestedObject, @O2G3ListProperty), built-in undo/redo, heterogeneous multi-object selection, and memory-leak-safe listeners. Discover the public preview.

GitHub link#

Source code is available in GitHub

Maven repository
#

Find all version here

Import Maven
#

<!-- https://mvnrepository.com/artifact/io.github.warnotte/obj2gui2 -->
<dependency>
    <groupId>io.github.warnotte</groupId>
    <artifactId>obj2gui2</artifactId>
    <version>1.4.9</version>
</dependency>

Import Graddle
#

// https://mvnrepository.com/artifact/io.github.warnotte/obj2gui2
implementation 'io.github.warnotte:obj2gui2:1.4.9'

comments powered by Disqus