Salut a tous ,
Voila , j'ai une erreur que je n'arrive pas à résoudre :
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78 import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; public class TableSourceFrame extends JDialog implements ActionListener { public TableSource modelSource; public JTable tabSource; public JButton btnGestion[] = new JButton[4]; public JPanel panelBtn; public MainFenetre main =new MainFenetre() ; public TableSourceFrame() { modelSource = new TableSource(); tabSource=new JTable(modelSource); setLayout(new BorderLayout()); add(new JScrollPane(tabSource, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER); panelBtn = new JPanel(); panelBtn.setLayout(new FlowLayout()); String lblBtn[] ={"<","Ok","Supprimer",">"}; for(int i = 0 ; i<lblBtn.length ; i++) { btnGestion[i]=new JButton(lblBtn[i]); panelBtn.add(btnGestion[i]); btnGestion[i].addActionListener(this); } add("South",panelBtn); pack(); } @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub Object src = arg0.getSource(); if(src == btnGestion[0]) { } if(src == btnGestion[1]) { this.setVisible(false); } if(src == btnGestion[2]) { int[] selectionSource = tabSource.getSelectedRows(); for(int i =selectionSource.length -1 ; i>=0 ;i--) { System.out.println(i); modelSource.removeSource(selectionSource[i]); main.imagePanel.lblMap.remove(selectionSource[i]); } } } }
Erreur :
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 Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0 at java.awt.Container.remove(Container.java:1132) at TableSourceFrame.actionPerformed(TableSourceFrame.java:70) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.Component.processMouseEvent(Component.java:6268) at javax.swing.JComponent.processMouseEvent(JComponent.java:3267) at java.awt.Component.processEvent(Component.java:6033) at java.awt.Container.processEvent(Container.java:2045) at java.awt.Component.dispatchEventImpl(Component.java:4629) at java.awt.Container.dispatchEventImpl(Container.java:2103) at java.awt.Component.dispatchEvent(Component.java:4455) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227) at java.awt.Container.dispatchEventImpl(Container.java:2089) at java.awt.Window.dispatchEventImpl(Window.java:2517) at java.awt.Component.dispatchEvent(Component.java:4455) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:649) at java.awt.EventQueue.access$000(EventQueue.java:96) at java.awt.EventQueue$1.run(EventQueue.java:608) at java.awt.EventQueue$1.run(EventQueue.java:606) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116) at java.awt.EventQueue$2.run(EventQueue.java:622) at java.awt.EventQueue$2.run(EventQueue.java:620) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105) at java.awt.EventQueue.dispatchEvent(EventQueue.java:619) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177) at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
Il pointe sur la ligne :Sachant que j'ai crée un objet et je l'ai ajouté a la lblMap ( dans une autre class) .
Code : Sélectionner tout - Visualiser dans une fenêtre à part main.imagePanel.lblMap.remove(selectionSource[i]);
Merci .
Partager