Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
crat1985 authored Jun 15, 2022
1 parent 54b6241 commit 3d535ef
Show file tree
Hide file tree
Showing 66 changed files with 1,508 additions and 1 deletion.
Binary file added bin/fr/programme/com/FirstAppWithListeners1$1.class
Binary file not shown.
Binary file added bin/fr/programme/com/FirstAppWithListeners1.class
Binary file not shown.
Binary file added bin/fr/programme/com/FirstAppWithListeners2.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added bin/fr/programme/com/MyEclipse.class
Binary file not shown.
Binary file added bin/fr/programme/com/MyEclipseTP.class
Binary file not shown.
Binary file added bin/fr/programme/com/MyEclipseTP2.class
Binary file not shown.
Binary file added bin/fr/programme/com/MyEclipseTest.class
Binary file not shown.
Binary file not shown.
Binary file added bin/fr/programme/com/MyFirstAppInJavaSwing.class
Binary file not shown.
Binary file added bin/fr/programme/com/MyWindowBorderLayout.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added bin/fr/programme/com/TutoMenuBar$1.class
Binary file not shown.
Binary file added bin/fr/programme/com/TutoMenuBar.class
Binary file not shown.
Binary file added bin/fr/programme/com/TutoPopupMenu$1.class
Binary file not shown.
Binary file added bin/fr/programme/com/TutoPopupMenu.class
Binary file not shown.
Binary file added bin/fr/programme/com/TutoToolBar.class
Binary file not shown.
Binary file added bin/fr/programme/com/icons/about.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/fr/programme/com/icons/copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/fr/programme/com/icons/cut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/fr/programme/com/icons/exit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/fr/programme/com/icons/java-project-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/fr/programme/com/icons/new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/fr/programme/com/icons/open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/fr/programme/com/icons/paste.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/fr/programme/com/icons/redo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/fr/programme/com/icons/save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/fr/programme/com/icons/save_as.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/fr/programme/com/icons/undo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 117 additions & 0 deletions src/fr/programme/com/FirstAppWithListeners1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package fr.programme.com;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import javax.swing.text.html.HTMLEditorKit;

public class FirstAppWithListeners1 extends JFrame implements ActionListener{

private static final long serialVersionUID = -1408157077817325761L;

public FirstAppWithListeners1() {
super("First app in Java Swing TP");
this.setSize(new Dimension(720,480));
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
// this.add(rootPane);
JPanel contentPane = (JPanel) this.getContentPane();
contentPane.add(createToolBar(),BorderLayout.NORTH);

JScrollPane tree = new JScrollPane(new JTree());
tree.setPreferredSize(new Dimension(200,0));
contentPane.add(tree,BorderLayout.WEST);

JScrollPane textArea = new JScrollPane(new JTextArea());
contentPane.add(textArea);

contentPane.add(createRightPanel(),BorderLayout.EAST);

contentPane.add(createStatusBar(),BorderLayout.SOUTH);
}

private JPanel createStatusBar() {
JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT));
statusBar.add(new JLabel("slt"));
statusBar.add(new JLabel("info inutile"));
statusBar.add(new JLabel("jsp"));
statusBar.setPreferredSize(new Dimension(0,50));
return statusBar;
}

private JPanel createRightPanel() {
JPanel rightPanel = new JPanel(new GridLayout(4,1));
rightPanel.add(new Button("Bouton inutile"));
rightPanel.add(new Button("Bouton inutile"));
rightPanel.add(new Button("Bouton inutile"));
rightPanel.add(new Button("Bouton inutile"));
// rightPanel.setPreferredSize(new Dimension(100,0));
return rightPanel;
}

private static void fileButtonClicked(ActionEvent e) {
System.out.println("Button \"File\" pressed");
}

