Bonjour!
Nous voulons, développer un programme baser sur l'interprétation de signal midi........
Enfin bref nous en sommes au début et nous rencontrer quelques problèmes, notament dans l'interface graphique: nous voudrions faire apparaître une scrollbar verticale et une horizontale. Cependant toute nos tentatives ont échoué(nous n'arrivons pas a avoir les ascenseurs) . Pouvez vous nous aider?


voici le code


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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
 
import java.awt.*;
import java.awt.event.*;
 
 
import javax.swing.*;
import javax.swing.JScrollPane;
import java.awt.Graphics2D;
import java.awt.Color;
import java.util.Vector;
 
public class Piste1 extends JFrame  {
 
    Vector touchesnoires = new Vector();
    Vector touchesblanches = new Vector();
    Vector touches = new Vector();
    Vector grille = new Vector();
    Vector data = new Vector();
    final int tl = 30, th = 10, tl1 = 60;
    JScrollPane scrollpane;
    JPanel pan;
    int xpos;
    int ypos;
    boolean mouseEntered;
    boolean rect1Clicked;
 
    public Piste1() {
        super("JScrollPane Demonstration");
        setSize(1000, 200);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        init();
        setVisible(true);
    }
 
    public void init() {
 
        Paneau p = new Paneau();
        p.setSize(2000, 300);
 
 
 
 
        int y = 0;
 
        for (int i = 0; i < 8; i++) {
 
            touchesblanches.add(new Touche(0, y, tl, th, 0));
            touchesblanches.add(new Touche(0, y += th, tl, th, 0));
            touchesblanches.add(new Touche(0, y += 2 * th, tl, th, 0));
            touchesblanches.add(new Touche(0, y += 2 * th, tl, th, 0));
            touchesblanches.add(new Touche(0, y += 2 * th, tl, th, 0));
            touchesblanches.add(new Touche(0, y += th, tl, th, 0));
            touchesblanches.add(new Touche(0, y += 2 * th, tl, th, 0));
            touchesblanches.add(new Touche(0, y += 2 * th, tl, th, 0));
        }
        touchesblanches.add(new Touche(0, y += th, tl, th, 0));
 
        for (int i = 1; i < 65; i++) {
            for (int j = 0; j < 88; j++) {
 
 
                grille.add(new Touche(i * tl1, j * th, tl1, th, i + j * 88));
 
 
            }
        }
 
        //p = new Paneau() ;
        //getContentPane().add(p) ;
 
        JScrollPane scrol1 = new JScrollPane(p);
        scrol1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        //JScrollBar barredef = new JScrollBar();
        //affichage.add(barredef);
 
        getContentPane().add(scrol1);
 
        JScrollPane scrol2 = new JScrollPane(p);
        scrol2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
 
        getContentPane().add(scrol2);
 
 
//        addMouseListener(this);
 
    }
 
    public class Paneau extends JPanel {
 
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g21 = (Graphics2D) g;
 
            Dimension d = getSize();
 
 
 
            g21.setBackground(getBackground());
            g21.clearRect(0, 0, d.width, d.height);
 
            g21.setColor(Color.BLACK);
            g21.fillRect(0, 0, tl, 88 * th);
 
 
 
 
 
            for (int i = 0; i < touchesblanches.size(); i++) {
                Touche touche = (Touche) touchesblanches.get(i);
 
                g21.setColor(Color.WHITE);
                g21.fill(touche);
                g21.setColor(Color.BLACK);
 
                g21.draw(touche);
 
 
            }
            for (int i = 0; i < grille.size(); i++) {
                Touche touche = (Touche) grille.get(i);
 
                if (i % 2 == 0) {
                    g21.setColor(Color.WHITE);
                } else {
                    g21.setColor(new Color(204, 204, 225));
                }
                g21.fill(touche);
                g21.setColor(Color.BLACK);
 
                g21.draw(touche);
 
 
 
            }
 
 
 
 
        }
 
        public void mouseClicked(MouseEvent me) {
 
            // Save the coordinates of the click lke this.
            xpos = me.getX();
            ypos = me.getY();
            int px, py;
 
            // Check if the click was inside the rectangle area.
            for (int i = 0; i < 88; i++) {
                if (xpos > i * th && xpos < (i + 1) * th) {
 
                    if (xpos > i * th && xpos < (i + 1) * th) {
                        px = i * th;
                        for (int j = 0; j < 65; j++) {
                            if (ypos > j * tl1 && ypos < (j + 1) * tl1) {
                                py = j * tl1;
                                for (int k = 0; k < 64 * 88; k++) {
                                }
                            }
                        }
                    }
                }
            }
        }
 
        public void mousePressed(MouseEvent me) {
        }
 
        public void mouseReleased(MouseEvent me) {
        }
 
        public void mouseEntered(MouseEvent me) {
            // Will draw the "inside applet message"
            mouseEntered = true;
            repaint();
        }
 
 
    }
 
    public static void main(String args[]) {
        new Piste1();
 
    }
}
et voila la classe touche



Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
import java.awt.*;
//CLASSE TOUCHE
public class Touche extends Rectangle{
       int Tnum ;
       boolean etatnote = false;
 
    public Touche(int x, int y, int largeur, int hauteur,int num){
    super(x, y, largeur, hauteur);
    this.Tnum=num;
    this.etatnote=false;
        }  
    }



merci (ne pas faire attention au mouselistener)