Note that there are some explanatory texts on larger screens.

plurals
  1. POProgram still running after System.exit
    primarykey
    data
    text
    <p>I'm a bit desperate over here. I Have this jFrame and I need to close after I press Escape. This is easily done by using keyTyped Event. In the keyTyped event I tried to use System.exit which closes the window, but the process is still running in the task manager (and in the netbeans, even If I run from the jar file, it is still running in the task manager).</p> <p>I have tried dispose, setVisible(false) along with other things but nothing seems to work.</p> <p>EDIT:</p> <p>Code</p> <pre><code>public Sketch(int width, int height) { sketch = new JFrame(); area = new JLabel(); sketch.setUndecorated(true); sketch.setMinimumSize(new Dimension(width, height)); sketch.setSize(width, height); area.setBounds(0, 0, width, height); sketch.getContentPane().setLayout(null); sketch.getContentPane().add(area); sketch.pack(); sketch.setLocationRelativeTo(null); sketch.setVisible(true); sketch.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); imageBGR = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR); imageGRAY = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY); keyEvents(); setup(); Thread t = new Thread() { @Override public void run() { running=true; while(running) draw(); } }; t.start(); } private void keyEvents() { sketch.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { if(e.getKeyChar()==KeyEvent.VK_ESCAPE) { running=false; System.exit(0); } } }); } </code></pre> <p>NOTE: The setup function is a blank function that I override when extending this class.</p> <p>EDIT2: SOLVED</p> <p>I found out what I was doing wrong. It appears that in the class that I was extended this one, I was using a webcam. When I call the System.exit function the webcam led is turned off, so I thought I didn't need to properly release it, but it was in fact needed. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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