public JToolBar createToolBar() {
JToolBar toolBar = new JToolBar();
JButton fileButton = new JButton("File");
//obsolète
fileButton.addActionListener(new ActionListener() {
//il vaut mieux utiliser une méthode séparée s'il y a beaucoup de code !!!
public void actionPerformed(ActionEvent e) {
fileButtonClicked(e);
}
});
toolBar.add(fileButton);
JButton editButton = new JButton("Edit");
editButton.addActionListener(this);
toolBar.add(editButton);
toolBar.add(new JButton("Source"));
toolBar.add(new JButton("Refactor"));
toolBar.add(new JButton("Navigate"));
toolBar.add(new JButton("Search"));
toolBar.add(new JButton("Project"));
toolBar.add(new JButton("Run"));
toolBar.add(new JButton("Window"));
helpButton.addActionListener(this);
toolBar.add(helpButton);
return toolBar;
}

public static void main(String[] args) throws UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
FirstAppWithListeners1 window = new FirstAppWithListeners1();
window.setVisible(true);
}

JButton helpButton = new JButton("Help");

@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == helpButton) {
System.out.println("Bouton d'aide pressé !");
} else {
System.out.println("En cours de développement...");
}
}
//TODO 9:06
}
114 changes: 114 additions & 0 deletions src/fr/programme/com/FirstAppWithListeners2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package fr.programme.com;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import javax.swing.text.html.HTMLEditorKit;

public class FirstAppWithListeners2 extends JFrame implements ActionListener{

private static final long serialVersionUID = -1408157077817325761L;

public FirstAppWithListeners2() {
super("First app in Java Swing TP");
this.setSize(new Dimension(720,480));
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
// this.add(rootPane);
JPanel contentPane = (JPanel) this.getContentPane();
contentPane.add(createToolBar(),BorderLayout.NORTH);

JScrollPane tree = new JScrollPane(new JTree());
tree.setPreferredSize(new Dimension(200,0));
contentPane.add(tree,BorderLayout.WEST);

JScrollPane textArea = new JScrollPane(new JTextArea());
contentPane.add(textArea);

contentPane.add(createRightPanel(),BorderLayout.EAST);

contentPane.add(createStatusBar(),BorderLayout.SOUTH);
}

private JPanel createStatusBar() {
JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT));
statusBar.add(new JLabel("slt"));
statusBar.add(new JLabel("info inutile"));
statusBar.add(new JLabel("jsp"));
statusBar.setPreferredSize(new Dimension(0,50));
return statusBar;
}

private JPanel createRightPanel() {
JPanel rightPanel = new JPanel(new GridLayout(4,1));
rightPanel.add(new Button("Bouton inutile"));
rightPanel.add(new Button("Bouton inutile"));
rightPanel.add(new Button("Bouton inutile"));
rightPanel.add(new Button("Bouton inutile"));
// rightPanel.setPreferredSize(new Dimension(100,0));
return rightPanel;
}

private static void fileButtonClicked(ActionEvent e) {
System.out.println("Button \"File\" pressed");
}

public JToolBar createToolBar() {
JToolBar toolBar = new JToolBar();
JButton fileButton = new JButton("File");
// fileButton.addActionListener((e)->{
// System.out.println(e.getSource().);
// });
fileButton.addActionListener((event)->fileButtonClicked(event));
toolBar.add(fileButton);
JButton editButton = new JButton("Edit");
editButton.addActionListener(this);
toolBar.add(editButton);
toolBar.add(new JButton("Source"));
toolBar.add(new JButton("Refactor"));
toolBar.add(new JButton("Navigate"));
toolBar.add(new JButton("Search"));
toolBar.add(new JButton("Project"));
toolBar.add(new JButton("Run"));
toolBar.add(new JButton("Window"));
helpButton.addActionListener(this);
toolBar.add(helpButton);
return toolBar;
}

public static void main(String[] args) throws UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
FirstAppWithListeners2 window = new FirstAppWithListeners2();
window.setVisible(true);
}

JButton helpButton = new JButton("Help");

@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == helpButton) {
System.out.println("Bouton d'aide pressé !");
} else {
System.out.println("En cours de développement...");
}
}
//TODO 9:06
}
164 changes: 164 additions & 0 deletions src/fr/programme/com/FirstAppWithListeners3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package fr.programme.com;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;

