Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to do an action when a certain button is clicked
    text
    copied!<p>Basically, at the moment I am doing certain actions that are being held in an <code>ArrayList</code> and when I click the <code>Play</code> Button, they are being output to a <code>TextArea</code>. I have two other buttons, <code>Start</code> and <code>Stop</code>.</p> <ul> <li>When I click Start, every action that I do is supposed to start recording. </li> <li>When i click Stop, it stops recording the actions. </li> <li>When I click Play, the actions are supposed to be printed in the text area. </li> </ul> <p>I have got the hard bit working but I just can't seem to implement the start and stop buttons. I will attach part of my code so you are able to see. Thanks in advance!! </p> <pre><code>public class jPanelBottom extends javax.swing.JPanel { private JTextField jtfBoundaryLength, jtfArea; private JSlider jsShapes; private JLabel jLabelBoundaryLength, jLabelArea, jLabelSlider; private JButton jbStart, jbStop, jbPlay; public static ActionPanel yes; public jPanelBottom() { initComponents(); jbStart = new JButton(); jbStop.setText("Start"); jbStart.setSize(80, 25); jbStart.setLocation(400, 95); this.add(jbStart); jbStop = new JButton(); jbStop.setText("Stop"); jbStop.setSize(80, 25); jbStop.setLocation(500, 95); this.add(jbStop); jbPlay = new JButton(); jbPlay.setText("Play"); jbPlay.setSize(80, 25); jbPlay.setLocation(600, 95); this.add(jbPlay); jbPlay.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try{ //jbStart.addActionListener(this); { jbPlay.addActionListener(this); ArrayList&lt;String&gt; list = MyFrame.shape1.getArrayList(); for (String s : list) { ActionPanel.jtaWoof.append(s); ActionPanel.jtaWoof.append("\n"); } }}catch(Throwable ex){}} }); } </code></pre> <p>I really appreciate any help!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload