I am looking for a Java GUI editor or library with the following exotic property: the GUI can be manipulated on runtime. That is, a running frame can include special controls, e.g., right-click, that enable users to add buttons and other widgets to it.
Alternatively, I can use a GUI editor that can interact with a running Java program. The program says "please add a button" and the editor shows the user a palette with buttons. The user adds a button and presses it, and the program receives an event "button pressed".
It there such a thing that can be used off-the-shelf, without writing it from scratch?
Java's GUI components include labels, text fields, text areas, buttons, etc. The Abstract Windowing Toolkit (AWT) also includes containers which can include these components. Containers include frames (windows), canvases (which are used to draw on), and panels (which are used to group components).
GUI Component classes, such as Button , TextField , and Label . GUI Container classes, such as Frame and Panel . Layout managers, such as FlowLayout , BorderLayout and GridLayout . Custom graphics classes, such as Graphics , Color and Font .
Any compliant JavaBean library would support Design Time semantics. In a nutshell, a bean (component) is understood to run in a container. In design time, that container is the editor 'canvas' and in runtime, the root of of (gui) container hierarchy. The author of the bean is expected to query this state flag and act appropriately e.g. change borders in designtime to include 'handles' to drag for resize, etc. And, naturally, the parent component (which is assumed to be a design canvas of sorts) is also expected to respect design changes e.g. modify the layout to handle the resized component.
That said, I don't believe any of the current offerings allow you to simply switch between designtime and runtime at whim in your app.
Effectively, you'll need to (a) pick a library and (b) bundle the necessary machinery to support designtime with your running app, and (c) in effect masquerade a design surface (canvas) as your runtime gui. Of course you will only need to support the design ops you are interested in, but bottom line, you are writing a GUI editor.
What's the benefit of this approach? Well, you are reusing "components" and mostly need to hack the container.
If I had to do something like this, I would seriously look at netbeans, keep this STO question in mind, and take it from there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With