Problème JComboBox avec autocomplétion et différents Layout
Bonjour à tous,
Comme exercice, j'ai réalisé une JComboBox réalisant de l'autocomplétion. L'objectif était de pouvoir utilisé un dictionnaire complet (genre 300 000 mots), donc d'implémentant un arbre de complétion. J'ai donc réalisé une classe ComboBoxWithAutomaticCompletion héritant de JComboBox dont l'un des attribut est l'arbre de complétion (objet de la classe Dictionnary)
Tout semble parfait, mais...
Lorsque je fait le test suivant, tout va bien :
Code:
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
|
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import Exceptions.NoDictionnaryAvailableException;
import Functionning.Dictionnary;
import Windows.ComboBoxWithCompletion.ComboBoxWithAutomaticCompletion;
public class Essai extends JFrame {
private static final long serialVersionUID = 1L;
private final static String repertoryPath = "...";
private final static String dicoRelativPath = "Dico/";
String name = "liste.de.mots.francais.frgut.txt";
String completeDicoPath = repertoryPath + dicoRelativPath + name;
public Essai() {
Dictionnary dico = null;
try {
dico = new Dictionnary(completeDicoPath, "ISO-8859-1");
} catch (NoDictionnaryAvailableException e) {
System.out.println("Dictionnaire introuvable, vérifiez votre chemin d'accès !");
}
JComboBox<String> jCombo = new ComboBoxWithAutomaticCompletion(dico);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(jCombo);
this.setSize(200, 100);
this.setVisible(true);
}
public static void main(String args[]) {
new Essai();
}
} |
Si je modifie la ligne
Code:
getContentPane().add(jCombo);
en
Code:
getContentPane().add(jCombo, BorderLayout.SOUTH);
, la JFrame ne s'affiche plus... Le programme ne ressort pas de la ligne
Code:
this.setVisible(true);
Avez vous déjà rencontré un cas similaire ???
Si je modifie la ligne
Code:
getContentPane().setLayout(new BorderLayout());
en
Code:
getContentPane().setLayout(new FlowLayout());
, c'est la même chose. Par contre, si j'utilise un GridLayout, ca marche nickel : je peux avoir un tableau complet de ma nouvelle JComboBox !!!
Je n'ai aucune idée d'où cela peut bien venir... Mon implémentation de l'autocomplétion ? des Layout ? Je pencherais bien pour la première solution, car lorsque je fais charger un petit dictionnaire (genre 10 mots), je peux bien mettre ma JComboBox au sud d'un BorderLayout, ou utiliser un FlowLayout...
SI quelqu'un à une idée... je suis preneur !
Merci d'avance,