-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPDFXLSMP3.java
More file actions
80 lines (68 loc) · 1.97 KB
/
PDFXLSMP3.java
File metadata and controls
80 lines (68 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package Codes;
import jaco.mp3.player.MP3Player;
import java.awt.Desktop;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFrame;
public class PDFXLSMP3 extends JFrame {
public static void main(String[] args) {
PDFXLSMP3 frame = new PDFXLSMP3();
frame.setVisible(true);
}
/**
* Create the frame.
*/
public PDFXLSMP3() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
getContentPane().setLayout(null);
JButton btnPdf = new JButton("PDF");
btnPdf.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openFile("NodeJS.pdf");
}
});
btnPdf.setFont(new Font("Tahoma", Font.BOLD, 18));
btnPdf.setBounds(25, 133, 89, 23);
getContentPane().add(btnPdf);
JButton btnXls = new JButton("PPT");
btnXls.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openFile("NodeJS.pptx");
}
});
btnXls.setFont(new Font("Tahoma", Font.BOLD, 18));
btnXls.setBounds(138, 133, 89, 23);
getContentPane().add(btnXls);
JButton btnMp = new JButton("MP3");
btnMp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
play();
// openFile("Zindagi.mp3");
}
});
btnMp.setFont(new Font("Tahoma", Font.BOLD, 18));
btnMp.setBounds(252, 133, 89, 23);
getContentPane().add(btnMp);
}
private void openFile(String fileName) {
if (Desktop.isDesktopSupported()) {
try {
File myFile = new File("C:\\Users\\arnav\\Desktop\\" + fileName);
Desktop.getDesktop().open(myFile);
} catch (IOException ex) {
ex.printStackTrace();
// no application registered for PDFs
}
}
}
private void play() {
// http://jacomp3player.sourceforge.net/download.html
MP3Player player = new MP3Player(new File("C:\\Users\\arnav\\Desktop\\Zindagi.mp3"));
player.play();
}
}