From af80f4c2d7138669fde79a63f980956c437b2083 Mon Sep 17 00:00:00 2001 From: Shaggy420 Date: Mon, 11 Apr 2022 17:29:26 +0200 Subject: [PATCH] added src files --- ihm.iml | 11 +++++++++++ out/production/ihm/tp1.tar | Bin 0 -> 20480 bytes out/production/ihm/tp1/editeur.class | Bin 0 -> 2948 bytes out/production/ihm/tp1/fenetres.class | Bin 0 -> 1055 bytes out/production/ihm/tp1/gestionnaires.class | Bin 0 -> 1899 bytes out/production/ihm/tp2/exo1/MainClass.class | Bin 0 -> 2101 bytes src/tp1.tar | Bin 0 -> 20480 bytes src/tp1/editeur.java | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/tp1/fenetres.java | 36 ++++++++++++++++++++++++++++++++++++ src/tp1/gestionnaires.java | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/tp2/exo1/MainClass.java | 31 +++++++++++++++++++++++++++++++ 11 files changed, 316 insertions(+), 0 deletions(-) create mode 100644 ihm.iml create mode 100644 out/production/ihm/tp1.tar create mode 100644 out/production/ihm/tp1/editeur.class create mode 100644 out/production/ihm/tp1/fenetres.class create mode 100644 out/production/ihm/tp1/gestionnaires.class create mode 100644 out/production/ihm/tp2/exo1/MainClass.class create mode 100644 src/tp1.tar create mode 100644 src/tp1/editeur.java create mode 100644 src/tp1/fenetres.java create mode 100644 src/tp1/gestionnaires.java create mode 100644 src/tp2/exo1/MainClass.java diff --git a/ihm.iml b/ihm.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/ihm.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/ihm/tp1.tar b/out/production/ihm/tp1.tar new file mode 100644 index 0000000..aff4cf1 Binary files /dev/null and b/out/production/ihm/tp1.tar differ diff --git a/out/production/ihm/tp1/editeur.class b/out/production/ihm/tp1/editeur.class new file mode 100644 index 0000000..71dcaf4 Binary files /dev/null and b/out/production/ihm/tp1/editeur.class differ diff --git a/out/production/ihm/tp1/fenetres.class b/out/production/ihm/tp1/fenetres.class new file mode 100644 index 0000000..1e701be Binary files /dev/null and b/out/production/ihm/tp1/fenetres.class differ diff --git a/out/production/ihm/tp1/gestionnaires.class b/out/production/ihm/tp1/gestionnaires.class new file mode 100644 index 0000000..f95e548 Binary files /dev/null and b/out/production/ihm/tp1/gestionnaires.class differ diff --git a/out/production/ihm/tp2/exo1/MainClass.class b/out/production/ihm/tp2/exo1/MainClass.class new file mode 100644 index 0000000..2ce1250 Binary files /dev/null and b/out/production/ihm/tp2/exo1/MainClass.class differ diff --git a/src/tp1.tar b/src/tp1.tar new file mode 100644 index 0000000..aff4cf1 Binary files /dev/null and b/src/tp1.tar differ diff --git a/src/tp1/editeur.java b/src/tp1/editeur.java new file mode 100644 index 0000000..c67f1af --- /dev/null +++ b/src/tp1/editeur.java @@ -0,0 +1,72 @@ +package tp1; + +import javax.swing.*; +import java.awt.*; +import java.util.concurrent.Flow; + +public class editeur { + public static final int width = 1000; + public static final int height = 800; + + public static void main(String[] args) { + JFrame win = new JFrame(); + + win.setSize( width, height); + win.setLocationRelativeTo(null); + + FlowLayout toolBarLayout = new FlowLayout(FlowLayout.LEFT); + JPanel toolbar = new JPanel(); + toolbar.setLayout(toolBarLayout); + JButton file = new JButton("Fichier"); + JButton edit = new JButton("Edition"); + JButton format = new JButton("Format"); + toolbar.add(file); + toolbar.add(edit); + toolbar.add(format); + + + FlowLayout statusBarLayout = new FlowLayout(FlowLayout.LEFT); + JPanel statusBar = new JPanel(); + statusBar.setLayout(statusBarLayout); + + JLabel researchLabel = new JLabel("Rechercher :"); + JTextField researchBar = new JTextField(); + researchBar.setPreferredSize(new Dimension(200, 25)); + JButton leftArrow = new JButton("<-"); + JButton rightArrow = new JButton("->"); + JButton overlineAll = new JButton("Tout surligner"); + statusBar.add(researchLabel); + statusBar.add(researchBar); + statusBar.add(leftArrow); + statusBar.add(rightArrow); + statusBar.add(overlineAll); + + JTextArea editor = new JTextArea(); + + JWindow menu = new JWindow(); + menu.setLayout(new BoxLayout(menu.getContentPane(), BoxLayout.PAGE_AXIS)); + menu.add(Box.createRigidArea(new Dimension(15, 0))); + menu.add(new JLabel("Nouveau")); + menu.add(new JLabel("Ouvrir")); + menu.add(new JLabel("Enregistrer")); + menu.add(new JLabel("Enregistrer sous")); + menu.add(new JSeparator()); + menu.add(new JLabel("Mise en page ")); + menu.add(new JLabel("imprimer")); + menu.add(new JSeparator()); + menu.add(new JLabel("Quitter")); + + + win.add(toolbar, BorderLayout.NORTH); + win.add(editor); + win.add(statusBar, BorderLayout.SOUTH); + + win.setVisible(true); + + menu.setSize(210, 120); + menu.setLocation(win.getX()+5,win.getY()+file.getHeight()+40); + + win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + menu.setVisible(true); + } +} diff --git a/src/tp1/fenetres.java b/src/tp1/fenetres.java new file mode 100644 index 0000000..20ec397 --- /dev/null +++ b/src/tp1/fenetres.java @@ -0,0 +1,36 @@ +package tp1; + +import javax.swing.*; + +public class fenetres { + public static void main(String[] args) { + //question 1 + //JWindow win = new JWindow(); + //il peut etre intéressant d'utiliser la classe JWindow pour afficher le logo d'un logiciel lors de son démarrage + //afin de faire patienter l'utilisateur. + + //question 2 + JFrame win = new JFrame(); + + win.setSize( 500, 400); + win.setLocationRelativeTo(null); + + JLabel label = new JLabel("Hello World!"); + + win.add(label); + + //question 5 + //JDialog dialog = new JDialog(win); + + //question 3 + win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + //question 4 + win.setResizable(false); + win.setVisible(true); + JDialog dialog = new JDialog(win, true); + //on peut interragir avec la fenetre à partir du moment où l'on ferme la boite de dialogue + dialog.setSize(150,100); + dialog.setLocationRelativeTo(null); + dialog.setVisible(true); + } +} diff --git a/src/tp1/gestionnaires.java b/src/tp1/gestionnaires.java new file mode 100644 index 0000000..d47a4a8 --- /dev/null +++ b/src/tp1/gestionnaires.java @@ -0,0 +1,166 @@ +package tp1; + +import javax.swing.*; +import java.awt.*; + +public class gestionnaires { + public static final int width = 500; + public static final int height = 400; + + public static void main(String[] args) { + + //question 16 + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + } catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + JFrame win = new JFrame(); + + win.setSize( width, height); + win.setLocationRelativeTo(null); + + /* + //questioon 6 + JButton toto1 = new JButton("button1"); + JButton toto2 = new JButton("button2"); + JButton toto3 = new JButton("button3"); + JButton toto4 = new JButton("button4"); + JButton toto5 = new JButton("button5"); + + win.add(toto1, BorderLayout.EAST); + win.add(toto2, BorderLayout.WEST); + win.add(toto3, BorderLayout.NORTH); + win.add(toto4, BorderLayout.SOUTH); + win.add(toto5, BorderLayout.CENTER); + */ + + /* + //question 7 + FlowLayout layout = new FlowLayout(); + win.setLayout(layout); + + JButton[] buttons = new JButton[20]; + + for (int i = 0; i < buttons.length; i++) { + buttons[i] = new JButton("button "+ i); + win.add(buttons[i]); + } + */ + + /* + //question 8 + GridLayout layout = new GridLayout(4,4); + win.setLayout(layout); + JButton[] buttons = new JButton[16]; + for (int i = 0; i < buttons.length; i++) { + buttons[i] = new JButton("button "+ i); + win.add(buttons[i]); + } + */ + + /* + //question 9 + BoxLayout layout = new BoxLayout(win.getContentPane(), BoxLayout.PAGE_AXIS); + win.setLayout(layout); + JButton[] buttons = new JButton[3]; + for (int i = 0; i < buttons.length; i++) { + buttons[i] = new JButton("button "+ i); + buttons[i].setPreferredSize(new Dimension(width-1, 50)); + } + + win.add(buttons[0]); + win.add(Box.createRigidArea(new Dimension(0, 20))); + win.add(buttons[1]); + win.add(Box.createVerticalGlue()); + win.add(buttons[2]); + */ + + /* + //question 10 + GridBagLayout layout = new GridBagLayout(); + win.setLayout(layout); + GridBagConstraints[] c = new GridBagConstraints[10]; + for (int i = 0; i < c.length; i++) { + c[i] = new GridBagConstraints(); + } + + c[0].gridx = 0; + c[0].gridy = 0; + + c[1].gridx = 1; + c[1].gridy = 0; + + c[2].gridx = 2; + c[2].gridy = 0; + + c[3].gridx = 3; + c[3].gridy = 0; + + c[4].gridx = 0; + c[4].gridy = 1; + c[4].gridwidth = 4; + + c[5].gridx = 0; + c[5].gridy = 2; + c[5].gridwidth = 3; + + c[6].gridx = 3; + c[6].gridy = 2; + + c[7].gridx = 0; + c[7].gridy = 3; + c[7].gridheight = 2; + + c[8].gridx = 1; + c[8].gridy = 3; + c[8].gridwidth = 3; + + c[9].gridx = 1; + c[9].gridy = 4; + c[9].gridwidth = 3; + + JButton[] buttons = new JButton[10]; + for (int i = 0; i < buttons.length; i++) { + buttons[i] = new JButton("button "+ i); + c[i].fill = GridBagConstraints.BOTH; + win.add(buttons[i], c[i]); + } + */ + + /* + //question 12 + win.setLayout(null); + int nbouton = 10; + int xstep = width/(nbouton +1); + int ystep = height/(nbouton +1); + JButton[] buttons = new JButton[nbouton]; + + for (int i = 0; i < buttons.length; i++) { + buttons[i] = new JButton("button "+ i); + win.add(buttons[i]); + buttons[i].setBounds( i*xstep, i*ystep,100,30); + buttons[i].repaint(); + } + */ + + JButton toto1 = new JButton("button1"); + JButton toto2 = new JButton("button2"); + JButton toto4 = new JButton("button4"); + JButton toto5 = new JButton("button5"); + + JPanel toto3 = new JPanel(); + toto3.add(new Button("bouton")); + toto3.add(new Button("bouton")); + toto3.add(new Button("bouton")); + + win.add(toto1, BorderLayout.EAST); + win.add(toto2, BorderLayout.WEST); + win.add(toto3, BorderLayout.NORTH); + win.add(toto4, BorderLayout.SOUTH); + win.add(toto5, BorderLayout.CENTER); + + win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + win.setVisible(true); + } +} diff --git a/src/tp2/exo1/MainClass.java b/src/tp2/exo1/MainClass.java new file mode 100644 index 0000000..55885b6 --- /dev/null +++ b/src/tp2/exo1/MainClass.java @@ -0,0 +1,31 @@ +package tp2.exo1; + + +import javax.swing.*; +import java.awt.*; + +public class MainClass { + public static void main(String[] args) { + JFrame win = new JFrame(); + + win.setSize( 500, 400); + win.setLocationRelativeTo(null); + + JLabel label = new JLabel("0"); + + win.add(label, BorderLayout.NORTH); + + JButton incbutt = new JButton("incrémenter"); + incbutt.addActionListener(e -> { + int t = Integer.parseInt(label.getText()); + label.setText(Integer.toString(t+1)); + }); + + win.add(incbutt, BorderLayout.SOUTH); + + win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + win.setResizable(false); + win.setVisible(true); + } +} -- libgit2 0.21.2