public void actionPerformed(ActionEvent e) {
   if (isVisible()) {
     repaint();
   } else {
     animator.stop();
   }
 }
示例#2
0
 // 当鼠标单击事件发生时
 public void actionPerformed(ActionEvent evt) {
   try {
     // 初始化聊天通信类
     comUtil = new ComUtil(chatFrame);
     final String loginMsg =
         YeekuProtocol.PRESENCE
             + userField.getText()
             + YeekuProtocol.SPLITTER
             + iconList.getSelectedObjects()[0]
             + YeekuProtocol.PRESENCE;
     comUtil.broadCast(loginMsg);
     // 启动定时器每20秒广播一次在线信息
     javax.swing.Timer timer =
         new javax.swing.Timer(1000 * 10, event -> comUtil.broadCast(loginMsg));
     timer.start();
     loginFrame.setVisible(false);
     chatFrame.setVisible(true);
   } catch (Exception ex) {
     loginFrame.setTipMsg("确认30001端口空闲,且网络正常!");
   }
 }
 public void go() {
   animator = new javax.swing.Timer(22 + 22 + 22, this);
   animator.start();
 }