(Category)controller.getCategories(group).get(i);
(Category)controller.getCategories(group).get(selectedCategory);
    private void buildGUI()    {        Container container = getContentPane();        container.setLayout(new BorderLayout(2,2));                JPanel listPanel = new JPanel();        listPanel.setLayout(new GridLayout(1,2));                JPanel leftPanel = new JPanel();        leftPanel.setLayout(new BorderLayout(2,2));        JPanel leftLabelPanel = new JPanel();        leftLabelPanel.setLayout(new FlowLayout(FlowLayout.LEFT));        leftLabelPanel.add(new JLabel("Groups:"));        leftPanel.add(leftLabelPanel,BorderLayout.NORTH);                groupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        groupList.addListSelectionListener(new ListSelectionListener()        {            public void valueChanged(ListSelectionEvent e)            {                newCategoryButton.setEnabled(true);                categoryList.setEnabled(true);                if(groupList.getSelectedIndex() != -1)                {                    selectedGroup = groupList.getSelectedIndex();                }                CategoryGroup group =                    (CategoryGroup)controller.getCategoryGroups().get(selectedGroup);                buildCategoryList(group);                repaint();            }        });                groupList.addFocusListener(new FocusAdapter()        {            public void focusLost(FocusEvent arg0)            {                if(arg0.getOppositeComponent() != editButton)                {                    editButton.setEnabled(false);                }            }                        public void focusGained(FocusEvent arg0)            {                editButton.setEnabled(true);                editButton.setAction(editGroupAction);            }        });                JScrollPane scrollPane = new JScrollPane(groupList);        scrollPane.setPreferredSize(new Dimension(150,225));        leftPanel.add(scrollPane,BorderLayout.CENTER);        listPanel.add(leftPanel);                JPanel rightPanel = new JPanel();        rightPanel.setLayout(new BorderLayout(2,2));        JPanel rightLabelPanel = new JPanel();        rightLabelPanel.setLayout(new FlowLayout(FlowLayout.LEFT));        rightLabelPanel.add(new JLabel("Phenotypes:"));        rightPanel.add(rightLabelPanel,BorderLayout.NORTH);                categoryList.setEnabled(false);        categoryList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        categoryList.addListSelectionListener(new ListSelectionListener()        {            public void valueChanged(ListSelectionEvent e)            {                int i = categoryList.getSelectedIndex();                CategoryGroup group =                    (CategoryGroup)controller.getCategoryGroups().get(selectedGroup);                Category cat =                    (Category)controller.getCategories(group).get(i);                repaint();            }        });                categoryList.addFocusListener(new FocusAdapter()        {            public void focusLost(FocusEvent arg0)            {                if(arg0.getOppositeComponent() != editButton)                {                    editButton.setEnabled(false);                }            }                        public void focusGained(FocusEvent arg0)            {                editButton.setEnabled(true);                editButton.setAction(editCategoryAction);            }        });                JScrollPane rightScrollPane = new JScrollPane(categoryList);        rightScrollPane.setPreferredSize(new Dimension(150,225));        rightPanel.add(rightScrollPane,BorderLayout.CENTER);        listPanel.add(rightPanel);                JPanel detailsPanel = new JPanel();        detailsPanel.setBorder(BorderFactory.createLineBorder(Color.gray));        detailsPanel.setLayout(new BorderLayout(2,2));        detailsPanel.add(listPanel,BorderLayout.CENTER);                JPanel buttonPanel = new JPanel();                newGroupButton = new JButton("New Group");        newGroupButton.addActionListener(new ActionListener()        {            public void actionPerformed(ActionEvent ae)            {                CategoryEditUI.showCreateGroupDialog(refCopy,controller);            }        });                  buttonPanel.add(newGroupButton);        editButton = new JButton("Edit");        buttonPanel.add(editButton);                newCategoryButton = new JButton("New Phenotype");        newCategoryButton.setEnabled(false);        newCategoryButton.addActionListener(new ActionListener()        {            public void actionPerformed(ActionEvent ae)            {                CategoryGroup group =                    (CategoryGroup)controller.getCategoryGroups().get(selectedGroup);                CategoryEditUI.showCreateCategoryDialog(refCopy,controller,group);            }        });                buttonPanel.add(newCategoryButton);        detailsPanel.add(buttonPanel,BorderLayout.SOUTH);        container.add(detailsPanel,BorderLayout.CENTER);                JPanel savePanel = new JPanel();        savePanel.setLayout(new FlowLayout(FlowLayout.RIGHT));                JButton saveButton = new JButton("Save");        saveButton.setAction(saveAction);        savePanel.add(saveButton);        savePanel.add(Box.createHorizontalStrut(10));        JButton cancelButton = new JButton("Cancel");        cancelButton.setAction(cancelAction);        savePanel.add(cancelButton);        container.add(savePanel,BorderLayout.SOUTH);    }