7 package org.libcsdbg.jtracer.installer;
9 import java.awt.event.KeyEvent;
10 import java.awt.event.ActionEvent;
11 import java.awt.event.ActionListener;
13 import java.awt.Color;
14 import java.awt.Insets;
15 import java.awt.BorderLayout;
16 import java.awt.GridBagLayout;
17 import java.awt.GridBagConstraints;
19 import javax.swing.JDialog;
20 import javax.swing.JFrame;
21 import javax.swing.JPanel;
22 import javax.swing.JLabel;
23 import javax.swing.ImageIcon;
24 import javax.swing.WindowConstants;
29 public class Alert extends JDialog implements ActionListener
56 Alert(JFrame owner, String msg,
short desc)
61 yes.setMnemonic(KeyEvent.VK_Y);
64 no.setMnemonic(KeyEvent.VK_N);
67 ok.setMnemonic(KeyEvent.VK_O);
69 GridBagLayout lm =
new GridBagLayout();
70 JPanel center =
new JPanel(lm);
71 JPanel south =
new JPanel(lm);
72 ImageIcon icon = null;
74 Registry conf = Registry.getCurrent();
75 GridBagConstraints c =
new GridBagConstraints();
76 c.gridy = c.gridx = 0;
77 c.insets =
new Insets(12, 4, 4, 4);
83 icon = conf.loadIcon(
"prompt32.png");
85 lm.setConstraints(yes, c);
89 lm.setConstraints(no, c);
95 icon = conf.loadIcon(
"error32.png");
96 lm.setConstraints(ok, c);
101 setTitle(
"Information");
102 icon = conf.loadIcon(
"info32.png");
103 lm.setConstraints(ok, c);
108 String lines[] = msg.split(
"\\n");
110 JLabel l =
new JLabel(icon);
112 c.insets =
new Insets(12, 12, 0, 12);
113 c.anchor = GridBagConstraints.NORTH;
114 c.gridheight = lines.length;
115 lm.setConstraints(l, c);
118 c.gridx = c.gridheight = 1;
119 c.insets =
new Insets(8, 0, 0, 8);
120 c.anchor = GridBagConstraints.WEST;
122 Font fnt = (Font) conf.
get(
"message",
"font");
123 Color fg = (Color) conf.
get(
"message",
"fgcolor");
124 for (
int i = 0, cnt = lines.length; i < cnt; i++) {
125 l =
new JLabel(lines[i]);
130 lm.setConstraints(l, c);
135 add(center, BorderLayout.CENTER);
136 add(south, BorderLayout.SOUTH);
138 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
141 setLocationRelativeTo(owner);
168 public static void error(JFrame owner, String msg,
boolean fatal)
183 public static void info(JFrame owner, String msg)
198 public static boolean prompt(JFrame owner, String msg)
213 String cmd = event.getActionCommand();
214 if (cmd.equals(
"Ok") || cmd.equals(
"Yes"))
220 catch (Throwable t) {
static final long serialVersionUID
Class version.
static final short INFORMATION_MSG
Alert type for plain, information messages.
Object get(String section, String key)
Get an entry.
boolean reply
The user reply.
static void error(JFrame owner, String msg, boolean fatal)
Show an error alert and exit if the error is marked as fatal.
void actionPerformed(ActionEvent event)
Handler for action events fired by the alert buttons.
static void info(JFrame owner, String msg)
Show a generic alert.
static final short ERROR_MSG
Alert type for error messages.
User alert or simple prompt dialog with configurable styles.
static final short QUESTION_MSG
Alert type for prompt messages.
static boolean prompt(JFrame owner, String msg)
Show an alert prompting the user to make a choice.
boolean getReply()
Get the user reply.