-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageUtil.java
More file actions
80 lines (50 loc) · 2.12 KB
/
MessageUtil.java
File metadata and controls
80 lines (50 loc) · 2.12 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 utils;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import gui.message.MessageFrame;
import gui.message.MessageGUI;
public class MessageUtil {
public static final byte ROUNDED_TICK = 0;
public static final byte ROUNDED_QUESTION = 1;
public static final byte TRIANGLE_ALERT = 2;
public static final byte TRIANGLE_ALERT_2 = 3;
public static final byte ROUNDED_ALERT = 4;
public static final byte ROUNDED_DENIED = 5;
public static final int ANSWER_YES = 0;
public static final int ANSWER_NO = 1;
public static void showMessage(String title, String message, byte icon) {
MessageGUI.startGUI(title, message, icon);
}
public static int showConfirmMessage(String title, String message) {
// JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options)
UIManager UI=new UIManager();
JPanel messagePanel = new JPanel();
JButton acceptButton = new JButton("Delete");
ImageIcon icon = utils.ImageIOUtil.getInstance().getIcon("/resources/images/question.png");
messagePanel.setOpaque(true);
messagePanel.setBackground(new Color(97, 102, 109));
messagePanel.setForeground(Color.WHITE);
messagePanel.add(new JLabel(message));
acceptButton.setBackground(new Color(97, 102, 109));
acceptButton.setForeground(Color.WHITE);
UI.put("OptionPane.background", new Color(45, 45, 45));
JOptionPane dialog = new JOptionPane(messagePanel,
JOptionPane.PLAIN_MESSAGE,
JOptionPane.OK_OPTION,
icon,
new Object[] {acceptButton});
dialog.createDialog("Are you sure?").setVisible(true);;
return 1;
//return JOptionPane.showConfirmDialog(null, messagePanel, title, JOptionPane.YES_NO_OPTION);
}
public static void showErrorMessage(String title, String message, byte icon, Exception e) {
MessageGUI.startGUI(title,
message + String.format("\n \n Exception message = [ %s ]", e.getMessage()),
icon);
}
}