public class SimpleButtonTest
{
public static void main(String[] args)
{
ButtonFrame frame = new ButtonFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
// 包含一个按钮的自定义框架类
class ButtonFrame extends JFrame
{
public ButtonFrame()
{
setTitle("SimpleButtonTest");
setSize(300,200);
public class MidiSoundTest {
private static Sequencer midiPlayer;
// testing main method
public static void main(String[] args) {
startMidi("song1.mid"); // start the midi player
try {
Thread.sleep(10000); // delay
} catch (InterruptedException e) { }
System.out.println("faster");
midiPlayer.setTempoFactor(2.0F); // >1 to speed up the tempo
try {
Thread.sleep(10000); // delay
} catch (InterruptedException e) { }
// Do this on every move step, you could change to another song
if (!midiPlayer.isRunning()) { // previous song finished
// reset midi player and start a new song
midiPlayer.stop();
midiPlayer.close();
startMidi("song2.mid");
}
}