Page 166 - MDP2022-3
P. 166

setUndecorated(true);
                            this.setTitle("MDP  GAME");
                            this.setSize(Main.SCREEN_WIDTH,  Main.SCREEN_HEIGHT);
                            this.setResizable(false);
                            this.setLocationRelativeTo(null);
                            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                            this.setVisible(true);
                            setBackground(new  Color(0,  0,  0,  0));
                            this.setLayout(null);


                            addKeyListener(new  KeyListener());


                            introMusic.start();


                            exitButton.setBounds(1245,  0,  30,  30);
                            exitButton.setBorderPainted(false);
                            exitButton.setContentAreaFilled(false);
                            exitButton.setFocusPainted(false);
                            exitButton.addMouseListener(new  MouseAdapter()  {
                                    @Override
                                    public  void  mouseEntered(MouseEvent  e)  {
                                            exitButton.setIcon(exitButtonEnteredImage);
                                            exitButton.setCursor(new  Cursor(Cursor.HAND_CURSOR));
                                            Music            buttonEnteredMusic             =            new
            Music("buttonPressedMusic.mp3"  ,  false);
                                            buttonEnteredMusic.start();
                                    }
                                    @Override
                                    public  void  mouseExited(MouseEvent  e)  {
                                            exitButton.setIcon(exitButtonBasicImage);
                                    }
                                    @Override
                                    public  void  mousePressed(MouseEvent  e)  {
                                            Music            buttonEnteredMusic             =            new
            Music("buttonPressedMusic.mp3"  ,  false);
                                            buttonEnteredMusic.start();
                                            try  {
                                                    Thread.sleep(1000);
                                            }catch(InterruptedException  ex)  {
                                                    ex.printStackTrace();
                                            }
                                            System.exit(0);
                                    }
                            });
   161   162   163   164   165   166   167   168   169   170   171