Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GUI library for handling primitives and arrays/collections of primitives

Tags:

java

swing

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?
like image 468
dacwe Avatar asked May 04 '12 07:05

dacwe


1 Answers

there are 2 binding libraries i've had some experience with:

  1. glazed lists - this library absolutely shines when you want to map a Collection to a jtable (one item per row, columns are attributes of the object).
  2. jgoodies binding - a more general-purpose library for mapping bean attributes to gui elements. its a bit more complex and difficult to pick up.

and why primitives? im assumming you store your model (the set of all values being displayed/edited by the gui) in one or more Objects no? if so, you could rely on autoboxing and work with object wrappers in the gui.

like image 101
radai Avatar answered Oct 30 '22 22:10

radai