frame.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { if(menu_bar_visible==false){ frame.setSize(oldwidth,oldheigh);//pour revenir en petite fenetre } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mousePressed(MouseEvent e) { } });
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionclass Our_media_player extends JFrame implements ControllerListener { private Player player = null; private JPanel videoPanel = null; private Component controlComponent = null; private JMenuBar menu_bar = null; // menu bar used for the different Buttons private JFrame frame = null; // frame used to open a file private JFileChooser fc = null; // used for the dialog window to open a file private File file; /* Various Buttons */ private JButton about = null; private boolean menu_bar_visible=true; int oldwidth=0; int oldheigh=0; ..... public void controllerUpdate( ControllerEvent ce ) { // to start the video and create all the buttons etc... if ( ce instanceof RealizeCompleteEvent ) { if (menu_bar == null) { //creation of the menu bar menu_bar = new JMenuBar(); //creation of the button with the icon stop.setMargin(new Insets(0, 0, 0, 0)); about = new JButton(new ImageIcon("about.gif")); about.setMargin(new Insets(0, 0, 0, 0)); //creation of the frame used to open a file frame = new JFrame(); frame.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { System.out.println("heho2"); if(menu_bar_visible==false){ menu_bar_visible=true; menu_bar.show(menu_bar_visible); frame.setSize(oldwidth,oldheigh); } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mousePressed(MouseEvent e) { } }); fc = new JFileChooser(); //the button is add to the menu bar menu_bar.add(about); System.out.println("validate"); //actions which are made while pressing the about button about.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("About"); //Brings up a dialog that displays a message using a default icon determined by the messageType parameter int width = (int)Toolkit.getDefaultToolkit().getScreenSize().width; int heigh = (int)Toolkit.getDefaultToolkit().getScreenSize().height; //Donne la position (x, y) de la JWindow ainsi que sa largeur et sa longueur setBounds(0,0,width, heigh); menu_bar_visible=false; menu_bar.show(menu_bar_visible); //affiche la fenêtre setVisible(true); //JOptionPane.showMessageDialog(null,"", "About Our media player",JOptionPane.INFORMATION_MESSAGE); System.out.println("heho1"); } }); } if ( videoPanel == null) { //creation of the panel of sight videoPanel = new JPanel(); videoPanel.setLayout( new BorderLayout() ); getContentPane().add( videoPanel, BorderLayout.CENTER); } else videoPanel.removeAll(); // Recuperer le composant ControlPanel de la video a l'aide de player if ( (controlComponent = player.getControlPanelComponent()) != null) { videoPanel.add(controlComponent, BorderLayout.SOUTH); videoPanel.setVisible(true); menu_bar.add(controlComponent); setJMenuBar(menu_bar); } //obtaining the component restoring the image in provenence of the player. Component vis = player.getVisualComponent(); if ( vis != null ) { // if it is valid then we put it in our sight videoPanel.add( vis, BorderLayout.CENTER); videoPanel.setVisible(true); this.pack(); // resize the size according to the size of film oldwidth=videoPanel.getWidth(); oldheigh=videoPanel.getHeight(); } }