package javafxapplication2;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.PopupMenu;
import java.awt.event.ActionListener;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.stage.Stage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.filechooser.FileFilter;
import static sun.audio.AudioPlayer.player;
public class JavaFXApplication2 extends Application implements ActionListener {
public JavaFXApplication2 (PopupMenu exit_f, PopupMenu open_f, JButton play_btn, JButton next_btn, JButton stop_btn, Vector list)
{
JMenu file=new JMenu("File");
open_f.addActionListener ((ActionListener) this);
exit_f.addActionListener ((ActionListener) this);
file.add (open_f);
file.add (exit_f);
JMenuBar bar=new JMenuBar();
bar.add (file);
play_btn=new JButton("PLAY");
next_btn=new JButton("NEXT");
stop_btn=new JButton("STOP");
next_btn.setEnabled (false);
stop_btn.setEnabled (false);
JPanel panel=new JPanel(new GridLayout(1,3));
panel.add (play_btn);
panel.add(next_btn);
panel.add(stop_btn);
//File f=new File("c:/ksm/mp3");
list=new Vector(1,1);
play_btn.addActionListener(this);
next_btn.addActionListener(this);
stop_btn.addActionListener(this);
}
private JavaFXApplication2() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public void actionPerformed (ActionEvent e, Object exit_f, Object open_f)
{
{
play_btn.setEnabled (false);
next_btn.setEnabled (true);
stop_btn.setEnabled (true);
int count = 0;
play(count);
if(count==list.size()-1)
{
count=0;
}
else
{
count++;
}
play(count);
player.stop ();
play_btn.setEnabled (true);
next_btn.setEnabled (false);
stop_btn.setEnabled (false);
}
if(e.getSource ()==open_f)
{
System.out.println("in open_f event");
open();
}
if(e.getSource ()==exit_f)
{
System.out.println("in exit_f event");
}
}
public void play(int v, boolean status)
{
if(status==true)
{
player.stop();
status=false;
}
if(status==false)
{
try
{
player.start();
status=true;
}
catch(Exception murle)
{
System.out.println("in murle");
}
}
}
public void open(FileFilter FileFilter, Component open_f)
{
JFileChooser fc=new JFileChooser(".mp3");
fc.setFileSelectionMode (JFileChooser.FILES_ONLY);
try {
FileReader filter=new FileReader("mp3");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
fc.addChoosableFileFilter(FileFilter);
int result=fc.showOpenDialog (open_f);
if(result==JFileChooser.APPROVE_OPTION)
{
File f=fc.getSelectedFile ();
if(f.exists ()==true && f.isFile ()==true)
{
list.add (f);
for(int i=0;i<list.size ();i++)
{
System.out.println(list.get (i));
}
}
else {
}
}
}
{
JavaFXApplication2 obj=new JavaFXApplication2();
obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void setDefaultCloseOperation(int EXIT_ON_CLOSE) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private void open() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private void play(int count) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void start(Stage stage) throws Exception {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void actionPerformed(java.awt.event.ActionEvent ae) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private static class Player {
public Player() {
boolean status=false;
}
private static class list {
private static void add(File f) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private static int size() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private static boolean get(int i) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public list() {
}
}
private static class stop_btn {
private static void setEnabled(boolean b) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public stop_btn() {
}
}
private static class next_btn {
private static void setEnabled(boolean b) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public next_btn() {
}
}
private static class play_btn {
public play_btn() {
}
}
}
private class JavaFXApplication2Impl extends JavaFXApplication2 {
public JavaFXApplication2Impl(PopupMenu exit_f, PopupMenu open_f, JButton play_btn, JButton next_btn, JButton stop_btn, Vector list) {
super(exit_f, open_f, play_btn, next_btn, stop_btn, list);
}
@Override
public void actionPerformed(java.awt.event.ActionEvent ae) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void start(Stage stage) throws Exception {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private void player() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
private static class list {
private static boolean get(int i) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private static int size() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private static void add(File f) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public list() {
}
}
private static class play_btn {
private static void setEnabled(boolean b) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public play_btn() {
}
}
private static class next_btn {
private static void setEnabled(boolean b) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public next_btn() {
}
}
private static class stop_btn {
private static void setEnabled(boolean b) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
}