added support for displaying list of files but need scrollbar

pull/108/head
js 5 years ago
parent 05a2967645
commit 4167cc3aa6

@ -4,13 +4,17 @@ import javax.swing.JFrame;
public class MainWindow extends JFrame{ public class MainWindow extends JFrame{
private static final long serialVersionUID = 13L;
public MainWindow(){ public MainWindow(){
JFrame fenetre = new JFrame(); JFrame fenetre = new JFrame();
fenetre.setTitle("Client"); fenetre.setTitle("Client");
fenetre.setSize(550, 200); fenetre.setSize(550, 200);
fenetre.setLocationRelativeTo(null); fenetre.setLocationRelativeTo(null);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.add(new Parameters()); //fenetre.add(new Parameters());
String[] listTest = {"test", "test2", "test3", "test4", "test5", "test6", "test7"};
fenetre.add(new downloadSelection(listTest));
fenetre.setVisible(true); fenetre.setVisible(true);
} }

@ -11,6 +11,7 @@ import java.awt.GridLayout;
public class Parameters extends JPanel{ public class Parameters extends JPanel{
private static final long serialVersionUID = 13L;
private JLabel label1, label2, label3, label4, label5; private JLabel label1, label2, label3, label4, label5;
private JTextField field1, field2, field3, field4; private JTextField field1, field2, field3, field4;
private JButton connectButton; private JButton connectButton;

@ -0,0 +1,41 @@
package gui;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JList;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
public class downloadSelection extends JPanel {
private static final long serialVersionUID = 13L;
private String[] listFilesToDownload;
private JList<String> list1;
private JLabel label1;
private JButton downloadButton;
public downloadSelection(String[] listFilesToDownload){
JPanel p1 = new JPanel();
JPanel p3 = new JPanel();
FlowLayout layout = new FlowLayout();
this.listFilesToDownload = listFilesToDownload;
this.list1 = new JList<>(listFilesToDownload);
this.label1 = new JLabel("List of files you can download: ");
this.downloadButton = new JButton("download");
this.list1.setSelectedIndex(0);
p1.setLayout(new GridLayout(1, 2));
p3.setLayout(layout);
this.setLayout(new GridLayout(2, 1));
p1.add(label1);
p1.add(list1);
p3.add(downloadButton);
this.add(p1);
this.add(p3);
setVisible(true);
}
}
Loading…
Cancel
Save