View.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package main;
  2. import javax.imageio.ImageIO;
  3. import javax.swing.*;
  4. import java.awt.*;
  5. import java.io.File;
  6. public class View extends JFrame {
  7. private JButton boutonExport= new JButton("Exporter");
  8. private JButton boutonReset = new JButton("Décocher cases");
  9. private JPanel pan = new JPanel();
  10. private JPanel panimg = new JPanel();
  11. public static void main(String[] args){
  12. new View();
  13. }
  14. public View(){
  15. this.setTitle("Jul Project");
  16. this.setSize(800, 1040);
  17. this.setLocationRelativeTo(null);
  18. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  19. this.setLayout(new BorderLayout());
  20. this.getContentPane().add((pan), BorderLayout.SOUTH);
  21. this.getContentPane().add((panimg), BorderLayout.CENTER);
  22. panimg.setLayout(new GridLayout(5,4));
  23. for (int i=0;i<20;i++){
  24. JButton button = new JButton();
  25. button.setSize(new Dimension(200,200));
  26. try {
  27. ImageJul julImg = new ImageJul(new Jul());
  28. Image iconeJul = julImg.genImage();
  29. Image img = iconeJul.getScaledInstance(button.getWidth(),button.getHeight(), Image.SCALE_DEFAULT);
  30. button.setIcon(new ImageIcon(img));
  31. } catch (Exception ex) {
  32. ex.printStackTrace();
  33. }
  34. panimg.add(button);
  35. }
  36. pan.add(boutonExport);
  37. pan.add(boutonReset);
  38. this.setVisible(true);
  39. }
  40. }