java中的下拉列表

来源:百度知道 编辑:UC知道 时间:2024/05/18 09:41:52
请帮我看一下,下面这个程序,我想实现,在第一个列表中选择吉林时,在第二个列表中显示相应的市!!!选择辽宁时,也显示相应的市!!
下面是这个程序!
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Demo10 extends JFrame implements ActionListener {
String s [] = {"吉林","辽宁","黑龙江"};
String ss [][] ={{"吉林市","长春市","四平市"},{"沈阳市","大连市","锦州市"},{"佳木斯","哈尔滨","齐齐哈尔"}};
JComboBox jb1 = new JComboBox(s);
JComboBox jb2 = new JComboBox(ss);
JPanel panel = new JPanel();

public Demo10() {
panel.add(jb1);
panel.add(jb2);
this.getContentPane().add(panel);
this.setBounds(100,100,300,300);
this.setDefaultCloseOperation(3);
this.setVisible(true);

}

public static void main(String[] args) {

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Demo10 extends JFrame implements ActionListener {
String s[] = { "吉林", "辽宁", "黑龙江" };
String ss[][] = { { "吉林市", "长春市", "四平市" },
{ "沈阳市", "大连市", "锦州市" },
{ "佳木斯", "哈尔滨", "齐齐哈尔" } };
JComboBox jb1 = new JComboBox(s);
JComboBox jb2 = new JComboBox();
JPanel panel = new JPanel();

public Demo10() {
panel.add(jb1);
panel.add(jb2);
jb1.addActionListener(this);
this.getContentPane().add(panel);
this.setBounds(100, 100, 300, 300);
this.setDefaultCloseOperation(3);
this.setVisible(true);

}

public static void main(String[] args) {
new