Combobox
salut a tous,
je veux afficher contenu de console dans un combobox pour cela j'ai fait ça
je veux afficher contenu de console dans un combobox pour cela j'ai fait ça
public static void main(String[] args) throws NamingException {
Hashtable<String, String> contextParams = new Hashtable<String, String>();
contextParams.put("java.naming.provider.url", "ldap://localhost:11389");
contextParams.put("java.naming.security.principal", "uid=admin,ou=system");
contextParams.put("java.naming.security.credentials", "secret");
contextParams.put("java.naming.security.authentication", "simple");
contextParams.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
DirContext dirContext = new InitialDirContext(contextParams);
Attributes attributes = dirContext.getAttributes( "", new String[]{"namingContexts"} );
Attribute attribute = attributes.get( "namingContexts" );
NamingEnumeration<?> all = attribute.getAll();
while(all.hasMore())
{
String lines = (String)all.next();
JFrame frame = new JFrame();
JPanel top = new JPanel();
combo1 = new JComboBox();
frame.add(top);
top.add(combo1);
combo1.addItem(lines);
frame.setVisible(true);
}
}
}
mais je sais pas pourquoi il s'affiche chaque ligne dans une fenetre(5 fenetre)