try { List list01 = new ArrayList(); String str = null; BufferedReader br01 = new BufferedReader(new FileReader ("src/information")); while((str=br01.readLine()) !=null){ list01.add(str); } br01.close(); String x = "学号:"+jtf02.getText(); jbt02.addActionListener(l->{ int location = list01.indexOf(""学号:"+jtf02.getText()"); String z =list01.get(location+2); jta02.setText(z); }); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace();
把变量值通过setText(变量名称)设置进去就可以显示了。
JTextArea#setText(String t)