Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public void mostrarNotificacion(Usuario user) throws AWTException, java.net.MalformedURLException, IOException {
  2. //Obtain only one instance of the SystemTray object
  3. SystemTray tray = SystemTray.getSystemTray();
  4.  
  5. //Get image
  6. BufferedImage trayIconImage = ImageIO.read(getClass().getResource("favicon.png"));
  7. int trayIconWidth = new TrayIcon(trayIconImage).getSize().width;
  8. TrayIcon trayIcon = new TrayIcon(trayIconImage.getScaledInstance(trayIconWidth, -1, Image.SCALE_SMOOTH));
  9.  
  10. //Let the system resizes the image if needed
  11. trayIcon.setImageAutoSize(true);
  12.  
  13. //Set tooltip text for the tray icon
  14. if(user.getDescargos()>=5 || user.getOtrosPendientes()>=1){
  15. mensaje = "Descargos pendientes: " + user.getDescargos() + "nSecciones pendientes: "+ user.getOtrosPendientes();
  16. }
  17. trayIcon.setToolTip(mensaje);
  18. tray.add(trayIcon);
  19. trayIcon.displayMessage("Pendientes EKHI", mensaje, MessageType.WARNING);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement