Bonjour,
voila j'ai cree un fileviewer dans lequel j'ai implemente un bouton " Search" me permettant de rechercher des mots dans le fichier en cours.

Lorsque le bouton est active , une nouvelle frame, creee dans une nouvelle classe apparait et effectue la recherche demande.

Le probleme que j'ai c'est que dans mon fileviewer j'aimerais deplacer ma scrollBar a la bonne position, mais pour cela il faut que j'attende que la frame "Search" le fasse...
Ma fenetre n'etant pas modal, comment puis je le faire?

Voici l'implementation de mon bouton :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
        // TODO add your handling code here:\
        searchFunction search = new searchFunction();
        search.setLocationRelativeTo(this);
        search.setText(fileContent);
        position = search.getPosition():
    }
et une partie de ma classe search:
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
public void actionPerformed(ActionEvent e) {
        try {
             pattern = textField.getText().toLowerCase();
            if (wholeWordCheckBox.getState() == true && partWordCheckBox.getState() == true) {
            } else {
                if (wholeWordCheckBox.getState() == true) {
 
                    if (!pattern.equals("")) {
                        if (fileContent.toLowerCase().contains("\n"+pattern+" ") || fileContent.toLowerCase().contains(" "+pattern+" ")) {
                                textField.setForeground(Color.green);
                                position = fileContent.indexOf(pattern);
                            System.out.println(fileContent.indexOf(pattern));
 
                        } else {
                            textField.setForeground(Color.red);
                            System.out.println(" It is not present");
                        }
                    }
                }
                else if (partWordCheckBox.getState() == true) {   
                    if (!pattern.equals("")) {
                        if (fileContent.toLowerCase().contains(pattern)) {
                            textField.setForeground(Color.green);
                            position = fileContent.indexOf(pattern);
                            System.out.println(fileContent.indexOf(pattern));
                        } else {
                            textField.setForeground(Color.red);
                            System.out.println(" It is not present");
                        }
                    }
                }
            }
        } catch (NumberFormatException nfe) {
            nfe.printStackTrace();
        }
    }
 
    public String getText() {
        return textField.getText();
    }
 
    public String getPattern(){
        return pattern;
    }
 
    public int getPosition(){
        return position;
    }
 
    public void setText(String text) {
        fileContent = text;
    }
C'est donc la variable position qui doit etre renvoye.

Merci d 'avance.