import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; public class ClientApp extends JFrame { private JTextArea textArea; private JButton loadButton; private File file = new File("clients.txt"); public ClientApp() { setTitle("Client Viewer"); setSize(400, 300); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BorderLayout()); textArea = new JTextArea(); loadButton = new JButton("Load Clients"); add(new JScrollPane(textArea), BorderLayout.CENTER); add(loadButton, BorderLayout.SOUTH); loadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { loadClientsFromFile(); } }); setVisible(true); } private void loadClientsFromFile() { textArea.setText(""); try (BufferedReader br = new BufferedReader(new FileReader(file))) { String line; while ((line = br.readLine()) != null) { String[] data = line.split(","); if (data.length == 4) { textArea.append("ID: " + data[0] + "\n"); textArea.append("Name: " + data[1] + "\n"); textArea.append("Address: " + data[2] + "\n"); textArea.append("Phone: " + data[3] + "\n"); textArea.append("-------------------------\n"); } } } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Error reading file: " + ex.getMessage()); } } public static void main(String[] args) { new ClientApp(); } }