-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlertAPI.java
More file actions
47 lines (41 loc) · 1.45 KB
/
AlertAPI.java
File metadata and controls
47 lines (41 loc) · 1.45 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
package fr.northenflo.frame;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
public class AlertAPI {
public static JPanel alert_panel = new JPanel();
public static JLabel alert_label = new JLabel();
public static void Show(String message, String status){
alert_panel.setVisible(true);
alert_label.setText(message);
if(status.equalsIgnoreCase("danger")){
alert_panel.setBackground(new Color(231,72,69));
}else if(status.equalsIgnoreCase("success")){
alert_panel.setBackground(new Color(65,176,67));
}else if(status.equalsIgnoreCase("infos")){
alert_panel.setBackground(new Color(77, 163, 205));
}else{
System.out.println("[LOG] Erreur lors de l'affichage du FlashAlert");
}
}
public static JPanel AddAlertPanel(int x_p, int y_p, int x_s, int y_s)
{
Font font = new Font("Calibri", 0, 16);
alert_panel.setBounds(x_p, y_p, x_s, y_s);
alert_panel.setVisible(false);
alert_panel.setLayout(new BoxLayout(alert_panel, BoxLayout.Y_AXIS));
alert_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
alert_panel.setBorder(new EmptyBorder(6, 10, 10, 10));
alert_label.setBounds(10, 10, 20, 20);
alert_label.setFont(font.deriveFont(16.0F));
alert_label.setForeground(Color.WHITE);
alert_panel.add(alert_label);
return alert_panel;
}
}