protected JPanel buildButtonPanel ( ) { buttonPanel = new JPanel ( ) ; leftToRight = new JButton ( ">" ) ; allLeftToRight = new JButton ( ">>" ) ; rightToLeft = new JButton ( "<" ) ; allRightToLeft = new JButton ( "<<" ) ; Font smallerFont = leftToRight . getFont ( ) . deriveFont ( 9.0F ) ; leftToRight . setFont ( smallerFont ) ; allLeftToRight . setFont ( smallerFont ) ; rightToLeft . setFont ( smallerFont ) ; allRightToLeft . setFont ( smallerFont ) ; Insets margin = new Insets ( 2 , 4 , 2 , 4 ) ; leftToRight . setMargin ( margin ) ; allLeftToRight . setMargin ( margin ) ; rightToLeft . setMargin ( margin ) ; allRightToLeft . setMargin ( margin ) ; GridBagLayout gbl = new GridBagLayout ( ) ; GridBagConstraints gbc = new GridBagConstraints ( ) ; buttonPanel . setLayout ( gbl ) ; gbc . gridwidth = GridBagConstraints . REMAINDER ; gbc . fill = GridBagConstraints . HORIZONTAL ; gbl . setConstraints ( leftToRight , gbc ) ; gbl . setConstraints ( allLeftToRight , gbc ) ; gbl . setConstraints ( rightToLeft , gbc ) ; gbl . setConstraints ( allRightToLeft , gbc ) ; buttonPanel . add ( leftToRight ) ; buttonPanel . add ( allLeftToRight ) ; buttonPanel . add ( rightToLeft ) ; buttonPanel . add ( allRightToLeft ) ; leftToRight . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent event ) { moveLeftToRight ( ) ; } } ) ; allLeftToRight . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent event ) { moveAllLeftToRight ( ) ; } } ) ; rightToLeft . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent event ) { moveRightToLeft ( ) ; } } ) ; allRightToLeft . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent event ) { moveAllRightToLeft ( ) ; } } ) ; buttonPanel . setBorder ( BorderFactory . createEmptyBorder ( 2 , 2 , 2 , 2 ) ) ; // buttonPanel.setBackground( Color.lightGray ); return buttonPanel ; }
Construct the control button panel .