java 私有静态类_java中,在私有的静态类中如何触发jbutton

privatestaticclassTeammember{publicTeammember()throwsUnsupportedEncodingException,FileNotFoundException,IOException{Stringencoding="GBK";JFrameframe=newJFrame("队员");fra...

private static class Teammember {

public Teammember() throws UnsupportedEncodingException, FileNotFoundException, IOException {

String encoding = "GBK";

JFrame frame=new JFrame("队员");

frame.setSize(300, 200);

JPanel panel=new JPanel();

JLabel label=new JLabel("输入查询的球队: 例如:巴西队员");

String[] str={"巴西队员","法国队员","美国队员"};

JComboBox comboBox=new JComboBox(str);

frame.add(panel);

JButton button=new JButton("确定");

button.addActionListener(comboBox);

panel.add(label,BorderLayout.CENTER);

panel.add(comboBox,BorderLayout.LINE_END);

frame.setVisible(true);

这块如何触发button:if(e.getsourse()==button)

String mem=comboBox.getSelectedItem().toString();

File file = new File("E:\\数据结构\\队员\\"+mem+".txt");

InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding);

BufferedReader bufferedReader = new BufferedReader(read);

String lineTXT = null;

String sumLine = "";

while ((lineTXT = bufferedReader.readLine()) != null) {

sumLine = sumLine+lineTXT.toString().trim()+"\n";

}

read.close();

JFrame frame1=new JFrame("射手榜");

frame1.setSize(600, 500);

JTextArea textArea=new JTextArea();

JScrollPane jScrollPane = new JScrollPane(textArea,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

frame1.add(jScrollPane);

textArea.setText(sumLine);

frame1.setVisible(true);

// textArea.setText(sumLine);

}

}

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值