————————————-这是查询按钮的————————————btn_xs_cx.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){Strings[]={"以学号为...
————————————-这是查询按钮的————————————
btn_xs_cx.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String s[]={"以学号为关键字查询某学生基本信息","以学号为关键字查询某学生卫生成绩"};
list.setListData(s);
list.addListSelectionListener(
new ListSelectionListener() {
public void valueChanged( ListSelectionEvent event )
{ if(list.getValueIsAdjusting() )
{stop:
switch(list.getSelectedIndex()){
case 0 : {JDialog xs_cxxsjbxx =new xs_cxxsjbxx();
xs_cxxsjbxx.setVisible(true);
break stop;}
case 1 : {JDialog xs_cxxswscj =new xs_cxxswscj();
xs_cxxswscj.setVisible(true);
break stop;}
————————————这是登记按钮的————————————
btn_xs_dj.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String s[]={"对新生进本信息进行登记"};
list.setListData(s);
list.addListSelectionListener(
new ListSelectionListener() {
public void valueChanged( ListSelectionEvent event )
{
if(list.getValueIsAdjusting() )
{stop1:
switch(list.getSelectedIndex()){
case 0 : {JDialog xs_xsdj =new xs_xsdj();
xs_xsdj.setVisible(true);
break stop1;}
——————————————
问题是,如果我点完查询按钮,然后在JList中选“以学号为关键字查询某学生基本信息”,没问题
然后我再点新生登记按钮,然后在JList中选“对新生进本信息进行登记”,不仅混弹出JDialog xs_xsdj,还会弹出JDialog xs_cxxsjbxx。怎么解决呢?
有没有什么办法能初始化JList的索引的还是有其他的办法?
按照你说的,改的switch
代码在这里。结果还是一样啊- -。。
switch(s[list.getSelectedIndex()]){
case "以学号为关键字查询某学生基本信息":
JDialog xs_cxxsjbxx =new xs_cxxsjbxx();
xs_cxxsjbxx.setVisible(true);
展开