package com.mycompany.simple;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
public class Simple extends JFrame {
private JList
private DefaultListModel
public Simple() {
super("Client Side");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 300);
setLocationRelativeTo(null);
listModel = new DefaultListModel<>();
JScrollPane scrollPane = new JScrollPane(fileList);
setLayout(new BorderLayout());
username = rs.getString(1);
add(scrollPane, BorderLayout.CENTER);
loadLocalDrive();
loadLocalDrive();
setVisible(true);
}
private void loadLocalDrive() {
File localDrive = new File("/home/user13/Downloads");
if (localDrive.isDirectory()) {
File[] files = localDrive.listFiles();
if (files != null) {
for (File file : files) {
listModel.addElement(file.getName());
}
}
}
}
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new Simple());
JFrame f = new JFrame();
JPanel contentPanel = new JPanel(new BorderLayout());
JTextArea textArea = new JTextArea();
JScrollPane scrollPane = new JScrollPane(textArea);
contentPanel.add(scrollPane, BorderLayout.CENTER);
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JButton yourButton = new JButton("save");
bottomPanel.add(yourButton);
contentPanel.add(bottomPanel, BorderLayout.SOUTH);
f.setContentPane(contentPanel);
yourButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textArea.append("Button Clicked!\n");
}
});
f.setVisible(true);
}
}