Note that there are some explanatory texts on larger screens.

plurals
  1. POEventDispatchThread.run() line: not available error in eclipse
    text
    copied!<p>I am new to Swing and was making a very basic event handling program in Eclipse. Here is the code that i wrote:</p> <pre><code>public class SwingDemo2 { JLabel jl; public SwingDemo2() { JFrame jfr = new JFrame("Swing Event Handling"); jfr.setSize(250, 100); jfr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jl = new JLabel(); jl.setVisible(false); JButton jb1 = new JButton("OK"); jb1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jl.setText("You Pressed OK"); jl.setVisible(true); } }); JButton jb2 = new JButton("Reset"); jb2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jl.setText("You Pressed Reset"); jl.setVisible(true); } }); jfr.setLayout(new BorderLayout()); jfr.add(jl, SwingConstants.NORTH); jfr.add(jb1, SwingConstants.EAST); jfr.add(jb2, SwingConstants.WEST); jfr.setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub SwingUtilities.invokeLater(new Runnable() { public void run() { new SwingDemo2(); } }); } } </code></pre> <p>Eclipse prompts me to open the debug perspective where he shows me the error:<br> <code>Thread [AWT-EventQueue-0] (Suspended (exception IllegalArgumentException))</code> <code>EventDispatchThread.run() line: not available [local variables unavailable]</code></p> <p>I didn't get any error when I used <code>FlowLayout</code> instead of <code>BorderLayout</code>.</p> <p>I have been trying to find info on the error on the portal, i came across <a href="https://stackoverflow.com/questions/5080912/java-error-eventdispatchthread-run-line-not-available-local-variables-unava">this</a> similar question. The answer is to change a bunch of settings (which didn't help either) without explaining the problem. Please explain the error so that i can make sure not to repeat it. Thanx in advance!</p> <p>Note: Updated the error message</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