//给树的子节点 添加了单机监听事件后,//怎么使其选择单机的节点页面置顶,以及单机的页面不论点击多少次,始终只实例化一次tree.addMouseListener(new MouseAdapter() { public void mouseClicked(final MouseEvent arg0) { TreePath tp = tree.getSelectionPath(); if( tp == null){ JOptionPane.showMessageDialog(null, "请点击选择按钮"); return; } System.out.println(tp); String str = tp.toString(); String[] arr = str.split(","); str = arr[arr.length-1].trim(); str = str.substring(0, str.length()-1); if(str.equals("开户")){ BankAddFrame addl = new BankAddFrame(); desktopPane.add(addl); }else if(str.equals("挂失")){ BankLossFrame loss = new BankLossFrame(); desktopPane.add(loss); }else if(str.equals("注销")){ BankCloseFrame close = new BankCloseFrame(); desktopPane.add(close); }else if(str.equals("个人业务")){ BankPerFrame per = new BankPerFrame(); desktopPane.add(per); }else if(str.equals("贷款")){ BankLoanFrame loan = new BankLoanFrame(); desktopPane.add(loan); } } });
添加回答
举报
0/150
提交
取消