premier comit

This commit is contained in:
Antoine GAGNEUX 2020-03-01 16:41:15 +01:00
commit 18c3c0a2dd
14 changed files with 165 additions and 0 deletions

13
.classpath Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/gson-2.8.6.jar"/>
<classpathentry kind="lib" path="lib/kotlin-stdlib-1.3.61.jar"/>
<classpathentry kind="lib" path="lib/okhttp-4.4.0.jar"/>
<classpathentry kind="lib" path="lib/okio-2.4.3.jar"/>
<classpathentry kind="lib" path="lib/retrofit-2.7.2.jar"/>
<classpathentry kind="lib" path="lib/converter-gson-2.0.0-beta3.jar"/>
<classpathentry kind="lib" path="lib/tmdbapiv10.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/bin/

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ExempleTMDB</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

Binary file not shown.

BIN
lib/gson-2.8.6.jar Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/okhttp-4.4.0.jar Normal file

Binary file not shown.

BIN
lib/okio-2.4.3.jar Normal file

Binary file not shown.

BIN
lib/retrofit-2.7.2.jar Normal file

Binary file not shown.

BIN
lib/tmdbapiv10.jar Normal file

Binary file not shown.

10
src/ClassePrincipale.java Normal file
View File

@ -0,0 +1,10 @@
public class ClassePrincipale {
public static void main(String[] args) {
MaJFrame mjf =new MaJFrame();
mjf.setVisible(true);
}
}

39
src/JPanelImage.java Normal file
View File

@ -0,0 +1,39 @@
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
public class JPanelImage extends JPanel {
private static final long serialVersionUID = -4704888296894874299L;
private BufferedImage image=null;
public JPanelImage() {
}
/**
* redéfinition de la methode de dessin du JPanel
* @param g
*/
public void paintComponent(Graphics g) {
super.paintComponent(g);
this.setBackground(Color.white);
if(image!=null) {
g.drawImage(image, 0, 0, this.getWidth(),this.getHeight(),this);
}
}
public BufferedImage getImage() {
return image;
}
public void setImage(BufferedImage buff) {
image=buff;
}
}

74
src/MaJFrame.java Normal file
View File

@ -0,0 +1,74 @@
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import api.TMDBAPI;
import api.TMDBAPICallBack;
import api.TMDBFilm;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;
public class MaJFrame extends JFrame implements TMDBAPICallBack {
private JPanel contentPane;
private JPanelImage panel_im;
private JButton btnNewButton;
private JTextField textField;
private TMDBAPI api=null;
/**
* Create the frame.
*/
public MaJFrame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 300, 450);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
JPanel panel = new JPanel();
contentPane.add(panel, BorderLayout.NORTH);
btnNewButton = new JButton("Film");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
clicBouton();
}
});
textField = new JTextField();
textField.setText("550");
panel.add(textField);
textField.setColumns(5);
panel.add(btnNewButton);
panel_im = new JPanelImage();
contentPane.add(panel_im, BorderLayout.CENTER);
api = new TMDBAPI(this);
}
protected void clicBouton() {
int idFilm=550;
if (textField.getText().length()>1) idFilm = Integer.parseInt(textField.getText());
if (api!=null) api.getFilm(idFilm);
}
@Override
public void retourAPI(TMDBFilm theMovie) {
if (theMovie!=null) {
panel_im.setImage(theMovie.getPoster_image());
}
this.repaint();
}
}