Announcement Announcement Module
No announcement yet.
Form binding with JList and Combobox Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Form binding with JList and Combobox

    I have dialog box looks like the following:

    and have following classes to bind the components in the form
    class  DeliveryScheculeBean {
    	private Company company;
    	private List<Date> deliveryDates;
    class Company {
       private String name;
       private Address address;
    class Address {
        private String street;
        private String city;
        private String state;
        private String zipCode;
    I would like to bind DeliveryScheduleBean.comapany with the item selected in JCombobox with Comapany objects, displaying name. JCombobox is populated with Company objects retrieved from database, and JList is populated with Date objects available for the selected company from the JCombobox.

    when user click on OK button, how do I get the DeliveryScheduleBean pupulated with selected company object, and available dates in the JList using TitledPageDialogBox.

    looking for example binding of combobox, and jlist.
    Last edited by pkbhavani; Jul 30th, 2008, 12:27 PM.

  • #2
    You have multiple options, a ListSelectionDialogBinder (explained at combines a combobox with auto-type filtering, or you could look at the source code of jpetstore, there are some other binding types there, eg the ShuffleListBinder is also very usefull. In all cases, your Form class will contain only a few lines of code, also in jpetstore are a few examples how JComponents can be autobound to certain class types, eg JXDatePicker to a Date.class, etc.


    • #3
      To further simplify, dialog box is as follows

      can anyone give me an example of binding JList with arrayList of Date objects in DeliveryScheculeBean


      • #4
        If you do not need the user to choose for a delivery date within the JList, you can probably populate your bean as you populate your JList.

        What you could do is to retrieve the ValueModel of the "company" property, add a change listener on it, and each time it changes, populate the JList and populate the ValueModel of the "deliveryDates" property.

        Hope this help!