public class FirstAppWithListeners3 extends JFrame implements ActionListener{

private static final long serialVersionUID = -1408157077817325761L;

public FirstAppWithListeners3() {
super("First app in Java Swing TP");
this.setSize(new Dimension(720,480));
this.setLocationRelativeTo(null);
// this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
// this.add(rootPane);
JPanel contentPane = (JPanel) this.getContentPane();
contentPane.add(createToolBar(),BorderLayout.NORTH);

JScrollPane tree = new JScrollPane(new JTree());
tree.setPreferredSize(new Dimension(200,0));
contentPane.add(tree,BorderLayout.WEST);

JScrollPane textArea = new JScrollPane(new JTextArea());
contentPane.add(textArea);

contentPane.add(createRightPanel(),BorderLayout.EAST);

contentPane.add(createStatusBar(),BorderLayout.SOUTH);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
int response = JOptionPane.showConfirmDialog(FirstAppWithListeners3.this, "Voulez-vous vraiment quitter ?","Etes-vous sûr ?",JOptionPane.YES_NO_OPTION);
if(response==JOptionPane.YES_OPTION) {
// FirstAppWithListeners3.this.dispose();
dispose();
}
}
});
}

private JPanel createStatusBar() {
JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT));
statusBar.add(new JLabel("slt"));
statusBar.add(new JLabel("info inutile"));
statusBar.add(new JLabel("jsp"));
statusBar.setPreferredSize(new Dimension(0,50));
return statusBar;
}
private JButton rightButton1 = new JButton("Useful Button !");
private JPanel createRightPanel() {
JPanel rightPanel = new JPanel(new GridLayout(4,1));
rightPanel.add(rightButton1);
System.out.println(rightButton1.getBackground());
rightButton1.addFocusListener(new FocusListener() {

@Override
public void focusLost(FocusEvent e) {
rightButton1.setBackground(new Color(214, 217, 223));
}

@Override
public void focusGained(FocusEvent e) {
rightButton1.setBackground(Color.BLUE);
}
});
rightPanel.add(new Button("Bouton inutile"));
rightPanel.add(new Button("Bouton inutile"));
rightPanel.add(new Button("Bouton inutile"));
// rightPanel.setPreferredSize(new Dimension(100,0));
return rightPanel;
}

private void fileButtonClicked(ActionEvent e) {
System.out.println("Button \"File\" pressed");
}

private JButton sourceButton = new JButton("Source");

public JToolBar createToolBar() {
JToolBar toolBar = new JToolBar();
JButton fileButton = new JButton("File");
// fileButton.addActionListener((e)->{
// System.out.println(e.getSource().);
// });
fileButton.addActionListener(this::fileButtonClicked);
toolBar.add(fileButton);
JButton editButton = new JButton("Edit");
editButton.addActionListener(this);
toolBar.add(editButton);
// sourceButton.addMouseListener(new MouseListener() {
// public void mouseReleased(MouseEvent e) {}
// public void mousePressed(MouseEvent e) {}
// public void mouseExited(MouseEvent e) {
// sourceButton.setForeground(Color.BLACK);
// }
// public void mouseEntered(MouseEvent e) {
// sourceButton.setForeground(Color.BLUE);
// }
// public void mouseClicked(MouseEvent e) {}
// });
//plus court
sourceButton.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
sourceButton.setForeground(Color.BLUE);
}
public void mouseExited(MouseEvent e) {
sourceButton.setForeground(Color.BLACK);
}
});
toolBar.add(sourceButton);
toolBar.add(new JButton("Refactor"));
toolBar.add(new JButton("Navigate"));
toolBar.add(new JButton("Search"));
toolBar.add(new JButton("Project"));
toolBar.add(new JButton("Run"));
toolBar.add(new JButton("Window"));
helpButton.addActionListener(this);
toolBar.add(helpButton);
return toolBar;
}

public static void main(String[] args) throws UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
FirstAppWithListeners3 window = new FirstAppWithListeners3();
window.setVisible(true);
}

JButton helpButton = new JButton("Help");

@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == helpButton) {
System.out.println("Bouton d'aide pressé !");
} else {
System.out.println("En cours de développement...");
}
}
//TODO 9:06
}
Loading

0 comments on commit 3d535ef

Please sign in to comment.