Java JToggleButton freezes in While loop
问题 public void playMet() { int tempo = Integer.parseInt(met_speed.getText()); tempo = tempo/60; int delay = tempo*1000; if(Play.isSelected()) { try { FileInputStream in = new FileInputStream(new File("Click1.wav")); AudioStream as = new AudioStream(in); AudioPlayer.player.start(as); Thread.sleep(tempo*1000); playMet(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } else System.out.println("not playing"); } Here's a section of my code, basically when a button is pressed it