1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
package fr.proagenda.ihm;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import fr.proagenda.application.Application;
import fr.proagenda.classes.Rdv;
import fr.proagenda.classes.User;
import fr.proagenda.redefineswing.RoundedCornerBorder;
import fr.proagenda.ihm.Cal;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.util.ArrayList;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.eclipse.wb.swing.FocusTraversalOnArray;
import javax.swing.JComboBox;
import javax.swing.JFrame;
@SuppressWarnings("serial")
public class IhmNouveauRdv extends JPanel {
private int font = Application.getRandomNumber();
private JTextField textField;
private JTextField textField_1;
private Cal fenCal;
private String date;
private int posX,posXTemp;
private int posY,posYTemp;
private int jour,mois,annee;
/**
* Create the panel.
*/
@SuppressWarnings("unchecked")
public IhmNouveauRdv(User user) {
this.setBounds(0, 0, 900, 500);
this.setBackground(Color.DARK_GRAY);
setLayout(null);
/*
* Croix de fermeture
*/
JButton btnNewButton = new JButton("");
btnNewButton.setIcon(new ImageIcon(IhmNouveauRdv.class.getResource("/fr/proagenda/img/close-window-32.png")));
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
((Window) getRootPane().getParent()).dispose();
}
});
btnNewButton.setBounds(877, 0, 23, 23);
add(btnNewButton);
/*
* Bouton retour
*/
JButton btnRetour_1 = new JButton("Retour");
btnRetour_1.setIcon(new ImageIcon(Ihm.class.getResource("/com/sun/javafx/scene/web/skin/Undo_16x16_JFX.png")));
btnRetour_1.setBounds(340, 11, 89, 23);
btnRetour_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
removeAll();
add(new IhmMenuPatron(user));
revalidate();
repaint();
}
});
add(btnRetour_1);
/*
* Image du côté
*/
JLabel label = new JLabel("");
label.setIcon(new ImageIcon(Ihm.class.getResource("/fr/proagenda/img/fond_"+font+".jpeg")));
label.setBounds(-5, 0, 320, 500);
add(label);
/*
* Titre
*/
JLabel lblAjouterUnRendezvous = new JLabel("Ajout d'un rendez-vous");
lblAjouterUnRendezvous.setForeground(Color.LIGHT_GRAY);
lblAjouterUnRendezvous.setFont(new Font("Tahoma", Font.PLAIN, 50));
lblAjouterUnRendezvous.setBounds(350, 45, 517, 84);
add(lblAjouterUnRendezvous);
/*
* Separator
*/
JSeparator separator = new JSeparator();
separator.setBounds(350, 127, 517, 2);
add(separator);
/*
* label technicien
*/
JLabel lblNewLabel = new JLabel("Technicien :");
lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblNewLabel.setForeground(Color.LIGHT_GRAY);
lblNewLabel.setBounds(383, 182, 78, 14);
add(lblNewLabel);
/*
* Label adresse
*/
JLabel lblAdresse = new JLabel("Adresse :");
lblAdresse.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblAdresse.setForeground(Color.LIGHT_GRAY);
lblAdresse.setBounds(399, 230, 62, 14);
add(lblAdresse);
/*
* Saisie adresse
*/
textField = new JTextField() {
@Override protected void paintComponent(Graphics g) {
if (!isOpaque() && getBorder() instanceof RoundedCornerBorder) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setPaint(getBackground());
g2.fill(((RoundedCornerBorder) getBorder()).getBorderShape(
0, 0, getWidth() - 1, getHeight() - 1));
g2.dispose();
}
super.paintComponent(g);
}
@Override public void updateUI() {
super.updateUI();
setOpaque(false);
setBorder(new RoundedCornerBorder());
}
};
textField.setBounds(505, 229, 214, 20);
add(textField);
textField.setColumns(10);
JLabel lblNewLabel_1 = new JLabel("Date et Heure :");
lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblNewLabel_1.setForeground(Color.LIGHT_GRAY);
lblNewLabel_1.setBounds(358, 275, 103, 14);
add(lblNewLabel_1);
textField_1 = new JTextField() {
@Override protected void paintComponent(Graphics g) {
if (!isOpaque() && getBorder() instanceof RoundedCornerBorder) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setPaint(getBackground());
g2.fill(((RoundedCornerBorder) getBorder()).getBorderShape(
0, 0, getWidth() - 1, getHeight() - 1));
g2.dispose();
}
super.paintComponent(g);
}
@Override public void updateUI() {
super.updateUI();
setOpaque(false);
setBorder(new RoundedCornerBorder());
}
};
textField_1.setColumns(10);
textField_1.setBounds(505, 274, 214, 20);
add(textField_1);
JLabel label_1 = new JLabel("YYYY-MM-JJ espace hh:mm:ss");
label_1.setForeground(Color.LIGHT_GRAY);
label_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
label_1.setBounds(505, 305, 214, 23);
add(label_1);
@SuppressWarnings("rawtypes")
JComboBox comboBox = new JComboBox();
comboBox.setBounds(505, 181, 214, 20);
add(comboBox);
ArrayList<User> users = Application.ihmtoDAOGetNomPrenomUSER();
for(int i = 0; i < users.size(); i++ ) {
comboBox.addItem(users.get(i).getNom()+" "+users.get(i).getPrenom());
}
JButton btnValider = new JButton("Valider");
btnValider.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Rdv rendezVous = new Rdv(textField_1.getText(), textField.getText(), Application.retIDCompteWithName((String) comboBox.getSelectedItem(), users));
Application.saveRdvApp(rendezVous);
removeAll();
add(new IhmMenuPatron(user));
revalidate();
repaint();
}
});
btnValider.setIcon(new ImageIcon(IhmNouveauRdv.class.getResource("/fr/proagenda/img/check-mark-12-16.png")));
btnValider.setBounds(572, 362, 89, 23);
add(btnValider);
posXTemp = this.getLocation().x;
posYTemp = this.getLocation().y;
JButton btnCal = new JButton("");
btnCal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
IhmNewCalendar f = new IhmNewCalendar();
f.setLocation(JFrame.getWindows()[JFrame.getWindows().length-2].getLocation().x+10,JFrame.getWindows()[JFrame.getWindows().length-2].getLocation().y+100);
f.setVisible(true);
}
});
btnCal.setIcon(new ImageIcon(IhmNouveauRdv.class.getResource("/fr/proagenda/img/tear-of-calendar-16.png")));
btnCal.setBounds(738, 273, 23, 23);
add(btnCal);
}
public void setDateNewRDV(String date) {
this.date=date;
}
} |
Partager