protected JComponent buildComponent ( ) { helperList . setSelectionMode ( ListSelectionModel . MULTIPLE_INTERVAL_SELECTION ) ; GridBagLayout gbl = new GridBagLayout ( ) ; GridBagConstraints gbc = new GridBagConstraints ( ) ; setLayout ( gbl ) ; editButton = new JButton ( "Edit..." ) ; editButton . setIconTextGap ( 0 ) ; editButton . setMargin ( new Insets ( 2 , 4 , 2 , 4 ) ) ; editButton . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent event ) { togglePanels ( ) ; } } ) ; gbc . fill = GridBagConstraints . NONE ; gbc . weightx = 0.0 ; gbc . weighty = 0.0 ; gbc . insets = new Insets ( 0 , 0 , 0 , 3 ) ; gbc . anchor = GridBagConstraints . NORTHWEST ; gbl . setConstraints ( editButton , gbc ) ; add ( editButton ) ; sourceList . setSelectionMode ( ListSelectionModel . MULTIPLE_INTERVAL_SELECTION ) ; sourceList . addKeyListener ( new KeyAdapter ( ) { public void keyPressed ( final KeyEvent e ) { if ( e . getKeyCode ( ) == KeyEvent . VK_ENTER || e . getKeyCode ( ) == KeyEvent . VK_RIGHT ) { moveLeftToRight ( ) ; } } } ) ; gbc . fill = GridBagConstraints . BOTH ; gbc . weightx = 1.0 ; gbc . weighty = 1.0 ; sourcePanel . add ( BorderLayout . NORTH , sourceLabel ) ; JScrollPane sourceScroller = new JScrollPane ( sourceList ) ; sourcePanel . add ( BorderLayout . CENTER , sourceScroller ) ; gbl . setConstraints ( sourcePanel , gbc ) ; add ( sourcePanel ) ; // JPanel buttonPanel = new ControlButtonPanel(); JPanel buttonPanel = buildButtonPanel ( ) ; gbc . fill = GridBagConstraints . VERTICAL ; gbc . weightx = 0 ; gbc . weighty = 1.0 ; gbl . setConstraints ( buttonPanel , gbc ) ; add ( buttonPanel ) ; chosenList . setSelectionMode ( ListSelectionModel . MULTIPLE_INTERVAL_SELECTION ) ; chosenList . addKeyListener ( new KeyAdapter ( ) { public void keyPressed ( final KeyEvent e ) { if ( e . getKeyCode ( ) == KeyEvent . VK_ENTER || e . getKeyCode ( ) == KeyEvent . VK_LEFT ) { moveRightToLeft ( ) ; } } } ) ; gbc . fill = GridBagConstraints . BOTH ; gbc . weightx = 1.0 ; gbc . weighty = 1.0 ; chosenPanel . add ( BorderLayout . NORTH , chosenLabel ) ; JScrollPane chosenScroller = new JScrollPane ( chosenList ) ; chosenPanel . add ( BorderLayout . CENTER , chosenScroller ) ; gbl . setConstraints ( chosenPanel , gbc ) ; add ( chosenPanel ) ; editButton . setVisible ( showEditButton ) ; this . buttonPanel . setVisible ( panelsShowing ) ; sourcePanel . setVisible ( panelsShowing ) ; return this ; }
Build our component panel .