Advertisement
Guest User

GameOver.java

a guest
Oct 22nd, 2018
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. package com.mathfacts.views;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Color;
  5. import java.awt.EventQueue;
  6.  
  7. import javax.swing.JFrame;
  8. import javax.swing.JPanel;
  9. import javax.swing.border.EmptyBorder;
  10. import javax.swing.JLabel;
  11. import javax.swing.SwingConstants;
  12. import javax.swing.UIManager;
  13.  
  14. import java.awt.Font;
  15. import javax.swing.JButton;
  16. import java.awt.event.ActionListener;
  17. import java.awt.event.ActionEvent;
  18.  
  19. public class GameOver extends JFrame {
  20.  
  21. private JPanel cPane;
  22. private JLabel lblGameOver;
  23. private JButton btnRetry;
  24. private static GameOver frame;
  25.  
  26. /**
  27. * Launch the application.
  28. */
  29. public static void main(String[] args) {
  30. try {
  31. UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
  32. } catch (Throwable e) {
  33. e.printStackTrace();
  34. }
  35. EventQueue.invokeLater(new Runnable() {
  36. public void run() {
  37. try {
  38. frame = new GameOver();
  39. frame.setVisible(true);
  40. } catch (Exception e) {
  41. e.printStackTrace();
  42. }
  43. }
  44. });
  45. }
  46.  
  47. /**
  48. * Create the frame.
  49. */
  50. public GameOver() {
  51. initComponents();
  52. createEvents();
  53. }
  54.  
  55. private void initComponents() {
  56. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  57. setBounds(100, 100, 585, 700);
  58. cPane = new JPanel();
  59. cPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  60. cPane.setLayout(new BorderLayout(0, 0));
  61. setContentPane(cPane);
  62. cPane.setBackground(Color.BLACK);
  63.  
  64. lblGameOver = new JLabel("GAME OVER");
  65. lblGameOver.setFont(new Font("Tahoma", Font.PLAIN, 99));
  66. lblGameOver.setHorizontalAlignment(SwingConstants.CENTER);
  67. lblGameOver.setForeground(Color.WHITE);
  68. cPane.add(lblGameOver, BorderLayout.CENTER);
  69.  
  70. btnRetry = new JButton("RETRY");
  71. btnRetry.setFont(new Font("Tahoma", Font.PLAIN, 99));
  72. cPane.add(btnRetry, BorderLayout.SOUTH);
  73. }
  74.  
  75. private void createEvents() {
  76. btnRetry.addActionListener(new ActionListener() {
  77. public void actionPerformed(ActionEvent arg0) {
  78. new Game().setVisible(true);
  79. dispose();
  80. }
  81. });
  82. }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement