Bonjour,
Voila je cherche à creer un menu contextuel comme ceci
et sur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 PopupMenu popup = new PopupMenu(); Menu submenu = new Menu("Sauvgarde"); MenuItem démarrer = new MenuItem("Afficher"); MenuItem quitter = new MenuItem("Quitter"); MenuItem config = new MenuItem("Configuration"); chk = new CheckboxMenuItem("Sauvegarder"); ActionListener afficher = new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(true); setExtendedState(Frame.NORMAL); } }; ActionListener arrêter = new ActionListener() { public void actionPerformed(ActionEvent e) { try { tray.displayMessage("Arrêt de l'application TIM+Auto", "A bientôt", TrayIcon.MessageType.INFO); Thread.sleep(4000); } catch (InterruptedException ex) { } finally { System.exit(0); } } }; ActionListener configur = new ActionListener() { public void actionPerformed(ActionEvent e) { try { config ma_config = new config(null, rootPaneCheckingEnabled); ma_config.show(); } catch (Exception ex) { } } }; ItemListener Ouisave = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; démarrer.addActionListener(afficher); quitter.addActionListener(arrêter); config.addActionListener(configur); chk.addItemListener(Ouisave); popup.add(démarrer); popup.add(config); popup.add(chk); popup.add(quitter); // création de l'icône Image icone = Toolkit.getDefaultToolkit().getImage(getClass().getResource("nuclearsubmarine.png"));// Si l'image est dans le jar //$NON-NLS-1$ tray = new TrayIcon(icone,"TIM+Auto", popup); //System.out.println("Affichage de l'icone"); tray.setImageAutoSize(true); tray.addActionListener(afficher); // placement de l'icône dans la barre de tâche try { SystemTray.getSystemTray().add(tray); } catch (AWTException ex) { } }
quand je clique sur mon checkboxmenuitem j'ai
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 ItemListener Ouisave = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { throw new UnsupportedOperationException("Not supported yet."); } };
alors que je n'ai encore rien mis dedansException in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
at jtimauto.vue$7.itemStateChanged(vue.java:689)
at java.awt.CheckboxMenuItem.processItemEvent(CheckboxMenuItem.java:389)
at java.awt.CheckboxMenuItem.processEvent(CheckboxMenuItem.java:357)
at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:351)
at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:339)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:732)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.awt.EventQueue$3.run(EventQueue.java:686)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:702)
at java.awt.EventQueue$4.run(EventQueue.java:700)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Partager