package com.test; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTextArea; public class ChatHistory extends JFrame{ /** * */ private static final long serialVersionUID = 4322029311676518125L; private JSplitPane jsp; @SuppressWarnings({ "rawtypes", "unused" }) private JList jl; private JScrollPane leftJP; private JScrollPane rightJP; @SuppressWarnings("rawtypes") private JList friends; private JTextArea JTrecord; private String txtName; private Parameterx parameterx; private File file; @SuppressWarnings("unused") private ArrayList<String> fileName; public ChatHistory(){ this.setTitle("�����¼��ѯ"); init(); setBounds(100,100,600,300); setVisible(true); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } @SuppressWarnings({ "static-access", "rawtypes", "unchecked" }) public void init(){ parameterx = new Parameterx(); file = new File(parameterx.path); File[] fa = file.listFiles(); String []data = new String[fa.length]; int strleng = 0; for (File file : fa) { if(strleng < fa.length){ data[strleng] = new String(file.getName()); strleng++; } } jsp = new JSplitPane();//������ jsp.setOrientation(JSplitPane.HORIZONTAL_SPLIT); leftJP = new JScrollPane();//�б�Ĺ����� rightJP = new JScrollPane(); JTrecord = new JTextArea(); jsp.setLeftComponent(leftJP); jsp.setRightComponent(rightJP); friends = new JList(data); leftJP.getViewport().add(friends); friends.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if(e.getClickCount() == 2){ JTrecord.setText(""); String name = friends.getSelectedValue().toString(); txtName = parameterx.path + "\\" + name; //txtName += ".txt"; fileReader(); } } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } }); rightJP.getViewport().add(JTrecord); add(jsp); } public void fileReader(){ try{ FileReader fr = new FileReader(txtName); BufferedReader br = new BufferedReader(fr); String s; while((s = br.readLine())!=null){ JTrecord.append(s + "\n"); } br.close(); }catch(FileNotFoundException e){ JOptionPane.showMessageDialog(this, "�Ҳ��������¼"); return ; }catch(IOException e){ JOptionPane.showMessageDialog(this, "���ļ�����"); return ; } } }

taoshen95 LV16
2024年1月19日
漫步的海星 LV4
2023年8月21日
2017143155 LV12
2023年6月24日
wanglinddad LV55
2022年6月18日
微信网友_6003487859068928 LV5
2022年6月16日
zhendong LV7
2022年3月6日
dfz12345 LV4
2021年12月8日
胡萝北呀 LV3
2021年11月28日
ComeDebug LV6
2021年9月6日
忧麦紫 LV18
2021年6月26日

13133117021 LV5
2024年12月26日
srl2881552 LV10
2024年11月25日
微信网友_7004855557083136 LV1
2024年5月22日
taoshen95 LV16
2024年1月19日
陈小灏 LV18
2023年12月27日
求学的熊猫 LV11
2023年12月25日
wuxin427
2023年12月20日
暂无贡献等级
fuyouou LV5
2023年6月29日
2017143155 LV12
2023年6月24日
17683946472 LV9
2023年6月8日