1 Package com.soft.test;2 3 /**4 * drop-down list, drop-down box, scroll bar usage5 */6 7Import javax.swing.*;8Import java.awt.*;9 Public classDem5 extends JFrame {Ten One A PrivateJPanel jp1, JP2; - PrivateJLabel jlb1, jlb2; - PrivateJComboBox jb1; the PrivateJList JL; - PrivateJScrollPane jsp; - - PublicDem5 () { +JP1 =NewJPanel (); -JP2 =NewJPanel (); +JLB1 =NewJLabel ("Hometown"); AJLB2 =NewJLabel ("Tourist Locations"); at - -String []JZ = {"Nanchang","Ganzhou","Jian","Xinyu","Yingtan","Jingdezhen","Fuzhou"}; -JB1 =NewJComboBox (JZ); -String []ly = {"Sanqingshan","General Park","Lung Fu Shan","Lushan","Teng Wang ge"}; - inJL =NewJList (ly); -JSP =NewJScrollPane (JL); toJl.setvisiblerowcount (3); + - This. setlayout (NewGridLayout (3,1)); the * Jp1.add (JLB1); $ Jp1.add (JB1);Panax Notoginseng Jp2.add (JLB2); - Jp2.add (JSP); the This. Add (JP1); + This. Add (JP2); A This. SetSize ( -, -); the This. Setdefaultcloseoperation (jframe.exit_on_close); + This. setlocation ( -, -); - This. setvisible (true); $ This. setresizable (false); $ } - - Public Static voidMain (String args[]) { the -DEM5 DEM5 =NewDEM5 ();Wuyi } the}
Java drop-down box, scroll bar