work together in school
This commit is contained in:
parent
b74565132a
commit
761e64756b
BIN
bin/BillGUI/BillGui.class
Normal file
BIN
bin/BillGUI/BillGui.class
Normal file
Binary file not shown.
BIN
bin/BillGUI/ButtonListenerBill.class
Normal file
BIN
bin/BillGUI/ButtonListenerBill.class
Normal file
Binary file not shown.
BIN
bin/BillGUI/ButtonListenerManager.class
Normal file
BIN
bin/BillGUI/ButtonListenerManager.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/BillGUI/Impression1.class
Normal file
BIN
bin/BillGUI/Impression1.class
Normal file
Binary file not shown.
BIN
bin/BillGUI/ManagerGui$1.class
Normal file
BIN
bin/BillGUI/ManagerGui$1.class
Normal file
Binary file not shown.
BIN
bin/BillGUI/ManagerGui$2.class
Normal file
BIN
bin/BillGUI/ManagerGui$2.class
Normal file
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.
58
src/BillGUI/BillGui.java
Normal file
58
src/BillGUI/BillGui.java
Normal file
@ -0,0 +1,58 @@
|
||||
package BillGUI;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class BillGui extends JFrame{
|
||||
String bill;
|
||||
JPanel jP;
|
||||
|
||||
BillGui(String bill){
|
||||
this.bill = bill;
|
||||
|
||||
//Create the frame with the layout
|
||||
this.setSize(400,600);
|
||||
this.setLocation(600,200);
|
||||
this.setVisible(true);
|
||||
FlowLayout fl = new FlowLayout();
|
||||
this.setLayout(fl);
|
||||
|
||||
jP = new JPanel();
|
||||
|
||||
JLabel jBill = new JLabel(bill);
|
||||
jP.add(jBill);
|
||||
|
||||
this.add(jP);
|
||||
|
||||
JButton buttonPrint = new JButton("Print");
|
||||
buttonPrint.addActionListener(new Impression1(jP));
|
||||
/*
|
||||
new ButtonListenerBill(this) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e){
|
||||
// TO-DO : print the pdf
|
||||
};
|
||||
});*/
|
||||
this.add(buttonPrint);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ButtonListenerBill implements ActionListener {
|
||||
JFrame Jf;
|
||||
|
||||
ButtonListenerBill(JFrame Jf){
|
||||
this.Jf = Jf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e){
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -4,9 +4,9 @@ public class HesSoGarage {
|
||||
public static void main(String[] args) {
|
||||
GarageManager garageManager = new GarageManager();
|
||||
ManagerGui managerGui;
|
||||
String name = "Garage manager\nPrestations";
|
||||
String logoFilePath = "src/logo_garage.png";
|
||||
managerGui = new ManagerGui(name, logoFilePath, garageManager.getServices());
|
||||
String name = "\033[3mGarage manager\033[0m\nPrestations"; //TODO résoudre en italique
|
||||
String logoFilePath = "src/logo_garage.png"; //TODO redimensionnement automatique
|
||||
managerGui = new ManagerGui(name, logoFilePath, garageManager.getServices(), garageManager); //TODO affichage sans redimmensionnement
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,19 +8,23 @@ import javax.swing.*;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ManagerGui extends JFrame{
|
||||
public class ManagerGui extends JFrame {
|
||||
GridLayout grid;
|
||||
JLabel Jname;
|
||||
JLabel Jlogo;
|
||||
ImageIcon logo;
|
||||
String buttonNameQuit = "Quit";
|
||||
String buttonNameBill = "Show bill";
|
||||
|
||||
|
||||
Vector<Row> prestations = new Vector<>();
|
||||
Vector<Integer> valuePrestations = new Vector<Integer>();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public ManagerGui(String name, String logoFilePath, String[] prestationsName){
|
||||
public ManagerGui(String name, String logoFilePath, String[] prestationsName, GarageManager garageManager){
|
||||
this.setSize(400,600);
|
||||
this.setLocation(600,200);
|
||||
this.setVisible(true);
|
||||
@ -39,7 +43,6 @@ public class ManagerGui extends JFrame{
|
||||
//Create rows for prestations
|
||||
for(String s : prestationsName){
|
||||
prestations.add(new Row(s));
|
||||
|
||||
}
|
||||
//add rows on the Jframe
|
||||
for(Row r : prestations){
|
||||
@ -48,16 +51,44 @@ public class ManagerGui extends JFrame{
|
||||
}
|
||||
|
||||
//Create and add button
|
||||
JButton ButtonBill = new JButton("Show bill");
|
||||
JButton ButtonQuit = new JButton("Quit");
|
||||
this.add(ButtonBill);
|
||||
this.add(ButtonQuit);
|
||||
|
||||
JButton buttonBill = new JButton(buttonNameBill);
|
||||
buttonBill.addActionListener(new ButtonListenerManager(valuePrestations, prestations, garageManager){
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e){
|
||||
//Get the value of each spinner
|
||||
for (int i = 0; i < prestations.size(); i++) {
|
||||
int value = (int)prestations.elementAt(i).spinner.getValue();
|
||||
for (int j = 0; j < value; j++) {
|
||||
valuePrestations.add(i);
|
||||
}
|
||||
System.out.println(value);
|
||||
}
|
||||
|
||||
new BillGui(garageManager.generateHTMLBill(valuePrestations));
|
||||
};
|
||||
});
|
||||
|
||||
JButton buttonQuit = new JButton(buttonNameQuit);
|
||||
buttonQuit.addActionListener(new ButtonListenerManager(this){
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e){
|
||||
Jf.dispose();
|
||||
};
|
||||
});
|
||||
|
||||
}
|
||||
this.add(buttonBill);
|
||||
this.add(buttonQuit);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -69,30 +100,32 @@ class Row {
|
||||
label = new JLabel(title);
|
||||
spinner = new JSpinner();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ButtonQuitListener implements ActionListener {
|
||||
JFrame Jf;
|
||||
/**
|
||||
*
|
||||
* @param Jf
|
||||
*/
|
||||
ButtonQuitListener(JFrame Jf){
|
||||
class ButtonListenerManager implements ActionListener {
|
||||
JFrame Jf;
|
||||
Vector<Integer> valuePrestations;
|
||||
Vector<Row> prestations;
|
||||
GarageManager garageManager;
|
||||
|
||||
ButtonListenerManager(Vector<Integer> valuePrestations, Vector<Row> prestations, GarageManager garageManager){
|
||||
this.valuePrestations = valuePrestations;
|
||||
this.prestations = prestations;
|
||||
this.garageManager = garageManager;
|
||||
};
|
||||
|
||||
ButtonListenerManager(JFrame Jf){
|
||||
this.Jf = Jf;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e){
|
||||
Jf.dispose();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e){};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user