-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcenterPanel.java
More file actions
1274 lines (1190 loc) · 52.1 KB
/
centerPanel.java
File metadata and controls
1274 lines (1190 loc) · 52.1 KB
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import javax.swing.*;
public abstract class centerPanel {
protected ResultSet resultSetFacade;
protected int yPos=1;
protected JPanel returnPanel = new JPanel();
protected Font smallFont=new Font("Serif",Font.BOLD,20);
protected Font largeFont=new Font("Serif",Font.BOLD,25);
protected GridBagConstraints constraintsToManipulate=new GridBagConstraints();
// Gets the connection from the FactoryFacade and passes the info to createInstance()
protected abstract void getConInfo();
// Uses the connection info and ArrayList to create the panels inside the centerPanel
//adds a scrollPane to the returnPanel
protected JScrollPane addScrollPane() {
JScrollPane pane=new JScrollPane(returnPanel,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
return pane;
}
}// End of centerPanel interface
//TODO START OF BUDGET
class BudgetCenter extends centerPanel {
private ArrayList<BudgetInstance> save = new ArrayList<BudgetInstance>();
private ArrayList<BudgetInstance> variable = new ArrayList<BudgetInstance>();
private ArrayList<BudgetInstance> fixed = new ArrayList<BudgetInstance>();
private BudgetFacade individualFac;
private ResultSet personelDataSet;
private Color bluePanelColor=new Color(153,204,255);
private Color redPanelColor=new Color(255,153,153);
private Color greenPanelColor=new Color(153,255,153);
private double savingSpent,savingTotal,fixedSpent,fixedTotal,variableSpent,variableTotal;
private DecimalFormat decimalFormat=new DecimalFormat("###,###.##");
private String income,expenses;
private BudgetInstance selectedPanel=null;
private JPopupMenu popupMenu;
private JMenuItem withdraw,setTitle,setAllocatedMoney,remove;
private ButtonListener buttonListener=new ButtonListener();
private int dataBaseIndex=1;
private String projectedExpenses;
private JLabel ratio;
// calls other methods that will manipulate returnPanel
public JScrollPane makeCenterPanel(FrameFacade individualFac) {
this.individualFac = (BudgetFacade) individualFac;
createPopUp();
getConInfo();
createSmallerComponent();
yPos=1;
return addScrollPane();
}
// Creates a popUpMenu that will show whenever the editButton is pressed on one of the panels
protected void createPopUp() {
popupMenu=new JPopupMenu();
withdraw=createMenuItems("withdraw",popupMenu);
setTitle=createMenuItems("Set Title",popupMenu);
setAllocatedMoney=createMenuItems("Set Allocated Money ",popupMenu);
remove=createMenuItems("remove",popupMenu);
}
private JMenuItem createMenuItems(String label,JPopupMenu popupMenu){
JMenuItem menuItem =new JMenuItem(label);
popupMenu.add(menuItem);
menuItem.addActionListener(buttonListener);
return menuItem;
}
// Gets the connection from the FactoryFac and passes the info to createInstance()
protected void getConInfo() {
personelDataSet=individualFac.getConnectionInfo("SELECT * From personel_data");
resultSetFacade=individualFac.getConnectionInfo("SELECT * From envelope");
setConInfo();
getDefaultMoneyValues();
addDefaultInstance();
}
//Sets the data from the resultSet to the class variables
private void setConInfo(){
try {
while(resultSetFacade.next()){
//double moneySpent, double totalMoney, String expenseType, String label,int dataBaseIndex
BudgetInstance instance=new BudgetInstance(resultSetFacade.getDouble(3),resultSetFacade.getDouble(4),resultSetFacade.getString(5),resultSetFacade.getString(2),dataBaseIndex);
addEnvelopeInstance(instance);
dataBaseIndex++;
}
personelDataSet.next();
income=decimalFormat.format(personelDataSet.getDouble(4));
expenses=decimalFormat.format(personelDataSet.getDouble(5));
projectedExpenses=decimalFormat.format(personelDataSet.getDouble(7));
} catch (SQLException e) {
e.printStackTrace();
}
}
//Gets the moneyRatios for the saving,fixed,and variable
protected void getDefaultMoneyValues(){
for(BudgetInstance instance:save){
savingSpent+=instance.getMoneySpent();
savingTotal+=instance.getTotalMoney();
}
for(BudgetInstance instance:variable){
variableSpent+=instance.getMoneySpent();
variableTotal+=instance.getTotalMoney();
}
for(BudgetInstance instance:fixed){
fixedSpent+=instance.getMoneySpent();
fixedTotal+=instance.getTotalMoney();
}
}
//Adds instances of the BudgetTemplateTabs
protected void addDefaultInstance(){
save.add(0,new BudgetInstance(savingSpent,savingTotal,"Save","Savings : ",0));
fixed.add(0,new BudgetInstance(fixedSpent,fixedTotal,"Fixed","Fixed : ",0));
variable.add(0,new BudgetInstance(variableSpent,variableTotal,"Variable","Variable:",0));
}
//Adds instances of the Envelopes
protected void addEnvelopeInstance(BudgetInstance instance) {
String type=instance.getExpenseType();
if(type.equals("Save")){
save.add(instance);
}else if(type.equals("Variable")){
variable.add(instance);
}else if(type.equals("Fixed")){
fixed.add(instance);
}
}
// Uses the connection info and ArrayList to create the panels inside the centerPanel
protected void createSmallerComponent() {
returnPanel.setLayout(new GridBagLayout());
createIncomeComponents(new Color(102, 178, 255));
makeDefaults(fixed.get(0),bluePanelColor);
for (int x = 1; x < fixed.size(); x++) {
makeEnvelopes(fixed.get(x),bluePanelColor);
}
makeDefaults(variable.get(0),redPanelColor);
for (int x = 1; x < variable.size(); x++) {
makeEnvelopes(variable.get(x),redPanelColor);
}
makeDefaults(save.get(0),greenPanelColor);
for (int x = 1; x < save.size(); x++) {
makeEnvelopes(save.get(x),greenPanelColor);
}
}
// Creates the envelopes that are a part of the Fixed type
protected void makeEnvelopes(BudgetInstance BInstance,Color color) {
//initialize Envelope Panels
JPanel envelope=new JPanel();
envelope.setLayout(new GridBagLayout());
envelope.setBackground(color);
//Creates components
JButton edit=FactoryFacade.makeIconButtons("C:/Users/Kyle Peters/Documents/picturesForFinance/editButton.png", color,50,50);
BInstance.setButton(edit);
edit.addActionListener(buttonListener);
JLabel title=FactoryFacade.makeLabels(BInstance.getLabel(), smallFont);
JLabel moneySpent=FactoryFacade.makeLabels("Money Spent : "+Double.toString(BInstance.getMoneySpent()), smallFont);
JSlider moneySlider=FactoryFacade.makeSliders(0,(int)BInstance.getTotalMoney(),(int)BInstance.getMoneySpent(),color);
JLabel totalMoney=FactoryFacade.makeLabels(Double.toString(BInstance.getTotalMoney()), smallFont);
JLabel MinimumLabel=FactoryFacade.makeLabels(Integer.toString(0), smallFont);
setEnvelopesLayout(constraintsToManipulate,envelope,edit,title,moneySpent,totalMoney,MinimumLabel,moneySlider);
}
//Adds the components of makeEnvelope to returnPanel
protected void setEnvelopesLayout(GridBagConstraints c,JPanel panel,JButton edit,JLabel title,JLabel moneySpent,JLabel totalMoney,JLabel MinimumLabel,JSlider moneySlider){
FactoryFacade.addWithGridBag(1, 1, 1, 3, 50, 50, GridBagConstraints.BOTH, GridBagConstraints.EAST, c, panel, edit);
FactoryFacade.addWithGridBag(2, 1, 3, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, title);
FactoryFacade.addWithGridBag(2, 2, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.EAST, c, panel, MinimumLabel);
FactoryFacade.addWithGridBag(3, 2, 1, 1, 50, 50, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, panel, moneySlider);
FactoryFacade.addWithGridBag(4, 2, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.WEST, c, panel, totalMoney);
FactoryFacade.addWithGridBag(2, 3, 3, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, moneySpent);
panel.setBorder(BorderFactory.createLineBorder(Color.BLACK,2));
FactoryFacade.addWithGridBag(1,yPos,1,1,50,50, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, returnPanel, panel);
yPos++;
}
// Creates the default envelope for Fixed
protected void makeDefaults(BudgetInstance BInstance,Color color) {
JPanel defaultPanels=new JPanel();
defaultPanels.setLayout(new GridBagLayout());
defaultPanels.setBackground(color);
JButton add=FactoryFacade.makeIconButtons("C:/Users/Kyle Peters/Documents/picturesForFinance/addButton.png", color,50,50);
BInstance.setButton(add);
add.addActionListener(buttonListener);
JLabel title=FactoryFacade.makeLabels(BInstance.getLabel(), largeFont);
JLabel moneyRatio=FactoryFacade.makeLabels("$"+BInstance.getMoneySpent()+" / $"+BInstance.getTotalMoney(), largeFont);
setDefaultsLayout(constraintsToManipulate,defaultPanels,add,title,moneyRatio);
}
protected void setDefaultsLayout(GridBagConstraints c,JPanel defaultPanels,JButton add,JLabel title,JLabel moneyRatio){
//initialize defaultPanel
FactoryFacade.addWithGridBag(1, 1, 1, 1, 50, 50, GridBagConstraints.BOTH, GridBagConstraints.WEST, c, defaultPanels, add);
FactoryFacade.addWithGridBag(2, 1, 1, 1, 100, 100, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, defaultPanels, title);
FactoryFacade.addWithGridBag(3, 1, 1, 1, 100, 100, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, defaultPanels, moneyRatio);
defaultPanels.setBorder(BorderFactory.createLineBorder(Color.BLACK,2));
//create Components
FactoryFacade.addWithGridBag(1, yPos, 1, 1, 50, 50, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, returnPanel, defaultPanels);
yPos++;
}
//Creates the IncomePanelComponents
private void createIncomeComponents(Color color){
JPanel panel=new JPanel();
panel.setLayout(new GridBagLayout());
panel.setBackground(color);
JButton setIncome=FactoryFacade.makeTextButtons("Set Income", new Color(51, 153, 255), Color.BLACK,largeFont);
setIncome.setBorderPainted(true);
ratio=FactoryFacade.makeLabels("Income: $"+income+" | "+"Expenses: $"+expenses+" |Projected Expenses : $"+projectedExpenses,largeFont);
createIncomePanel(constraintsToManipulate,panel,setIncome,ratio);
addListenerToIncome(setIncome,ratio);
}
//Adds a listener to the setIncomeButton
private void addListenerToIncome(JButton setIncome,JLabel incomeLabel){
setIncome.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
String newIncome=JOptionPane.showInputDialog(null,"Type in your new Income");
if(newIncome==null)return;
newIncome=newIncome.replaceAll(",", "");
updateLabels(newIncome);
updateDataBase(newIncome);
if(individualFac.checkIncomeVsExpense(personelDataSet)){
JOptionPane.showMessageDialog(null, "Your expenses are more than your income, try balancing your budget,");
}
}
//Sets the text on the labels
private void updateLabels(String newIncome){
income=decimalFormat.format(Double.parseDouble(newIncome));
incomeLabel.setText("Income: $"+income+" | "+"Expenses: $"+expenses+" |Projected Expenses : $"+projectedExpenses);
}
//updates the dataBase
private void updateDataBase(String newIncome){
try {
personelDataSet.absolute(1);
personelDataSet.updateDouble(4, Double.parseDouble(newIncome));
personelDataSet.updateRow();
} catch (SQLException e1) {}
}
});
}
//Creates the IncomePanel
private void createIncomePanel(GridBagConstraints c,JPanel panel,JButton setIncome, JLabel ratio){
FactoryFacade.addWithGridBag(1, 1, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.EAST, c, panel, setIncome);
c.insets=new Insets(0,50,0,0);
FactoryFacade.addWithGridBag(2, 1, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.WEST, c, panel, ratio);
panel.setBorder(BorderFactory.createLineBorder(Color.BLACK,2));
//create Components
c.insets=new Insets(0,0,0,0);
FactoryFacade.addWithGridBag(1, yPos, 1, 1, 50, 50, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, returnPanel, panel);
yPos++;
}
//Listens to the edit buttons on the envelopes and add buttons on the defaults
//TODO Budget ActionListener
class ButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
//If source is a default have checkDefaults return true so checkEnvelopes is not called
if(checkDefaults(e)){
}else{
checkEnvelopes(e);
}
checkPopUp(e);
}
//Checks if the default panels threw the action
private boolean checkDefaults(ActionEvent e){
if(e.getSource()==fixed.get(0).getButton()){
insertFixed();
createDefaultFrame();
return true;
}else if(e.getSource()==variable.get(0).getButton()){
insertVariable();
createDefaultFrame();
return true;
}else if(e.getSource()==save.get(0).getButton()){
insertSave();
createDefaultFrame();
return true;
}
return false;
}
//Inserts specific values for Fixed
private void insertFixed(){
try {
resultSetFacade.moveToInsertRow();
resultSetFacade.updateString(5,"Fixed");
resultSetFacade.updateDouble(3,0);
} catch (SQLException e) {
e.printStackTrace();
}
}
//Inserts specific values for Fixed
private void insertVariable(){
try {
resultSetFacade.moveToInsertRow();
resultSetFacade.updateString(5,"Variable");
resultSetFacade.updateDouble(3,0);
} catch (SQLException e) {
e.printStackTrace();
}
}
//Inserts specific values for Save
private void insertSave(){
try {
resultSetFacade.moveToInsertRow();
resultSetFacade.updateString(5,"Save");
resultSetFacade.updateDouble(3,0);
} catch (SQLException e) {
e.printStackTrace();
}
}
//Checks if the envelope panels threw the action
private void checkEnvelopes(ActionEvent e){
for (int x = 1; x < fixed.size(); x++) {
if(e.getSource()==fixed.get(x).getButton()){
popupMenu.show(fixed.get(x).getButton(), 70, 0);
selectedPanel=fixed.get(x);
return;
}
}
for (int x = 1; x < variable.size(); x++) {
if(e.getSource()==variable.get(x).getButton()){
popupMenu.show(variable.get(x).getButton(), 70, 0);
selectedPanel=variable.get(x);
return;
}
}
for (int x = 1; x < save.size(); x++) {
if(e.getSource()==save.get(x).getButton()){
popupMenu.show(save.get(x).getButton(), 70, 0);
selectedPanel=save.get(x);
return;
}
}
}
//Creates the Frame for the defaults
private void createDefaultFrame(){
JFrame frame=new JFrame();
frame.setAlwaysOnTop(true);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(400, 300);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setTitle("Add Envelopse");
addWindowListener(frame);
frame.add(createDefaultComponents(frame));
}
//creates the Frame components
private JPanel createDefaultComponents(JFrame frame){
JLabel nameLabel=FactoryFacade.makeLabels(" Title : ", smallFont);
JTextField nameField=new JTextField(10);
nameField.setBorder(BorderFactory.createLineBorder(Color.BLACK));
JLabel moneyLabel=FactoryFacade.makeLabels("Allocated Money : ", smallFont);
JTextField moneyField=new JTextField(10);
moneyField.setBorder(BorderFactory.createLineBorder(Color.BLACK));
JButton continueButton=FactoryFacade.makeTextButtons("OK", nameLabel.getBackground(), Color.BLACK, smallFont);
addDefaultActionListener(continueButton,frame,nameField,moneyField);
return createDefaultLayout(constraintsToManipulate,nameLabel, nameField, moneyLabel, moneyField, continueButton);
}
//Adds the components to the frame
private JPanel createDefaultLayout(GridBagConstraints c,JLabel nameLabel, JTextField nameField,JLabel moneyLabel,JTextField moneyField,JButton continueButton){
JPanel panel=new JPanel();
panel.setLayout(new GridBagLayout());
FactoryFacade.addWithGridBag(1, 1, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, nameLabel);
FactoryFacade.addWithGridBag(2, 1, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, nameField);
FactoryFacade.addWithGridBag(1, 2, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, moneyLabel);
FactoryFacade.addWithGridBag(2, 2, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, moneyField);
FactoryFacade.addWithGridBag(2, 3, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.EAST, c, panel, continueButton);
return panel;
}
//Adds the actionListener to the continueButton
private void addDefaultActionListener(JButton continueButton,JFrame frame,JTextField nameField,JTextField moneyField){
continueButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try{
//Gets user input and gets rid of frame
frame.dispose();
String title=nameField.getText();
String money=moneyField.getText();
money=money.replaceAll(",", "");
double expense=Double.parseDouble(money);
//updates program with new information
resultSetFacade.updateString(2, title);
resultSetFacade.updateDouble(4, expense);
resultSetFacade.insertRow();
personelDataSet.updateDouble(7, personelDataSet.getDouble(7)+expense); personelDataSet.updateRow();
startUp.createBudgetFrame();
}catch(NumberFormatException|SQLException e){
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Unable to complete transaction, you didn't enter a number","Error",JOptionPane.ERROR_MESSAGE);
}
selectedPanel=null;
}
});
}
//Adds a windowListener that disposes when someone clicks on something other than the frame
private void addWindowListener(JFrame frame){
frame.addWindowListener(new WindowAdapter(){
public void windowDeactivated(WindowEvent arg0) {
frame.dispose();
}
});
}
//checks which JMenuItem was clicked
private void checkPopUp(ActionEvent e) {
if(e.getSource()==withdraw){
actOnWithdraw();
}else if(e.getSource()==setTitle){
actOnSetTitle();
}else if(e.getSource()==setAllocatedMoney){
actOnSetAllocatedMoney();
}else if(e.getSource()==remove){
actOnRemove();
}
}
//Does the withdraw action by creating a JFrame which waits for user input
private void actOnWithdraw(){
JFrame frame=new JFrame();
frame.setAlwaysOnTop(true);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setTitle("Withdraw");
addWindowListener(frame);
frame.add(createEnvelopeComponents(frame));
}
//creates the Frame components
private JPanel createEnvelopeComponents(JFrame frame){
JLabel nameLabel=FactoryFacade.makeLabels(" Amount : ", smallFont);
JTextField nameField=new JTextField(10);
nameField.setBorder(BorderFactory.createLineBorder(Color.BLACK));
JLabel descriptionLabel=FactoryFacade.makeLabels("Description : ", smallFont);
JTextArea descriptionArea=new JTextArea(2,10);
descriptionArea.setBorder(BorderFactory.createLineBorder(Color.BLACK));
descriptionArea.setLineWrap(true);
descriptionArea.setWrapStyleWord(true);
JButton continueButton=FactoryFacade.makeTextButtons("OK", nameLabel.getBackground(), Color.BLACK, smallFont);
addEnvelopeActionListener(continueButton,frame,nameField,descriptionArea);
return createEnvelopeLayout(constraintsToManipulate,nameLabel, nameField, descriptionLabel, descriptionArea, continueButton);
}
//Adds the components to the frame
private JPanel createEnvelopeLayout(GridBagConstraints c,JLabel nameLabel, JTextField nameField,JLabel descLabel,JTextArea descArea,JButton continueButton){
JPanel panel=new JPanel();
panel.setLayout(new GridBagLayout());
FactoryFacade.addWithGridBag(1, 1, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, nameLabel);
FactoryFacade.addWithGridBag(2, 1, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, nameField);
FactoryFacade.addWithGridBag(1, 2, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, descLabel);
FactoryFacade.addWithGridBag(2, 2, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, descArea);
FactoryFacade.addWithGridBag(2, 3, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.EAST, c, panel, continueButton);
return panel;
}
//Adds the actionListener to the continueButton
private void addEnvelopeActionListener(JButton continueButton,JFrame frame,JTextField field,JTextArea area){
continueButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try{
//Gets user input and gets rid of frame
frame.dispose();
String expenseString=field.getText();
expenseString=expenseString.replaceAll(",", "");
double expense=Double.parseDouble(expenseString);
String description=area.getText();
//updates program with new information
boolean okForTransaction=updateDataBaseWithdraw(expense);
createReconciliation(description,expense,okForTransaction);
}catch(NumberFormatException e){
JOptionPane.showMessageDialog(null, "Unable to complete transaction, you didn't enter a number","Error",JOptionPane.ERROR_MESSAGE);
}
selectedPanel=null;
}
});
}
//Adds a row to the Reconciliation Table
private void createReconciliation(String description,double expense,boolean okForTransaction){
ResultSet reconciliation=individualFac.getConnectionInfo("SELECT * from reconciliation");
try {
if(okForTransaction){
reconciliation.moveToInsertRow();
reconciliation.updateString(2, selectedPanel.getLabel());
reconciliation.updateString(3, description);
reconciliation.updateDouble(4, expense);
reconciliation.updateString(5, selectedPanel.getExpenseType());
reconciliation.insertRow();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
//Updates the database with the values from the actOnWithdraw method
private boolean updateDataBaseWithdraw(double expense){
try {
resultSetFacade.absolute(selectedPanel.getDataBaseIndex());
double moneyDifference=resultSetFacade.getDouble(4)-resultSetFacade.getDouble(3)-expense;
if(moneyDifference>=0){
resultSetFacade.updateDouble(3,resultSetFacade.getDouble(3)+expense);
resultSetFacade.updateRow();
personelDataSet.absolute(1);
personelDataSet.updateDouble(5, personelDataSet.getDouble(5)+expense);
personelDataSet.updateRow();
startUp.createBudgetFrame();
return true;
}else{
String formatDif=decimalFormat.format(Math.abs(moneyDifference));
JOptionPane.showMessageDialog(null, "Unable to complete transaction, you are $"+formatDif+" over budget","Error",JOptionPane.ERROR_MESSAGE);
}
} catch (SQLException e) {e.printStackTrace();}
return false;
}
//Does the setTitle action
private void actOnSetTitle(){
String title=JOptionPane.showInputDialog(null, "Type in the new title");
if(title==null){
return;
}else if(title.equals("")){
JOptionPane.showMessageDialog(null, "You didn't enter anything");
return;
}
try {
resultSetFacade.absolute(selectedPanel.getDataBaseIndex());
updateDataBaseTitle(title);
startUp.createBudgetFrame();
} catch (SQLException e) {
e.printStackTrace();
}
}
//Updates the database with the values from the actOnSetTitle method
private void updateDataBaseTitle(String title)throws SQLException{
ResultSet reconciliationSet=individualFac.getConnectionInfo("SELECT * from reconciliation where label='"+resultSetFacade.getString(2)+"'");
while(reconciliationSet.next()){
reconciliationSet.updateString(2, title);
reconciliationSet.updateRow();
}
resultSetFacade.updateString(2, title);
resultSetFacade.updateRow();
}
//Does the setAllocatedMoney action
private void actOnSetAllocatedMoney(){
try{
String allocatedMoneyString=JOptionPane.showInputDialog(null, "Type in the amount of allocated Money");
allocatedMoneyString.replaceAll(",", "");
double allocatedMoneyDouble=0;
allocatedMoneyDouble=Double.parseDouble(allocatedMoneyString);
if(checkForUpdate(allocatedMoneyDouble)) updateDataBaseMoney(allocatedMoneyDouble);
} catch (SQLException e) {
e.printStackTrace();
}catch(NumberFormatException e){
JOptionPane.showMessageDialog(null, "You didn't enter a number","Error",JOptionPane.ERROR_MESSAGE); return;
}catch(NullPointerException e){
return;
}
}
//Checks if it is clear to update the dataBase
private boolean checkForUpdate(double allocatedMoneyDouble) throws SQLException{
resultSetFacade.absolute(selectedPanel.getDataBaseIndex());
if(allocatedMoneyDouble>=resultSetFacade.getDouble(3)){
//Checks if income is greater than total expenses
if(personelDataSet.getDouble(4)>=personelDataSet.getDouble(7)+allocatedMoneyDouble-resultSetFacade.getDouble(4)){
return true;
}else{
JOptionPane.showMessageDialog(null, "The projected expenses from your envelopes are more than your income");
}
}else{
JOptionPane.showMessageDialog(null, "The money spent is more than the money allocated by $"+decimalFormat.format(allocatedMoneyDouble)+", delete some bank transactions or allocate more money");
}
return false;
}
//Updates the database with the values from the actOnSetAllocatedMoney method
private void updateDataBaseMoney(double allocatedMoney)throws SQLException{
personelDataSet.absolute(1);
personelDataSet.updateDouble(7, personelDataSet.getDouble(7)+allocatedMoney-resultSetFacade.getDouble(4));
personelDataSet.updateRow();
resultSetFacade.absolute(selectedPanel.getDataBaseIndex());
resultSetFacade.updateDouble(4, allocatedMoney);
resultSetFacade.updateRow();
startUp.createBudgetFrame();
}
//Does the remove action
private void actOnRemove(){
int hitYes=JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this envelope, this will also delete the transactions associated with it","Confirmation",JOptionPane.INFORMATION_MESSAGE);
if(hitYes==0){
try {
updateDataBaseRemove();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
//updates the dataBaseTable for actOnRemove
private void updateDataBaseRemove() throws SQLException{
resultSetFacade.absolute(selectedPanel.getDataBaseIndex());
//Updates Reconciliation
ResultSet recSet=individualFac.getConnectionInfo("SELECT * from reconciliation where label='"+resultSetFacade.getString(2)+"'");
while(recSet.next()){
recSet.deleteRow();
}
//Updates personel_data
personelDataSet.absolute(1);
personelDataSet.updateDouble(5, personelDataSet.getDouble(5)-resultSetFacade.getDouble(3));
personelDataSet.updateDouble(7, personelDataSet.getDouble(7)-resultSetFacade.getDouble(4));
personelDataSet.updateRow();
//Updates envelope
resultSetFacade.deleteRow();
startUp.createBudgetFrame();
}
}
}// End of BudgetCenter
//TODO START OF RECONCILIATION
class ReconciliationCenter extends centerPanel {
private ArrayList<RecInstance> save = new ArrayList<RecInstance>();
private ArrayList<RecInstance> variable = new ArrayList<RecInstance>();
private ArrayList<RecInstance> fixed = new ArrayList<RecInstance>();
private FrameFacade individualFac;
private Color bluePanelColor=new Color(153,204,255);
private Color redPanelColor=new Color(255,153,153);
private Color greenPanelColor=new Color(153,255,153);
private double savingSpent,fixedSpent,variableSpent;
private ButtonListener buttonListener=new ButtonListener();
private int dataBaseIndex=1;
private ResultSet personelDataSet;
// calls other methods that will manipulate returnPanel
public JScrollPane makeCenterPanel(FrameFacade individualFac) {
this.individualFac = individualFac;
getConInfo();
createSmallerComponent();
yPos=1;
return addScrollPane();
}
// Gets the connection from the FactoryFac and passes the info to createInstance()
protected void getConInfo() {
personelDataSet=individualFac.getConnectionInfo("SELECT * From personel_data");
resultSetFacade=individualFac.getConnectionInfo("SELECT * From reconciliation");
setConInfo();
getDefaultMoneyValues();
addDefaultInstance();
}
private void setConInfo(){
try {
while(resultSetFacade.next()){
RecInstance instance=new RecInstance(resultSetFacade.getString(3),resultSetFacade.getString(5),resultSetFacade.getString(2),resultSetFacade.getDouble(4),dataBaseIndex);
addEnvelopeInstance(instance);
dataBaseIndex++;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
//Gets the moneyRatios for the saving,fixed,and variable
protected void getDefaultMoneyValues(){
for(RecInstance instance:save){
savingSpent+=instance.getMoneySpent();
}
for(RecInstance instance:variable){
variableSpent+=instance.getMoneySpent();
}
for(RecInstance instance:fixed){
fixedSpent+=instance.getMoneySpent();
}
}
//Adds instances of the BudgetTemplateTabs
protected void addDefaultInstance(){
//String description, String expenseType, String label, double allocatedMoney
save.add(0,new RecInstance("","Save","Savings : ",savingSpent,1));
fixed.add(0,new RecInstance("","Fixed","Fixed : ",fixedSpent,1));
variable.add(0,new RecInstance("","Variable","Variable:",variableSpent,1));
}
//Adds instances of the Envelopes
protected void addEnvelopeInstance(RecInstance instance) {
String type=instance.getExpenseType();
if(type.equals("Save")){
save.add(instance);
}else if(type.equals("Variable")){
variable.add(instance);
}else if(type.equals("Fixed")){
fixed.add(instance);
}
}
// Uses the connection info and ArrayList to create the panels inside the centerPanel
protected void createSmallerComponent() {
returnPanel.setLayout(new GridBagLayout());
makeDefaults(fixed.get(0),bluePanelColor);
for (int x = 1; x < fixed.size(); x++) {
makeEnvelopes(fixed.get(x),bluePanelColor,"Withdraw");
}
makeDefaults(variable.get(0),redPanelColor);
for (int x = 1; x < variable.size(); x++) {
makeEnvelopes(variable.get(x),redPanelColor,"Withdraw");
}
makeDefaults(save.get(0),greenPanelColor);
for (int x = 1; x < save.size(); x++) {
makeEnvelopes(save.get(x),greenPanelColor,"Deposit");
}
}
// Creates the envelopes that are a part of the Fixed type
protected void makeEnvelopes(RecInstance RInstance,Color color,String transactionType) {
//initialize Envelope Panels
JPanel envelope=new JPanel();
envelope.setLayout(new GridBagLayout());
envelope.setBackground(color);
//Create components
JButton remove=FactoryFacade.makeIconButtons("C:/Users/Kyle Peters/Documents/picturesForFinance/deleteButton.png", color,50,50);
remove.addActionListener(buttonListener);
RInstance.setButton(remove);
JLabel title=FactoryFacade.makeLabels(RInstance.getLabel()+" : "+RInstance.getDescription(), smallFont);
JLabel transaction=FactoryFacade.makeLabels(Double.toString(RInstance.getMoneySpent())+" "+transactionType,smallFont);
setEnvelopesLayout(constraintsToManipulate,envelope,remove,title,transaction);
}
//Adds the components of makeEnvelope to returnPanel
protected void setEnvelopesLayout(GridBagConstraints c,JPanel panel,JButton remove,JLabel title,JLabel transaction){
FactoryFacade.addWithGridBag(1, 1, 1, 2, 75, 75, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, panel, remove);
FactoryFacade.addWithGridBag(2, 1, 1, 1, 100, 100, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, panel, title);
FactoryFacade.addWithGridBag(2, 2, 1, 1, 100, 100, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, panel, transaction);
panel.setBorder(BorderFactory.createLineBorder(Color.BLACK,2));
FactoryFacade.addWithGridBag(1,yPos,1,1,50,50, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, returnPanel, panel);
yPos++;
}
// Creates the default envelope for Fixed
protected void makeDefaults(RecInstance RInstance,Color color) {
//initialize defaultPanels
JPanel defaultPanels=new JPanel();
defaultPanels.setLayout(new GridBagLayout());
defaultPanels.setBackground(color);
//create Components
JButton add=FactoryFacade.makeIconButtons("C:/Users/Kyle Peters/Documents/picturesForFinance/addButton.png", color,50,50);
add.addActionListener(buttonListener);
RInstance.setButton(add);
JLabel title=FactoryFacade.makeLabels(RInstance.getLabel()+" "+"Total : $"+RInstance.getMoneySpent(), largeFont);
setDefaultsLayout(constraintsToManipulate,defaultPanels,add,title);
}
//Adds the default Reconciliation panels to a panel
protected void setDefaultsLayout(GridBagConstraints c,JPanel defaultPanels,JButton add,JLabel title){
FactoryFacade.addWithGridBag(1, 1, 1, 1, 50, 50, GridBagConstraints.BOTH, GridBagConstraints.WEST, c, defaultPanels, add);
FactoryFacade.addWithGridBag(2, 1, 1, 1, 100, 100, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, defaultPanels, title);
defaultPanels.setBorder(BorderFactory.createLineBorder(Color.BLACK,2));
FactoryFacade.addWithGridBag(1, yPos, 1, 1, 50, 50, GridBagConstraints.BOTH, GridBagConstraints.CENTER, c, returnPanel, defaultPanels);
yPos++;
}
//TODO Start of Reconciliation ActionListener
class ButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
if(checkAdd(e)){
}else{
checkRemove(e);
}
}
//Checks if the default panels threw the action
private boolean checkAdd(ActionEvent e) {
if(e.getSource()==save.get(0).getButton()){
withdrawFromRec("Save");
return true;
}else if(e.getSource()==fixed.get(0).getButton()){
withdrawFromRec("Fixed");
return true;
}else if(e.getSource()==variable.get(0).getButton()){
withdrawFromRec("Variable");
return true;
}
return false;
}
//Creates the Frame that appears when you click the defaultPanel' add button
private void withdrawFromRec(String type){
JFrame frame=new JFrame();
frame.setResizable(false);
frame.setAlwaysOnTop(true);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(500, 300);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setTitle("Withdraw");
addWindowListener(frame);
frame.add(createFrameComponents(frame,type));
}
//creates the Frame components
private JPanel createFrameComponents(JFrame frame,String type){
JLabel warning=new JLabel("This function should only be used in emergencies or when depositing");
JLabel warning2=new JLabel("unexpected savings, everyday expenses should use the envelopes");
JLabel nameLabel=FactoryFacade.makeLabels(" Amount : ", smallFont);
JTextField nameField=new JTextField(10);
nameField.setBorder(BorderFactory.createLineBorder(Color.BLACK));
JLabel descriptionLabel=FactoryFacade.makeLabels("Description : ", smallFont);
JTextArea descriptionArea=new JTextArea(3,10);
descriptionArea.setBorder(BorderFactory.createLineBorder(Color.BLACK));
descriptionArea.setLineWrap(true);
descriptionArea.setWrapStyleWord(true);
JButton continueButton=FactoryFacade.makeTextButtons("OK", nameLabel.getBackground(), Color.BLACK, smallFont);
addEnvelopeActionListener(type,continueButton,frame,nameField,descriptionArea);
return createFrameLayout(constraintsToManipulate,warning,warning2,nameLabel, nameField, descriptionLabel, descriptionArea, continueButton);
}
//Adds the components to the frame
private JPanel createFrameLayout(GridBagConstraints c,JLabel warning,JLabel warning2,JLabel nameLabel, JTextField nameField,JLabel descLabel,JTextArea descArea,JButton continueButton){
JPanel panel=new JPanel();
panel.setLayout(new GridBagLayout());
FactoryFacade.addWithGridBag(1, 1, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, nameLabel);
FactoryFacade.addWithGridBag(2, 1, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, nameField);
FactoryFacade.addWithGridBag(1, 2, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, descLabel);
FactoryFacade.addWithGridBag(2, 2, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.CENTER, c, panel, descArea);
FactoryFacade.addWithGridBag(1, 3, 2, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.SOUTH, c, panel, warning);
FactoryFacade.addWithGridBag(1, 4, 2, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.NORTH, c, panel, warning2);
FactoryFacade.addWithGridBag(2, 5, 1, 1, 50, 50, GridBagConstraints.NONE, GridBagConstraints.EAST, c, panel, continueButton);
return panel;
}
//Adds the actionListener to the continueButton
private void addEnvelopeActionListener(String type,JButton continueButton,JFrame frame,JTextField field,JTextArea area){
continueButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try{
//Gets user input and gets rid of frame
frame.dispose();
String expenseString=field.getText();
expenseString=expenseString.replaceAll(",", "");
double expense=Double.parseDouble(expenseString);
String description=area.getText();
//updates program with new information
insertTransaction(type,expense,description);
startUp.createRecFrame();
}catch(NumberFormatException e){
JOptionPane.showMessageDialog(null, "Unable to complete transaction, you didn't enter a number","Error",JOptionPane.ERROR_MESSAGE);
}
}
private void insertTransaction(String type,double expense,String description){
try {
resultSetFacade.moveToInsertRow();
resultSetFacade.updateString(2, "Default");
resultSetFacade.updateString(3, description);
resultSetFacade.updateDouble(4, expense);
resultSetFacade.updateString(5, type);
resultSetFacade.insertRow();
personelDataSet.absolute(1);
updateFinancials(expense);
personelDataSet.updateRow();
resultSetFacade.close();
personelDataSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
//Updates labels and part of the dataBase
private void updateFinancials(double expense) throws SQLException{
double newWealth=0;
double wealthChange=0;
if(type.equals("Save")){
newWealth=personelDataSet.getDouble(3)+expense;
wealthChange=personelDataSet.getDouble(2)+expense;
}else{
newWealth=personelDataSet.getDouble(3)-expense;
wealthChange=personelDataSet.getDouble(2)-expense;
}
System.out.println(newWealth+" "+wealthChange);
personelDataSet.updateDouble(3, newWealth);
personelDataSet.updateDouble(2, wealthChange);
TopPanel.getInstance(null).setWealth(newWealth);
TopPanel.getInstance(null).setChange(wealthChange);
}
});
}
//Adds a listener to tell if the user clicked somewhere other than the Frame
private void addWindowListener(JFrame frame){
frame.addWindowListener(new WindowAdapter(){
public void windowDeactivated(WindowEvent arg0) {
frame.dispose();
}
});
}
//Checks to see if the transaction panel threw the event
private void checkRemove(ActionEvent e) {
for (int x = 1; x < save.size(); x++) {
if(e.getSource()==save.get(x).getButton()){
showConfirmPopup(save.get(x));
return;
}
}for (int x = 1; x < fixed.size(); x++) {
if(e.getSource()==fixed.get(x).getButton()){
showConfirmPopup(fixed.get(x));
return;
}
}for (int x = 1; x < variable.size(); x++) {
if(e.getSource()==variable.get(x).getButton()){
showConfirmPopup(variable.get(x));
return;
}
}
}
//Makes sure the user wants to delete this object
private void showConfirmPopup(RecInstance RInstance){
int hitYes=JOptionPane.showConfirmDialog(null, "Are you sure you wish to continue, this will also delete the withdraw from the envelopes");
if(hitYes==0){
deleteTransaction(RInstance);
startUp.createRecFrame();
}
}
//deletes the Rec panel from the database
private void deleteTransaction(RecInstance RInstance){
try {
resultSetFacade.absolute(RInstance.getDataBaseIndex());
if(!RInstance.getLabel().equals("Default")){
updateEnvelopeGeneratedPanel(RInstance);
}else{
updateRecGeneratedPanel(RInstance);
}
resultSetFacade.deleteRow();
resultSetFacade.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
//updates DataBase due to a rec. panel being deleted that was created by using withdraw in an envelope
private void updateEnvelopeGeneratedPanel(RecInstance RInstance) throws SQLException{
personelDataSet.absolute(1);
//updates overall money spent
personelDataSet.updateDouble(5, personelDataSet.getDouble(5)-RInstance.getMoneySpent());
personelDataSet.updateRow();
//updates envelope money spent
ResultSet envelopeSet=individualFac.getConnectionInfo("SELECT * from envelope where label='"+RInstance.getLabel()+"'");
envelopeSet.next();
envelopeSet.updateDouble(3, envelopeSet.getDouble(3)-RInstance.getMoneySpent());
envelopeSet.updateRow();
}
//updates DataBase due to a rec. panel being deleted that was created by using plus on a default rec. Panel
private void updateRecGeneratedPanel(RecInstance RInstance) throws SQLException{
personelDataSet.absolute(1);
double newWealth=0,wealthChange=0;
if(RInstance.getExpenseType().equals("Save")){
newWealth=personelDataSet.getDouble(3)-RInstance.getMoneySpent();
wealthChange=personelDataSet.getDouble(2)-RInstance.getMoneySpent();
}else{
newWealth=personelDataSet.getDouble(3)+RInstance.getMoneySpent();
wealthChange=personelDataSet.getDouble(2)+RInstance.getMoneySpent();
}
personelDataSet.updateDouble(3, newWealth);
personelDataSet.updateDouble(2, wealthChange);
TopPanel.getInstance(null).setWealth(newWealth);
TopPanel.getInstance(null).setChange(wealthChange);