Alex Rivera | Logout

GUI library for handling primitives and arrays/collections of primitives

Asked 2012-05-04T07:01:13.617
10

I have built many many GUI:s and I don't like to have dependencies to libraries so I end up doing much of the basics myself. One thing that I end up doing over and over again is mapping primitives to GUI components.

For example if it is a boolean I often use JCombobox with two options ("true", "false") and if it is int I use a JTextField. Much of the work is to go from and to text...

Some example mappings:

  • int or Integer => JTextField or JSpinner
  • boolean => JTextField, JComboBox or JCheckBox
  • int[] => JList (with "add" field and "remove" buttons)
  • Set<Byte> => probably the same as arrays

So, to the questions:

  • Is there already a library that have mappings like this or do I need to "invent" it again?
  • I have seen jfg that uses refection and SWT as frontend (you can implement a new frontend using swing but that is exactly what I'm trying to avoid). Is there a simular library that uses swing and refection?
Edit
Report

2 Answers

1

One should mention JavaFX, which is still not my beer.

answered 2012-05-06T10:28:36.263
0

You might find it interesting to take a look at seesaw which is a GUI library for Clojure baseed on Swing.

It does a pretty good job of wrapping Swing functionality in pretty simple functions - some good design ideas even if you don't end up using it directly. For example, it can bind controls directly to mutable data objects:

; Bind a the value of a slider to an atom, with a transform
; that forces the value to [0, 1]
(let [s (slider :min 0 :max 1)
      a (atom 0.0)]
  (bind s (transform / 100.0) a))
answered 2012-05-21T16:22:40.750

Your Answer