The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

RE:JComboBox

Posted by Kishori Sharan on August 10, 2000 at 11:46 PM

Hi
I think somehow all but the first element of the vector is null and that is why it is displaying only one element. I have used the following program to add 100,000 string objects in vector which in turn is used to initialize the JComboBox and it works fine. But when I made all element in vector but the first one null it displays only one. Please check your code when you add elements in the vector and make sure they are not null.
Thanx
Kishori
/////////////////////////
import java.awt.* ;
import javax.swing.* ;
import java.util.* ;


class JCombo1 {
public static void main ( String[] args ) {
JFrame f = new JFrame ( ) ;
Container cp = f.getContentPane ( );
JPanel panel = new JPanel ( );
Vector v = new Vector ( );
for ( int i = 0; i < 100000 ; i++ )
v.add ( "Hello :" + i ) ;



JComboBox combo = new JComboBox ( v ) ;
panel.add ( combo );
f.setTitle ( "Hello" ) ;
f.setBounds ( 200, 300, 300, 300 ) ;
cp.add ( panel ) ;
f.show () ;

}

}



Replies:
  • JComboBox shakila August 22, 2000 at 4:48 PM (1)
    • JComboBox shakila August 23, 2000 at 12:37 PM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us