...
 
Commits (4)
......@@ -16,7 +16,7 @@ public class NavigateurActeur {
private Statement stmt = null;
private ResultSet acteurRS;
private int nbActeur;
private int nbActeur =0;
public int getNbActeur() {
return nbActeur;
......
package metier;
import java.sql.*;
import javax.swing.table.*;
abstract class ResultSetTableModel extends AbstractTableModel {
private ResultSet rs;
private ResultSetMetaData rsmd;
public ResultSetTableModel(ResultSet aResultSet) {
this.rs = aResultSet;
try {
rsmd = rs.getMetaData();
} catch (SQLException e) {
System.out.println("Erreur " + e);
}
}
@Override
public String getColumnName(int column) {
try {
return rsmd.getColumnName(column + 1);
} catch (SQLException e) {
System.out.println("Erreur " + e);
return "";
}
}
@Override
public int getColumnCount() {
try {
return rsmd.getColumnCount();
} catch (SQLException e) {
System.out.println("Erreur " + e);
return 0;
}
}
protected ResultSet getResultSet() {
return rs;
}
}
package metier;
import java.sql.ResultSet;
import java.sql.SQLException;
public class ScrollingResultSetTableModel extends ResultSetTableModel {
public ScrollingResultSetTableModel(ResultSet aResultSet) {
super(aResultSet);
}
public Object getValueAt(int r, int c)
{
try {
ResultSet rs = getResultSet();
rs.absolute(r + 1);
return rs.getObject(c + 1);
} catch (SQLException e) {
System.out.println("Erreur " + e);
return null;
}
}
public int getRowCount()
{
try {
ResultSet rs = getResultSet();
rs.last();
return rs.getRow();
} catch (SQLException e) {
System.out.println("Erreur " + e);
return 0;
}
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex){
return false;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="presentation.CarriereActeur">
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="2" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="3" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="593" height="400"/>
<xy x="20" y="20" width="644" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f0b3e" class="javax.swing.JButton" binding="button1" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="100" height="25"/>
<preferred-size width="100" height="25"/>
<maximum-size width="100" height="25"/>
......@@ -22,7 +22,7 @@
</component>
<component id="d15d8" class="javax.swing.JButton" binding="button2" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="100" height="25"/>
<preferred-size width="100" height="25"/>
<maximum-size width="100" height="25"/>
......@@ -34,7 +34,7 @@
</component>
<component id="e558c" class="javax.swing.JProgressBar" binding="progressBar1" default-binding="true">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<requestFocusEnabled value="false"/>
......@@ -44,7 +44,7 @@
</component>
<component id="b5ca2" class="javax.swing.JButton" binding="button3" default-binding="true">
<constraints>
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="100" height="25"/>
<preferred-size width="100" height="25"/>
<maximum-size width="100" height="25"/>
......@@ -56,7 +56,7 @@
</component>
<component id="cff71" class="javax.swing.JButton" binding="button4" default-binding="true">
<constraints>
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="100" height="25"/>
<preferred-size width="100" height="25"/>
<maximum-size width="100" height="25"/>
......@@ -118,6 +118,24 @@
</component>
</children>
</grid>
<grid id="90508" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="9ad9c" class="javax.swing.JButton" binding="carriereButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Carriere"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>
......@@ -25,9 +25,12 @@ public class CarriereActeur {
private JLabel nomLabel;
private JPanel test;
private JPanel panel2;
private JButton carriereButton;
private Color sombre = new Color(89,91,93);
private Color blue = new Color(53,146,196);
private CarriereDlg carriereDlg;
public CarriereActeur() throws Exception {
init();
button3.addActionListener(new ActionListener() {
......@@ -99,6 +102,17 @@ public class CarriereActeur {
}
}
});
carriereButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
if(carriereDlg == null){
carriereDlg = new CarriereDlg();
carriereDlg.setSize(900,400);
carriereDlg.setBackground(sombre);
}
carriereDlg.show(nacteur);
}
});
}
private void init() throws Exception{
......
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="presentation.CarriereDlg">
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="48" y="54" width="436" height="297"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="94766" binding="carrierePanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="98af6">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="OK"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<grid id="e3588" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane id="b7f5e">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3ff16" class="javax.swing.JTable" binding="tableCarriere">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
</children>
</grid>
</children>
</grid>
</form>
package presentation;
import metier.ScrollingResultSetTableModel;
import javax.swing.*;
import java.awt.event.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class CarriereDlg extends JDialog {
private JPanel contentPane;
private JButton buttonOK;
private JButton buttonCancel;
private JPanel carrierePanel;
private JTable tableCarriere;
private PreparedStatement stmt;
private ResultSet rs;
private ScrollingResultSetTableModel model;
//requete SQL : carriere d'un acteur
private static String QUERY = " select TITRE, NATURE, nom as Pays, REALISATEUR, SORTIE, ENTREES "
+ " FROM FILM "
+ " JOIN GENRE USING (ngenre) "
+ " JOIN PAYS USING (npays) "
+ " WHERE NACTEURPRINCIPAL = ? "
+ " ORDER BY TITRE ";
private void init(){
try{
stmt = dto.ConnectCinema.getInstance().prepareStatement(QUERY,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
} catch (SQLException e) {
System.err.println(e.getMessage());
}
}
public void show(int nacteur) {
try {
if (rs != null){
rs.close();
}
stmt.setInt(1, nacteur);
rs=stmt.executeQuery();
model = new ScrollingResultSetTableModel(rs);
this.tableCarriere.setModel(model);
this.setVisible(true);
}catch (SQLException e){
System.err.println("Erreur" + e);
}
}
public CarriereDlg() {
init();
setContentPane(contentPane);
setModal(true);
getRootPane().setDefaultButton(buttonOK);
buttonOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onOK();
}
});
// call onCancel() when cross is clicked
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
onCancel();
}
});
// call onCancel() on ESCAPE
contentPane.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onCancel();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
private void onOK() {
// add your code here
this.setVisible(false);
}
private void onCancel() {
// add your code here if necessary
dispose();
}
public static void main(String[] args) {
CarriereDlg dialog = new CarriereDlg();
dialog.pack();
dialog.setVisible(true);
System.exit(0);
}
}
package presentation;
public class CineCarriere {
}