Skip to content

Commit

Permalink
Updating GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
doshiparth committed Apr 1, 2017
1 parent a6a3dca commit 9453221
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 27 deletions.
56 changes: 40 additions & 16 deletions src/ser/ui/GUI/AdminGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,52 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;
import ser.admin.IntAdmin;
import ser.ui.IntUI;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.scene.control.DatePicker;

/**
*
* @author Parth Doshi
*/

public class AdminGUI extends JFrame implements IntUI,ActionListener{
JFrame f1;
//JFrame f1;
JButton[] jb1=new JButton[6];
JButton[] jb2;
JLabel[] jl;
JTextField jtf;
LocalDate date;
final IntAdmin ia;
public AdminGUI(IntAdmin ia){
new JFrame("Software-Monitor");
setLayout(new GridLayout(3, 2));
this.ia=ia;
List<String> abc = ia.getAllUname(LocalDate.MIN);
jtf=new JTextField();
String sdate=jtf.getText();
try {
date = LocalDate.of(new Integer(sdate.substring(0, 4)).intValue(), new Integer(sdate.substring(5, 7)).intValue(), new Integer(sdate.substring(8)).intValue());
} catch (Exception ex) {
Logger.getLogger(AdminGUI.class.getName()).log(Level.SEVERE, null, ex);
}
List<String> abc = ia.getAllUname(date);
jl = new JLabel[abc.size()];
jb2 = new JButton[abc.size()];
int i = 0;
JPanel p1=new JPanel(new FlowLayout());
JPanel p2=new JPanel(new GridLayout(300, 2));
JPanel p1=new JPanel(new GridLayout(2, 4));
JPanel p2=new JPanel(new GridLayout(abc.size(), 2));
final DatePicker dp = new DatePicker();

for(String username:abc)
{
jl[i] = new JLabel(username);
Expand All @@ -58,6 +78,7 @@ public void actionPerformed(ActionEvent e) {
ListPage lp=new ListPage(ia,username,date);
}
});
i++;
}

jb1[1]=new JButton("Update");
Expand Down Expand Up @@ -103,10 +124,8 @@ public void actionPerformed(ActionEvent e) {
ia.stopSer();
}
});
f1 = new JFrame("Software-Monitor");
f1.setLayout(new GridLayout(3, 2));
f1.add(p1);
f1.add(p2);
add(p1);
add(p2);
p1.add(jb1[1]);
p1.add(jb1[5]);
p1.add(jb1[6]);
Expand All @@ -117,10 +136,11 @@ public void actionPerformed(ActionEvent e) {
jb1[2].setEnabled(true);
jb1[3].setEnabled(false);
jb1[4].setEnabled(false);

f1.setVisible(false);
f1.setSize(500, 400);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setExtendedState(JFrame.MAXIMIZED_BOTH);
setUndecorated(true);
setVisible(false);
setSize(500, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

Expand Down Expand Up @@ -155,16 +175,20 @@ public String showPrompt(String msg) {

@Override
public void start() {
f1.setVisible(true);
setVisible(true);
}

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

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

public static void main(String[] args) {
AdminGUI ag=new AdminGUI();
}
}
41 changes: 30 additions & 11 deletions src/ser/ui/GUI/ListPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package ser.ui.GUI;

import com.dataBean.IntDataBean;
import com.dataBean.IntDataTuple;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
Expand All @@ -31,31 +32,49 @@
* @author Parth Doshi
*/

class ListPage extends JFrame implements ActionListener{
class ListPage extends JFrame {
final IntAdmin ia;
JLabel[] jl;
JLabel[] sname;
JLabel[] ver;
JLabel[] idate;

JPanel p1,p2;

public ListPage(IntAdmin ia,String uname,LocalDate dt){
p1=new JPanel(new FlowLayout());
List<IntDataBean> abc = ia.getUserDetail(uname, dt);
p2=new JPanel(new GridLayout(abc.size(), 3));
this.ia=ia;
p1=new JPanel(new GridLayout(3, 2));
List<IntDataBean> abc = ia.getUserDetail(uname, dt);
jl[1]=new JLabel("Username : "+uname);
//jl[2]=new JLabel("IP Address : "+ia.getIp);
//jl[3]=new JLabel("Mac Address : "+ia.getMac);
jl[2]=new JLabel("IP Address : "+abc.get(0).getIP());
jl[3]=new JLabel("Mac Address : "+abc.get(0).getMac());
p1.add(jl[1]);
p1.add(jl[2]);
p1.add(jl[3]);
//Panel 1 ends
jl[4]=new JLabel("Software Name");
jl[5]=new JLabel("Version");
jl[6]=new JLabel("Installed Date");
p2=new JPanel(new GridLayout(abc.size(), 3));
p2.add(jl[4]);
p2.add(jl[5]);
p2.add(jl[6]);
}

@Override
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
int i = 1;
for(IntDataBean p:abc){
for(IntDataTuple idt:p.getSoftDetail()){
sname[i]=new JLabel(idt.getSoftName());
ver[i]=new JLabel(idt.getVersion());
idate[i]=new JLabel(idt.getDate().toString());
p2.add(sname[i]);
p2.add(ver[i]);
p2.add(idate[i]);
i++;
}
}
//Panel 2 ends
setExtendedState(JFrame.MAXIMIZED_BOTH);
setUndecorated(true);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}

0 comments on commit 9453221

Please sign in to comment.