p.setBackground(backgroundColor);
p.setForeground(foregroundColor);
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.CENTER;
Label tl = new Label(title);
tl.setFont(titleFont);
UIUtil.gridBagAdd(p, tl, gbc, GridBagConstraints.REMAINDER);
WrappingLabel l = new WrappingLabel();
l.setText(message);
l.setVAlignStyle(Canvas.TOP_ALIGNMENT);
l.setBackground(backgroundColor);
l.setForeground(foregroundColor);
gbc.fill = GridBagConstraints.BOTH;
gbc.weighty = 1.0;
l.setFont(textFont);
l.setHAlignStyle(textAlign);
gbc.weightx = 1.0;
if (image != null) {
Panel pi = new Panel(new BorderLayout(4, 0));
pi.setBackground(backgroundColor);
pi.setForeground(foregroundColor);
UIUtil.waitFor(image, this);
ImageCanvas c = new ImageCanvas(image);
c.setValign(Canvas.TOP_ALIGNMENT);
pi.add(c, BorderLayout.WEST);
pi.add(l, BorderLayout.CENTER);
UIUtil.gridBagAdd(p, pi, gbc, GridBagConstraints.REMAINDER);
} else {
UIUtil.gridBagAdd(p, l, gbc, GridBagConstraints.REMAINDER);
}
p.addMouseListener(this);
l.addMouseListener(this);
tl.addMouseListener(this);
add(p);
if (timeout > 0) {
Thread t = new Thread() {
public void run() {
try {
Thread.sleep(timeout);
} catch (InterruptedException ie) {
}
hideAndRemove(MessageWindow.this);
}
};
t.start();
}
if(actionText != null) {
Label l2 = new Label(actionText);
l2.setAlignment(Label.CENTER);
l2.setFont(new Font(titleFont.getName(), Font.PLAIN, 10));
gbc.anchor = GridBagConstraints.CENTER;
gbc.weightx = 1.0;
UIUtil.gridBagAdd(p, l2, gbc, GridBagConstraints.REMAINDER);
}
}