Skip to content

Commit 9453221

Browse files
committed
Updating GUI
1 parent a6a3dca commit 9453221

File tree

2 files changed

+70
-27
lines changed

2 files changed

+70
-27
lines changed

src/ser/ui/GUI/AdminGUI.java

+40-16
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,52 @@
2020
import java.awt.event.ActionEvent;
2121
import java.awt.event.ActionListener;
2222
import javax.swing.*;
23-
import java.awt.*;
23+
import java.io.IOException;
24+
import java.text.DateFormat;
25+
import java.text.ParseException;
26+
import java.text.SimpleDateFormat;
2427
import java.time.LocalDate;
28+
import java.util.Date;
2529
import ser.admin.IntAdmin;
2630
import ser.ui.IntUI;
2731
import java.util.List;
32+
import java.util.Locale;
33+
import java.util.logging.Level;
34+
import java.util.logging.Logger;
35+
import javafx.scene.control.DatePicker;
2836

2937
/**
3038
*
3139
* @author Parth Doshi
3240
*/
3341

3442
public class AdminGUI extends JFrame implements IntUI,ActionListener{
35-
JFrame f1;
43+
//JFrame f1;
3644
JButton[] jb1=new JButton[6];
3745
JButton[] jb2;
3846
JLabel[] jl;
47+
JTextField jtf;
3948
LocalDate date;
4049
final IntAdmin ia;
4150
public AdminGUI(IntAdmin ia){
51+
new JFrame("Software-Monitor");
52+
setLayout(new GridLayout(3, 2));
4253
this.ia=ia;
43-
List<String> abc = ia.getAllUname(LocalDate.MIN);
54+
jtf=new JTextField();
55+
String sdate=jtf.getText();
56+
try {
57+
date = LocalDate.of(new Integer(sdate.substring(0, 4)).intValue(), new Integer(sdate.substring(5, 7)).intValue(), new Integer(sdate.substring(8)).intValue());
58+
} catch (Exception ex) {
59+
Logger.getLogger(AdminGUI.class.getName()).log(Level.SEVERE, null, ex);
60+
}
61+
List<String> abc = ia.getAllUname(date);
4462
jl = new JLabel[abc.size()];
4563
jb2 = new JButton[abc.size()];
4664
int i = 0;
47-
JPanel p1=new JPanel(new FlowLayout());
48-
JPanel p2=new JPanel(new GridLayout(300, 2));
65+
JPanel p1=new JPanel(new GridLayout(2, 4));
66+
JPanel p2=new JPanel(new GridLayout(abc.size(), 2));
67+
final DatePicker dp = new DatePicker();
68+
4969
for(String username:abc)
5070
{
5171
jl[i] = new JLabel(username);
@@ -58,6 +78,7 @@ public void actionPerformed(ActionEvent e) {
5878
ListPage lp=new ListPage(ia,username,date);
5979
}
6080
});
81+
i++;
6182
}
6283

6384
jb1[1]=new JButton("Update");
@@ -103,10 +124,8 @@ public void actionPerformed(ActionEvent e) {
103124
ia.stopSer();
104125
}
105126
});
106-
f1 = new JFrame("Software-Monitor");
107-
f1.setLayout(new GridLayout(3, 2));
108-
f1.add(p1);
109-
f1.add(p2);
127+
add(p1);
128+
add(p2);
110129
p1.add(jb1[1]);
111130
p1.add(jb1[5]);
112131
p1.add(jb1[6]);
@@ -117,10 +136,11 @@ public void actionPerformed(ActionEvent e) {
117136
jb1[2].setEnabled(true);
118137
jb1[3].setEnabled(false);
119138
jb1[4].setEnabled(false);
120-
121-
f1.setVisible(false);
122-
f1.setSize(500, 400);
123-
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
139+
setExtendedState(JFrame.MAXIMIZED_BOTH);
140+
setUndecorated(true);
141+
setVisible(false);
142+
setSize(500, 400);
143+
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
124144

125145
}
126146

@@ -155,16 +175,20 @@ public String showPrompt(String msg) {
155175

156176
@Override
157177
public void start() {
158-
f1.setVisible(true);
178+
setVisible(true);
159179
}
160180

161181
@Override
162182
public void actionPerformed(ActionEvent e) {
163183
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
164184
}
165185

166-
public static void main(String[] args) {
167-
AdminGUI ag=new AdminGUI(null);
186+
@Override
187+
public void close() throws IOException {
188+
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
168189
}
169190

191+
public static void main(String[] args) {
192+
AdminGUI ag=new AdminGUI();
193+
}
170194
}

src/ser/ui/GUI/ListPage.java

+30-11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package ser.ui.GUI;
1818

1919
import com.dataBean.IntDataBean;
20+
import com.dataBean.IntDataTuple;
2021
import java.awt.FlowLayout;
2122
import java.awt.GridLayout;
2223
import java.awt.event.ActionEvent;
@@ -31,31 +32,49 @@
3132
* @author Parth Doshi
3233
*/
3334

34-
class ListPage extends JFrame implements ActionListener{
35+
class ListPage extends JFrame {
3536
final IntAdmin ia;
3637
JLabel[] jl;
38+
JLabel[] sname;
39+
JLabel[] ver;
40+
JLabel[] idate;
41+
3742
JPanel p1,p2;
43+
3844
public ListPage(IntAdmin ia,String uname,LocalDate dt){
39-
p1=new JPanel(new FlowLayout());
40-
List<IntDataBean> abc = ia.getUserDetail(uname, dt);
41-
p2=new JPanel(new GridLayout(abc.size(), 3));
4245
this.ia=ia;
46+
p1=new JPanel(new GridLayout(3, 2));
47+
List<IntDataBean> abc = ia.getUserDetail(uname, dt);
4348
jl[1]=new JLabel("Username : "+uname);
44-
//jl[2]=new JLabel("IP Address : "+ia.getIp);
45-
//jl[3]=new JLabel("Mac Address : "+ia.getMac);
49+
jl[2]=new JLabel("IP Address : "+abc.get(0).getIP());
50+
jl[3]=new JLabel("Mac Address : "+abc.get(0).getMac());
4651
p1.add(jl[1]);
4752
p1.add(jl[2]);
4853
p1.add(jl[3]);
54+
//Panel 1 ends
4955
jl[4]=new JLabel("Software Name");
5056
jl[5]=new JLabel("Version");
5157
jl[6]=new JLabel("Installed Date");
58+
p2=new JPanel(new GridLayout(abc.size(), 3));
5259
p2.add(jl[4]);
5360
p2.add(jl[5]);
5461
p2.add(jl[6]);
55-
}
56-
57-
@Override
58-
public void actionPerformed(ActionEvent e) {
59-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
62+
int i = 1;
63+
for(IntDataBean p:abc){
64+
for(IntDataTuple idt:p.getSoftDetail()){
65+
sname[i]=new JLabel(idt.getSoftName());
66+
ver[i]=new JLabel(idt.getVersion());
67+
idate[i]=new JLabel(idt.getDate().toString());
68+
p2.add(sname[i]);
69+
p2.add(ver[i]);
70+
p2.add(idate[i]);
71+
i++;
72+
}
73+
}
74+
//Panel 2 ends
75+
setExtendedState(JFrame.MAXIMIZED_BOTH);
76+
setUndecorated(true);
77+
setVisible(true);
78+
setDefaultCloseOperation(EXIT_ON_CLOSE);
6079
}
6180
}

0 commit comments

Comments
 (0)