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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
| package client;
import hw.AmortissementAvecEtatRemote;
import hw.AmortissementRemote;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.swing.DefaultListModel;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class Amortissement extends JApplet {
/**
*
*/
private static final long serialVersionUID = 1L;
public Amortissement() {
}
private JTextField textField;
private JTextField textField_4;
private JTextField Date;
private JTextField annee;
private JTextField Duree;
private JTable table;
// Initialisation de l'applet
public void init(){
try {
jbinit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**
* Create the applet.
*/
public void jbinit() throws Exception{
getContentPane().setLayout(null);
JLabel lblNewLabel = new JLabel("Votre Tableau d'amortissement");
lblNewLabel.setFont(new Font("Arial Black", Font.BOLD, 14));
lblNewLabel.setBounds(0, 0, 306, 14);
getContentPane().add(lblNewLabel);
JLabel lblretrouverLeDtail = new JLabel("<html>Retrouver <bold> le d\u00E9tail de vos remboursements sur toutes la dur\u00E9e de vos pr\u00EAs immobilier .</bold>Un \u00E9cch\u00E9ancier annuel et mensuel qui met en \u00E9vidence l'\u00E9volutiondu montantdes int\u00E9r\u00EAts de votre pr\u00EAt immobilier et la part de capital amorti.</html>");
lblretrouverLeDtail.setBounds(0, 25, 471, 59);
getContentPane().add(lblretrouverLeDtail);
JLabel lblsommeEmprunt = new JLabel("*Somme emprunt\u00E9");
lblsommeEmprunt.setFont(new Font("Tahoma", Font.BOLD, 11));
lblsommeEmprunt.setBounds(88, 88, 120, 14);
getContentPane().add(lblsommeEmprunt);
JLabel lblDateDeDbut = new JLabel("Date de d\u00E9but de remboursement");
lblDateDeDbut.setFont(new Font("Tahoma", Font.BOLD, 11));
lblDateDeDbut.setBounds(20, 110, 198, 14);
getContentPane().add(lblDateDeDbut);
JLabel lblDureDuPrt = new JLabel("Dur\u00E9e du pr\u00EAt");
lblDureDuPrt.setFont(new Font("Tahoma", Font.BOLD, 11));
lblDureDuPrt.setBounds(140, 157, 78, 14);
getContentPane().add(lblDureDuPrt);
JLabel lblTauxAnnuel = new JLabel("Taux annuel");
lblTauxAnnuel.setFont(new Font("Tahoma", Font.BOLD, 11));
lblTauxAnnuel.setBounds(140, 182, 78, 14);
getContentPane().add(lblTauxAnnuel);
final JTextField Somme = new JTextField();
Somme.setBounds(228, 88, 140, 14);
getContentPane().add(Somme);
Somme.setColumns(10);
final JTextField Taux = new JTextField();
Taux.setColumns(10);
Taux.setBounds(228, 182, 140, 14);
getContentPane().add(Taux);
JButton btnNewButton = new JButton("Envoyer");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(Somme.getText().length() != 0 && Date.getText().length() != 0 && annee.getText().length() != 0 && Duree.getText().length() != 0 && Taux.getText().length() != 0){
String somme = Somme.getText() ;
int s = Integer.parseInt(somme);
String date = Date.getText() ;
int datee = Integer.parseInt(date);
String Annee = annee.getText() ;
int a = Integer.parseInt(Annee);
String duree = Duree.getText() ;
int d = Integer.parseInt(duree);
String taux = Taux.getText() ;
int t = Integer.parseInt(taux);
envoie_donnee(s,datee,a,d,t);
}
}
});
btnNewButton.setBackground(new Color(255, 165, 0));
btnNewButton.setForeground(Color.WHITE);
btnNewButton.setBounds(238, 207, 89, 23);
getContentPane().add(btnNewButton);
JLabel lblNewLabel_1 = new JLabel("\u20AC");
lblNewLabel_1.setBounds(374, 88, 46, 14);
getContentPane().add(lblNewLabel_1);
JLabel lblAns = new JLabel("ans");
lblAns.setBounds(374, 157, 46, 14);
getContentPane().add(lblAns);
JLabel label = new JLabel("%");
label.setBounds(374, 182, 46, 14);
getContentPane().add(label);
Date = new JTextField();
Date.setBounds(228, 107, 140, 14);
getContentPane().add(Date);
Date.setColumns(10);
annee = new JTextField();
annee.setColumns(10);
annee.setBounds(228, 132, 140, 14);
getContentPane().add(annee);
Duree = new JTextField();
Duree.setColumns(10);
Duree.setBounds(228, 157, 140, 14);
getContentPane().add(Duree);
JButton btnRelancer = new JButton("relancer");
btnRelancer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
btnRelancer.setForeground(Color.WHITE);
btnRelancer.setBackground(new Color(255, 165, 0));
btnRelancer.setBounds(129, 207, 89, 23);
getContentPane().add(btnRelancer);
JButton btnConserver = new JButton("conserver");
btnConserver.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(Somme.getText().length() != 0 && Date.getText().length() != 0 && annee.getText().length() != 0 && Duree.getText().length() != 0 && Taux.getText().length() != 0){
String somme = Somme.getText() ;
int s = Integer.parseInt(somme);
String date = Date.getText() ;
int datee = Integer.parseInt(date);
String Annee = annee.getText() ;
int a = Integer.parseInt(Annee);
String duree = Duree.getText() ;
int d = Integer.parseInt(duree);
String taux = Taux.getText() ;
int t = Integer.parseInt(taux);
conserver(s,datee,a,d,t);
}
}
});
btnConserver.setForeground(Color.WHITE);
btnConserver.setBackground(new Color(255, 165, 0));
btnConserver.setBounds(337, 207, 89, 23);
getContentPane().add(btnConserver);
}
// Connexion au serveur et lookup du bean
private static AmortissementRemote lookupRemoteStatelessAmortissement() throws NamingException {
AmortissementRemote remote=null;
try {
Properties jndiProps = new Properties();
jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
InitialContext ctx = new InitialContext(jndiProps);
remote = (AmortissementRemote) ctx.lookup("ejb:/AmortissementEJB/Amortissement!hw.AmortissementRemote");
} catch (Exception e) {
e.printStackTrace();
}
return remote;
}
// Connexion au serveur et lookup du bean
private static AmortissementAvecEtatRemote lookupRemoteStatelessAvecEtatAmortissement() throws NamingException {
AmortissementAvecEtatRemote remote=null;
try {
Properties jndiProps = new Properties();
jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
InitialContext ctx = new InitialContext(jndiProps);
remote = (AmortissementAvecEtatRemote) ctx.lookup("ejb:/AmortissementEJB/AmortissementAvecEtat!hw.AmortissementAvecEtatRemote");
} catch (Exception e) {
e.printStackTrace();
}
return remote;
}
public void conserver(int Somme,int Date,int annee,int duree,int taux) {
// TODO Auto-generated method stub
// Appel du stateless bean
AmortissementAvecEtatRemote Amortissement;
try {
Amortissement = lookupRemoteStatelessAvecEtatAmortissement();
Amortissement.calculerAmortissement( Somme, Date, annee, duree, taux);
Object[][] donnee = Amortissement.calculerAmortissement(Somme, Date, annee, duree, taux);
String[] entetes = {"mois", "annee", "mensualite", "amortissement", "interet"};
JTable table = new JTable( donnee,entetes);
table.size();
table.setBounds(116, 240, 300,300);
getContentPane().add(table);
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void afficher_amortissement() {
// TODO Auto-generated method stub
// Appel du stateless bean
AmortissementAvecEtatRemote Amortissement;
try {
Amortissement = lookupRemoteStatelessAvecEtatAmortissement();
ArrayList<Object[][]> amortissement = Amortissement.getBuffer();
String[] entetes = {"mois", "annee", "mensualite", "amortissement", "interet"};
for(Object[][] tableau : amortissement ) {
JTable table = new JTable( tableau,entetes);
table.setBounds(116, 240, 300,300);
getContentPane().add(new JScrollPane(table), BorderLayout.SOUTH);
}
}
catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void envoie_donnee(int Somme,int Date,int annee,int duree,int taux) {
// TODO Auto-generated method stub
// Appel du stateless bean
AmortissementRemote Amortissement;
try {
Amortissement = lookupRemoteStatelessAmortissement();
Object[][] donnee = Amortissement.calculerAmortissement(Somme, Date, annee, duree, taux);
String[] entetes = {"mois", "annee", "mensualite", "amortissement", "interet"};
JTable table = new JTable( donnee,entetes);
table.size();
// table.setBounds(116, 240, 300,300);
getContentPane().add(new JScrollPane(table), BorderLayout.SOUTH);
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
Partager