Bonjour amis developpeur,
tout d'abord voici mon code,
Je souhaiterai utiliser la variable str qui est en argument dans le action performed mais meme avc l'utilisation de this ou super je n'y arrive pas... Je pense que c'est tout bete mais je bloque si quelqun pouvait m'aider...
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 class Fenetre extends JFrame { private Image imagePanel; Fenetre(String str) { setTitle( "Affichage des courbes" ); setSize( 1280, 940 ); setLocationRelativeTo( null ); setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); this.setLayout( new BorderLayout() ); JPanel pan = new JPanel(); JButton suivant = new JButton( " Suivant " ); pan.add( suivant ); suivant.addActionListener( new ActionListener() { //Sytem.out.println(str); int cpts=1; StringBuffer ches = new StringBuffer("D:\\Documents and Settings\\karayat\\Desktop\\DERNIER TEST\\MARCHE\\IntGraph\\src\\intgraph\\MATLAB Compiler Runtime\\v710\\bin\\win32\\img01.jpg"); public void actionPerformed( ActionEvent event ) { this.cpts=cpts; this.ches=ches; if (cpts==9){ cpts=0; ches.replace(126,127,"1"); } else{ cpts++; } String bs=Integer.toString(cpts); ches.replace(127, 128, bs); String ches1 = new String(ches); imagePanel.setImage(ches1); imagePanel.repaint(); } } ); String fin = "\\MARCHE\\IntGraph\\src\\intgraph\\MATLAB Compiler Runtime\\v710\\bin\\win32\\img01.jpg"; String str1=str.substring(0,str.lastIndexOf("\\")); String hellolol=str1+fin; this.getContentPane().add( pan, BorderLayout.SOUTH ); imagePanel = new Image(hellolol); this.getContentPane().add( imagePanel, BorderLayout.CENTER ); setVisible( true ); } }
Merci d'avance bonne journée
Partager