private ImageIcon messageAlertIcon;
private ImageIcon messageAlertNullIcon;
private Rectangle location;
public static TrayIcon trayicon;
private Dao dao;
//Preferences.systeRoot:返回系统的根首选项节点 Preferences:参数选择
public final static Preferences preferences = Preferences.systemRoot();
private JButton userInfoButton;
//----------------------------------------------------------------------------------
public static void main(String[] args){
try{
String laf = preferences.get("lookAndFeel", "java默认");
if(laf.indexOf("当前系统") > -1){
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
EQ frame = new EQ();
frame.setVisible(true);
frame.SystemTrayInitial();// 初始化系统栏
frame.server();
frame.checkPlacard();
}catch(Exception e){
e.printStackTrace();
}
}
//----------------------------------------------------------------------------------
public EQ(){
super(new JFrame());
frame = this;
dao = Dao.getDao();
location = dao.getLocation();
setTitle("EQ聊天");
setBounds(location);
progressBar = new JProgressBar();
//BevelBorder:该类实现简单的双线斜面边框。Bevel:斜面 lowered:凹入斜面类型。
progressBar.setBorder(new BevelBorder(BevelBorder.LOWERED));
tabbedPane = new JTabbedPane();
popupMenu = new JPopupMenu();
chatTree = new ChatTree(this);
user_dir = System.getProperty("user.dir");// 程序执行路径用于系统更新
localFile = new File(user_dir + File.separator + "EQ.jar");// 本地EQ文件
stateLabel = new JLabel();// 状态栏标签
this.addWindowListener(new FrameWindowListener());// 添加窗体监视器
this.addComponentListener(new ComponentAdapter(){
public void componentResized(final ComponentEvent e){
saveLocation();
}
public void componentMoved(final ComponentEvent e){
saveLocation();
}
});
try{// 启动通讯服务端口
ss = new DatagramSocket(1111);
}catch(SocketException e2){
if(e2.getMessage().startsWith("Address already in use")){
showMessageDialog("服务端口被占用,或者本软件已经运行。");
}
System.exit(0);
}
{// 初始化公共信息按钮
messageAlertIcon = new ImageIcon(EQ.class.getResource("/image/messageAlert.gif"));
messageAlertNullIcon = new ImageIcon(EQ.class.getResource("/image/messageAlertNull20.gif"));
messageStack = new Stack
messageAlertButton = new JButton();
messageAlertButton.setHorizontalAlignment(SwingConstants.RIGHT);
messageAlertButton.setContentAreaFilled(false);//不填充内容区域
final JPanel BannerPanel = new JPanel();
BannerPanel.setLayout(new BorderLayout());
this.add(BannerPanel,BorderLayout.NORTH);
userInfoButton = new JButton();
BannerPanel.add(userInfoButton