public BallControlUsingThread() { // Group buttons in a panel JPanel panel = new JPanel(); panel.add(jbtSuspend); panel.add(jbtResume); panel.add(jbtAdd); panel.add(jbtSubtract); // Add ball and buttons to the panel ball.setBorder(new javax.swing.border.LineBorder(Color.red)); jsbDelay.setOrientation(JScrollBar.HORIZONTAL); ball.setDelay(jsbDelay.getMaximum()); setLayout(new BorderLayout()); add(jsbDelay, BorderLayout.NORTH); add(ball, BorderLayout.CENTER); add(panel, BorderLayout.SOUTH); // Register listeners jbtSuspend.addActionListener(this); jbtResume.addActionListener(this); jbtAdd.addActionListener(this); jbtSubtract.addActionListener(this); jsbDelay.addAdjustmentListener(this); }