-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
79 lines (66 loc) · 2.57 KB
/
App.java
File metadata and controls
79 lines (66 loc) · 2.57 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
public class App extends JFrame {
public App() {
//JPanel backgroundPanel = new JPanel();
setUndecorated(true);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
gd.setFullScreenWindow(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel contentPanel = new JPanel(new BorderLayout());
String[] imagePaths = {"image/movies7.png", "image/spotify.png", "image/youtube.png", "image/orange_tv.png"};
JPanel imagePanel = new JPanel(new GridLayout(2, 2)) {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Image backgroundImage = new ImageIcon("image/fond.jpg").getImage();
g.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), this);
}
};
for (int i = 0; i < 4; i++) {
JLabel imageLabel = new JLabel(new ImageIcon(imagePaths[i]));
final String url;
if (i == 0) {
url = "https://movies7.to/home";
} else if (i == 1) {
url = "https://open.spotify.com/";
} else if (i == 2) {
url = "https://www.youtube.com/";
} else {
url = "https://chaines-tv.orange.fr/?filtres=all";
}
imageLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
openLinkInBrowser(url);
}
});
imagePanel.add(imageLabel);
}
contentPanel.add(imagePanel, BorderLayout.CENTER);
add(contentPanel);
setVisible(true);
}
private void openLinkInBrowser(String url) {
try {
Process process = new ProcessBuilder("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe", url).start();
Thread.sleep(300);
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_F11);
robot.keyRelease(KeyEvent.VK_F11);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new App();
}
});
}
}