-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudyVideos.java
More file actions
49 lines (42 loc) · 1.68 KB
/
StudyVideos.java
File metadata and controls
49 lines (42 loc) · 1.68 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
import javax.swing.*;
import java.awt.*;
import java.net.URI;
public class StudyVideos {
public void showVideoLinks() {
// Frame for video links
JFrame frame = new JFrame("Study Videos");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(800, 700);
frame.setLayout(new GridLayout(3, 1, 10, 10)); // Adjust rows for the number of links
frame.getContentPane().setBackground(Color.decode("#424242"));
// Video Links
String[] videoTitles = {
"1. Java Full Course for Beginners",
"2. C Full Course for Beginners",
"3. Python Full Course for Beginners"
};
String[] videoLinks = {
"https://www.youtube.com/watch?v=eIrMbAQSU34&t=8s",
"https://www.youtube.com/watch?v=Bz4MxDeEM6k",
"https://www.youtube.com/watch?v=K5KVEU3aaeQ"
};
// Create buttons for each video link
for (int i = 0; i < videoTitles.length; i++) {
String title = videoTitles[i];
String link = videoLinks[i];
JButton button = new JButton(title);
button.setFont(new Font("Arial", Font.BOLD, 22));
// Add action listener using a lambda expression
button.addActionListener(e -> {
try {
Desktop.getDesktop().browse(new URI(link));
} catch (Exception ex) {
JOptionPane.showMessageDialog(frame, "Unable to open link: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
});
frame.add(button);
}
// Display the frame
frame.setVisible(true);
}
}