package voxo.client.views;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JWindow;
import javax.swing.SwingConstants;
import javax.swing.Timer;
import javax.swing.UIManager;
public class NoticeView extends JWindow implements ActionListener {
private static final long serialVersionUID = 7125782553222257225L;
public NoticeView(String msg) {
GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
try{
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
}
catch(Exception ex){
//ex.printStackTrace();
}
setBackground(Color.LIGHT_GRAY);
setLayout(null);
setSize(new Dimension(250, 120));
setPreferredSize(new Dimension(250, 120));
setAlwaysOnTop(true);
setLocation((e.getMaximumWindowBounds().width-250+e.getMaximumWindowBounds().x), (e.getMaximumWindowBounds().height-120+e.getMaximumWindowBounds().y));
JButton btnX = new JButton("X");
btnX.setBounds(205, 0, 45, 45);
btnX.addActionListener(this);
add(btnX);
JLabel lblNotice = new JLabel(msg);
lblNotice.setHorizontalAlignment(SwingConstants.CENTER);
lblNotice.setBounds(10, 25, 230, 84);
add(lblNotice);
setVisible(true);
new Timer(5000, this).start();
}
@Override
public void actionPerformed(ActionEvent e) {
this.dispose();
}
}