question: public void init ( ) { pubPanel . setLayout ( new BorderLayout ( ) ) ; topic = new JComboBox ( ) ; topic . setEditable ( true ) ; topic . setMaximumSize ( MQTTFrame . TEXT_FIELD_DIMENSION ) ; topic . setMaximumRowCount ( 5 ) ; qosList = new JComboBox ( qos ) ; qosList . setSelectedIndex ( 0 ) ; qosList . setMaximumSize ( MQTTFrame . DROP_DOWN_DIMENSION ) ; pubData = new JTextArea ( 3 , 30 ) ; pubData . setBorder ( new BevelBorder ( BevelBorder . LOWERED ) ) ; pubData . setMargin ( MQTTFrame . TEXT_MARGINS ) ; retained = new JCheckBox ( ) ; retained . setSelected ( false ) ; pubLabel = new JLabel ( PANEL_TITLE + " - text display" ) ; Font f = pubLabel . getFont ( ) ; pubLabel . setFont ( new Font ( f . getName ( ) , Font . BOLD , f . getSize ( ) + 1 ) ) ; JPanel topicBox = new JPanel ( ) ; topicBox . setLayout ( new BoxLayout ( topicBox , BoxLayout . X_AXIS ) ) ; topicBox . add ( new JLabel ( " Topic:" ) ) ; topicBox . add ( topic ) ; topicBox . add ( new JLabel ( " QoS:" ) ) ; topicBox . add ( qosList ) ; topicBox . add ( new JLabel ( " Retained:" ) ) ; topicBox . add ( retained ) ; JPanel titleAndTopic = new JPanel ( ) ; titleAndTopic . setLayout ( new GridLayout ( 2 , 1 ) ) ; titleAndTopic . add ( pubLabel ) ; titleAndTopic . add ( topicBox ) ; hexDisplay = false ; hexButton = new JButton ( "Hex" ) ; hexButton . addActionListener ( this ) ; fileButton = new JButton ( "File..." ) ; fileButton . setEnabled ( true ) ; fileButton . addActionListener ( this ) ; pubButton = new JButton ( "Publish" ) ; pubButton . setEnabled ( false ) ; pubButton . addActionListener ( this ) ; JPanel buttons = new JPanel ( ) ; buttons . setLayout ( new GridLayout ( 3 , 1 ) ) ; buttons . add ( pubButton ) ; buttons . add ( fileButton ) ; buttons . add ( hexButton ) ; JPanel buttonLayout = new JPanel ( ) ; buttonLayout . add ( buttons ) ; pubPanel . add ( titleAndTopic , BorderLayout . NORTH ) ; pubPanel . add ( new JScrollPane ( pubData ) , BorderLayout . CENTER ) ; pubPanel . add ( buttonLayout , BorderLayout . EAST ) ; }
target:  The init method builds all the required components and adds them to the publication panel. Different layout managers are used throughout to ensure that the components resize correctly as the window resizes.