import javax.swing.*; import java.io.*; import java.awt.*; import java.awt.event.*; import javax.sound.sampled.*; public class uus_playa extends JFrame { public uus_playa() { setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("Muusika mängija"); setSize(250, 100); currentDir = new File(System.getProperty("user.dir")); FilenameFilter filter = new FilenameFilter() { public boolean accept(File directory, String filename) { String name = filename.toLowerCase(); return name.endsWith(".au")|| name.endsWith(".aif")|| name.endsWith(".wav"); } }; String soundFiles[] = currentDir.list(filter); if(soundFiles == null||soundFiles.length == 0) { JOptionPane.showMessageDialog(this, "No sound files - terminating...", "Sound Files Error", JOptionPane.ERROR_MESSAGE); System.exit(1); } JComboBox soundChoice = new JComboBox(soundFiles); soundChoice.setSelectedIndex(0); oldFilename = soundFiles[0]; player = new ClipPlayer(soundFiles[0]); soundChoice.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } } ); play = new JButton("PLAY"); play.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("PLAY")) { } else { } } }); Container content = getContentPane(); content.add(soundChoice); content.add(play, BorderLayout.SOUTH); setVisible(true); } public static void main(String[] args) { uus_playa soundPlayer = new uus_playa(); } public class ClipPlayer { public ClipPlayer(String filename) { } private Clip clip; } private File currentDir; private JButton play; private String oldFilename; private ClipPlayer player; }