gt22

Untitled

Aug 3rd, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. public JavaErrorFrame()
  2.     {
  3.         setLayout(new GridBagLayout());
  4.         gc = new GridBagConstraints();
  5.         add(new JLabel("<html><p>Java 8 is required to run the launcher</p><p style='margin-left: 78px;'></html>"), 0, 0);
  6.         JLabel download = new JLabel("<html><a href='https://java.com'>Dowload</a></html>");
  7.         JButton ok = new JButton("OK");
  8.         //Cannot use lambda becouse if we here, no java 8 detected
  9.         ok.addActionListener(new ActionListener()
  10.         {
  11.             @Override
  12.             public void actionPerformed(ActionEvent e)
  13.             {
  14.                 Core.log.fatal("Detected java older than 1.8, launcher is unable to run", true, Const.EXITCODE_INVALID_JAVA);
  15.             }
  16.         });
  17.         download.addMouseListener(new MouseListener()
  18.         {
  19.  
  20.             @Override
  21.             public void mouseReleased(MouseEvent e)
  22.             {
  23.             }
  24.  
  25.             @Override
  26.             public void mousePressed(MouseEvent e)
  27.             {
  28.                 if (Desktop.isDesktopSupported())
  29.                 {
  30.                     try
  31.                     {
  32.                         Desktop.getDesktop().browse(new URI("http://www.java.com"));
  33.                     }
  34.                     catch (Exception ex)
  35.                     {
  36.                         Core.log.error("Unable to open java.com");
  37.                         ex.printStackTrace(Core.log);
  38.                     }
  39.                 }
  40.             }
  41.  
  42.             @Override
  43.             public void mouseExited(MouseEvent e)
  44.             {
  45.             }
  46.  
  47.             @Override
  48.             public void mouseEntered(MouseEvent e)
  49.             {
  50.                
  51.             }
  52.  
  53.             @Override
  54.             public void mouseClicked(MouseEvent e)
  55.             {
  56.             }
  57.         });
  58.         download.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  59.         add(download, 0, 1);
  60.         add(ok, 0, 2);
  61.         setResizable(false);
  62.         setSize(Const.jerrorwidth, Const.jerrorheight);
  63.         setVisible(true);
  64.     }
Advertisement
Add Comment
Please, Sign In to add comment