Commit af80f4c2d7138669fde79a63f980956c437b2083
0 parents
added src files
Showing
11 changed files
with
316 additions
and
0 deletions
Show diff stats
1 | +++ a/ihm.iml | ||
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<module type="JAVA_MODULE" version="4"> | ||
3 | + <component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
4 | + <exclude-output /> | ||
5 | + <content url="file://$MODULE_DIR$"> | ||
6 | + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
7 | + </content> | ||
8 | + <orderEntry type="inheritedJdk" /> | ||
9 | + <orderEntry type="sourceFolder" forTests="false" /> | ||
10 | + </component> | ||
11 | +</module> | ||
0 | \ No newline at end of file | 12 | \ No newline at end of file |
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
1 | +++ a/src/tp1/editeur.java | ||
@@ -0,0 +1,72 @@ | @@ -0,0 +1,72 @@ | ||
1 | +package tp1; | ||
2 | + | ||
3 | +import javax.swing.*; | ||
4 | +import java.awt.*; | ||
5 | +import java.util.concurrent.Flow; | ||
6 | + | ||
7 | +public class editeur { | ||
8 | + public static final int width = 1000; | ||
9 | + public static final int height = 800; | ||
10 | + | ||
11 | + public static void main(String[] args) { | ||
12 | + JFrame win = new JFrame(); | ||
13 | + | ||
14 | + win.setSize( width, height); | ||
15 | + win.setLocationRelativeTo(null); | ||
16 | + | ||
17 | + FlowLayout toolBarLayout = new FlowLayout(FlowLayout.LEFT); | ||
18 | + JPanel toolbar = new JPanel(); | ||
19 | + toolbar.setLayout(toolBarLayout); | ||
20 | + JButton file = new JButton("Fichier"); | ||
21 | + JButton edit = new JButton("Edition"); | ||
22 | + JButton format = new JButton("Format"); | ||
23 | + toolbar.add(file); | ||
24 | + toolbar.add(edit); | ||
25 | + toolbar.add(format); | ||
26 | + | ||
27 | + | ||
28 | + FlowLayout statusBarLayout = new FlowLayout(FlowLayout.LEFT); | ||
29 | + JPanel statusBar = new JPanel(); | ||
30 | + statusBar.setLayout(statusBarLayout); | ||
31 | + | ||
32 | + JLabel researchLabel = new JLabel("Rechercher :"); | ||
33 | + JTextField researchBar = new JTextField(); | ||
34 | + researchBar.setPreferredSize(new Dimension(200, 25)); | ||
35 | + JButton leftArrow = new JButton("<-"); | ||
36 | + JButton rightArrow = new JButton("->"); | ||
37 | + JButton overlineAll = new JButton("Tout surligner"); | ||
38 | + statusBar.add(researchLabel); | ||
39 | + statusBar.add(researchBar); | ||
40 | + statusBar.add(leftArrow); | ||
41 | + statusBar.add(rightArrow); | ||
42 | + statusBar.add(overlineAll); | ||
43 | + | ||
44 | + JTextArea editor = new JTextArea(); | ||
45 | + | ||
46 | + JWindow menu = new JWindow(); | ||
47 | + menu.setLayout(new BoxLayout(menu.getContentPane(), BoxLayout.PAGE_AXIS)); | ||
48 | + menu.add(Box.createRigidArea(new Dimension(15, 0))); | ||
49 | + menu.add(new JLabel("Nouveau")); | ||
50 | + menu.add(new JLabel("Ouvrir")); | ||
51 | + menu.add(new JLabel("Enregistrer")); | ||
52 | + menu.add(new JLabel("Enregistrer sous")); | ||
53 | + menu.add(new JSeparator()); | ||
54 | + menu.add(new JLabel("Mise en page ")); | ||
55 | + menu.add(new JLabel("imprimer")); | ||
56 | + menu.add(new JSeparator()); | ||
57 | + menu.add(new JLabel("Quitter")); | ||
58 | + | ||
59 | + | ||
60 | + win.add(toolbar, BorderLayout.NORTH); | ||
61 | + win.add(editor); | ||
62 | + win.add(statusBar, BorderLayout.SOUTH); | ||
63 | + | ||
64 | + win.setVisible(true); | ||
65 | + | ||
66 | + menu.setSize(210, 120); | ||
67 | + menu.setLocation(win.getX()+5,win.getY()+file.getHeight()+40); | ||
68 | + | ||
69 | + win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
70 | + menu.setVisible(true); | ||
71 | + } | ||
72 | +} |
1 | +++ a/src/tp1/fenetres.java | ||
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +package tp1; | ||
2 | + | ||
3 | +import javax.swing.*; | ||
4 | + | ||
5 | +public class fenetres { | ||
6 | + public static void main(String[] args) { | ||
7 | + //question 1 | ||
8 | + //JWindow win = new JWindow(); | ||
9 | + //il peut etre intéressant d'utiliser la classe JWindow pour afficher le logo d'un logiciel lors de son démarrage | ||
10 | + //afin de faire patienter l'utilisateur. | ||
11 | + | ||
12 | + //question 2 | ||
13 | + JFrame win = new JFrame(); | ||
14 | + | ||
15 | + win.setSize( 500, 400); | ||
16 | + win.setLocationRelativeTo(null); | ||
17 | + | ||
18 | + JLabel label = new JLabel("Hello World!"); | ||
19 | + | ||
20 | + win.add(label); | ||
21 | + | ||
22 | + //question 5 | ||
23 | + //JDialog dialog = new JDialog(win); | ||
24 | + | ||
25 | + //question 3 | ||
26 | + win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
27 | + //question 4 | ||
28 | + win.setResizable(false); | ||
29 | + win.setVisible(true); | ||
30 | + JDialog dialog = new JDialog(win, true); | ||
31 | + //on peut interragir avec la fenetre à partir du moment où l'on ferme la boite de dialogue | ||
32 | + dialog.setSize(150,100); | ||
33 | + dialog.setLocationRelativeTo(null); | ||
34 | + dialog.setVisible(true); | ||
35 | + } | ||
36 | +} |
1 | +++ a/src/tp1/gestionnaires.java | ||
@@ -0,0 +1,166 @@ | @@ -0,0 +1,166 @@ | ||
1 | +package tp1; | ||
2 | + | ||
3 | +import javax.swing.*; | ||
4 | +import java.awt.*; | ||
5 | + | ||
6 | +public class gestionnaires { | ||
7 | + public static final int width = 500; | ||
8 | + public static final int height = 400; | ||
9 | + | ||
10 | + public static void main(String[] args) { | ||
11 | + | ||
12 | + //question 16 | ||
13 | + try { | ||
14 | + UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); | ||
15 | + } catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException e) { | ||
16 | + e.printStackTrace(); | ||
17 | + } | ||
18 | + JFrame win = new JFrame(); | ||
19 | + | ||
20 | + win.setSize( width, height); | ||
21 | + win.setLocationRelativeTo(null); | ||
22 | + | ||
23 | + /* | ||
24 | + //questioon 6 | ||
25 | + JButton toto1 = new JButton("button1"); | ||
26 | + JButton toto2 = new JButton("button2"); | ||
27 | + JButton toto3 = new JButton("button3"); | ||
28 | + JButton toto4 = new JButton("button4"); | ||
29 | + JButton toto5 = new JButton("button5"); | ||
30 | + | ||
31 | + win.add(toto1, BorderLayout.EAST); | ||
32 | + win.add(toto2, BorderLayout.WEST); | ||
33 | + win.add(toto3, BorderLayout.NORTH); | ||
34 | + win.add(toto4, BorderLayout.SOUTH); | ||
35 | + win.add(toto5, BorderLayout.CENTER); | ||
36 | + */ | ||
37 | + | ||
38 | + /* | ||
39 | + //question 7 | ||
40 | + FlowLayout layout = new FlowLayout(); | ||
41 | + win.setLayout(layout); | ||
42 | + | ||
43 | + JButton[] buttons = new JButton[20]; | ||
44 | + | ||
45 | + for (int i = 0; i < buttons.length; i++) { | ||
46 | + buttons[i] = new JButton("button "+ i); | ||
47 | + win.add(buttons[i]); | ||
48 | + } | ||
49 | + */ | ||
50 | + | ||
51 | + /* | ||
52 | + //question 8 | ||
53 | + GridLayout layout = new GridLayout(4,4); | ||
54 | + win.setLayout(layout); | ||
55 | + JButton[] buttons = new JButton[16]; | ||
56 | + for (int i = 0; i < buttons.length; i++) { | ||
57 | + buttons[i] = new JButton("button "+ i); | ||
58 | + win.add(buttons[i]); | ||
59 | + } | ||
60 | + */ | ||
61 | + | ||
62 | + /* | ||
63 | + //question 9 | ||
64 | + BoxLayout layout = new BoxLayout(win.getContentPane(), BoxLayout.PAGE_AXIS); | ||
65 | + win.setLayout(layout); | ||
66 | + JButton[] buttons = new JButton[3]; | ||
67 | + for (int i = 0; i < buttons.length; i++) { | ||
68 | + buttons[i] = new JButton("button "+ i); | ||
69 | + buttons[i].setPreferredSize(new Dimension(width-1, 50)); | ||
70 | + } | ||
71 | + | ||
72 | + win.add(buttons[0]); | ||
73 | + win.add(Box.createRigidArea(new Dimension(0, 20))); | ||
74 | + win.add(buttons[1]); | ||
75 | + win.add(Box.createVerticalGlue()); | ||
76 | + win.add(buttons[2]); | ||
77 | + */ | ||
78 | + | ||
79 | + /* | ||
80 | + //question 10 | ||
81 | + GridBagLayout layout = new GridBagLayout(); | ||
82 | + win.setLayout(layout); | ||
83 | + GridBagConstraints[] c = new GridBagConstraints[10]; | ||
84 | + for (int i = 0; i < c.length; i++) { | ||
85 | + c[i] = new GridBagConstraints(); | ||
86 | + } | ||
87 | + | ||
88 | + c[0].gridx = 0; | ||
89 | + c[0].gridy = 0; | ||
90 | + | ||
91 | + c[1].gridx = 1; | ||
92 | + c[1].gridy = 0; | ||
93 | + | ||
94 | + c[2].gridx = 2; | ||
95 | + c[2].gridy = 0; | ||
96 | + | ||
97 | + c[3].gridx = 3; | ||
98 | + c[3].gridy = 0; | ||
99 | + | ||
100 | + c[4].gridx = 0; | ||
101 | + c[4].gridy = 1; | ||
102 | + c[4].gridwidth = 4; | ||
103 | + | ||
104 | + c[5].gridx = 0; | ||
105 | + c[5].gridy = 2; | ||
106 | + c[5].gridwidth = 3; | ||
107 | + | ||
108 | + c[6].gridx = 3; | ||
109 | + c[6].gridy = 2; | ||
110 | + | ||
111 | + c[7].gridx = 0; | ||
112 | + c[7].gridy = 3; | ||
113 | + c[7].gridheight = 2; | ||
114 | + | ||
115 | + c[8].gridx = 1; | ||
116 | + c[8].gridy = 3; | ||
117 | + c[8].gridwidth = 3; | ||
118 | + | ||
119 | + c[9].gridx = 1; | ||
120 | + c[9].gridy = 4; | ||
121 | + c[9].gridwidth = 3; | ||
122 | + | ||
123 | + JButton[] buttons = new JButton[10]; | ||
124 | + for (int i = 0; i < buttons.length; i++) { | ||
125 | + buttons[i] = new JButton("button "+ i); | ||
126 | + c[i].fill = GridBagConstraints.BOTH; | ||
127 | + win.add(buttons[i], c[i]); | ||
128 | + } | ||
129 | + */ | ||
130 | + | ||
131 | + /* | ||
132 | + //question 12 | ||
133 | + win.setLayout(null); | ||
134 | + int nbouton = 10; | ||
135 | + int xstep = width/(nbouton +1); | ||
136 | + int ystep = height/(nbouton +1); | ||
137 | + JButton[] buttons = new JButton[nbouton]; | ||
138 | + | ||
139 | + for (int i = 0; i < buttons.length; i++) { | ||
140 | + buttons[i] = new JButton("button "+ i); | ||
141 | + win.add(buttons[i]); | ||
142 | + buttons[i].setBounds( i*xstep, i*ystep,100,30); | ||
143 | + buttons[i].repaint(); | ||
144 | + } | ||
145 | + */ | ||
146 | + | ||
147 | + JButton toto1 = new JButton("button1"); | ||
148 | + JButton toto2 = new JButton("button2"); | ||
149 | + JButton toto4 = new JButton("button4"); | ||
150 | + JButton toto5 = new JButton("button5"); | ||
151 | + | ||
152 | + JPanel toto3 = new JPanel(); | ||
153 | + toto3.add(new Button("bouton")); | ||
154 | + toto3.add(new Button("bouton")); | ||
155 | + toto3.add(new Button("bouton")); | ||
156 | + | ||
157 | + win.add(toto1, BorderLayout.EAST); | ||
158 | + win.add(toto2, BorderLayout.WEST); | ||
159 | + win.add(toto3, BorderLayout.NORTH); | ||
160 | + win.add(toto4, BorderLayout.SOUTH); | ||
161 | + win.add(toto5, BorderLayout.CENTER); | ||
162 | + | ||
163 | + win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
164 | + win.setVisible(true); | ||
165 | + } | ||
166 | +} |
1 | +++ a/src/tp2/exo1/MainClass.java | ||
@@ -0,0 +1,31 @@ | @@ -0,0 +1,31 @@ | ||
1 | +package tp2.exo1; | ||
2 | + | ||
3 | + | ||
4 | +import javax.swing.*; | ||
5 | +import java.awt.*; | ||
6 | + | ||
7 | +public class MainClass { | ||
8 | + public static void main(String[] args) { | ||
9 | + JFrame win = new JFrame(); | ||
10 | + | ||
11 | + win.setSize( 500, 400); | ||
12 | + win.setLocationRelativeTo(null); | ||
13 | + | ||
14 | + JLabel label = new JLabel("0"); | ||
15 | + | ||
16 | + win.add(label, BorderLayout.NORTH); | ||
17 | + | ||
18 | + JButton incbutt = new JButton("incrémenter"); | ||
19 | + incbutt.addActionListener(e -> { | ||
20 | + int t = Integer.parseInt(label.getText()); | ||
21 | + label.setText(Integer.toString(t+1)); | ||
22 | + }); | ||
23 | + | ||
24 | + win.add(incbutt, BorderLayout.SOUTH); | ||
25 | + | ||
26 | + win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
27 | + | ||
28 | + win.setResizable(false); | ||
29 | + win.setVisible(true); | ||
30 | + } | ||
31 | +} |