-
Notifications
You must be signed in to change notification settings - Fork 0
/
GuiQuery3.java
128 lines (125 loc) · 4.2 KB
/
GuiQuery3.java
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
/**
*@file GuiQuery3.java
*This file contains GUI Query3 implementation
*@author Abhinav Khattar 2015120
*@author Tushar Arora 2015107
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;
import javax.swing.border.Border;
import javax.swing.table.DefaultTableModel;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
/**Creates the GUI needed for supporting Query3*/
public class GuiQuery3 extends GUIQuery
{
private int flag=0,flag2=0,tableWorking=0,pages=0;
private JLabel title = new JLabel("Name of Author");
private JLabel title1 = new JLabel("Prediction after year");
private JTextField authName =new JTextField();
private JTextField predYear =new JTextField();
private DefaultTableModel query3Table= new DefaultTableModel();
private JTable displayTable = new JTable(query3Table);
private JScrollPane dispTable = new JScrollPane(displayTable);
private JLabel warning = new JLabel(" ");
private JButton next = new JButton("NEXT");
private JButton back = new JButton("BACK");
public GuiQuery3(JFrame mainFrame, JComboBox<String> queries,JPanel sidePanel,JPanel displayPanel,QueryFacade q3)
{
this.mainFrame=mainFrame;
this.queries=queries;
this.sidePanel=sidePanel;
this.displayPanel=displayPanel;
this.q=q3;
}
public void initQuery()
{
submit=new JButton("Submit");
reset=new JButton("Reset");
submit.setBackground(Color.BLACK);
reset.setBackground(Color.RED);
title.setFont(new Font("Calibri", Font.PLAIN, 12));
title.setBounds(30,80,130,20);
title1.setFont(new Font("Calibri", Font.PLAIN, 12));
title1.setBounds(30,105,130,20);
authName.setBounds(170,80,50,20);
predYear.setBounds(170,105,50,20);
submit.setForeground(Color.WHITE);
submit.setBounds(30,155,80,30);
reset.setBounds(140,155,80,30);
submit.setFont(new Font("Calibri", Font.PLAIN, 12));
reset.setFont(new Font("Calibri", Font.PLAIN, 12));
displayTable.setDefaultEditor(Object.class, null);
dispTable.setBounds(20,5,910,390);
query3Table.addColumn("S.No.");
query3Table.addColumn("Authors");
query3Table.addColumn("Predicted Value");
warning.setForeground(Color.RED);
warning.setBounds(30,340,190,20);
warning.setFont(new Font("Calibri", Font.PLAIN, 12));
next.setBounds(540,335,80,40);
next.setBackground(Color.RED);
next.setFont(new Font("Calibri", Font.PLAIN, 10));
back.setBounds(30,335,80,40);
back.setBackground(Color.BLACK);
back.setFont(new Font("Calibri", Font.PLAIN, 10));
reset.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
warning.setText("");
authName.setText("");
predYear.setText("");
query3Table.setRowCount(0);
}
});
}
public void setQuery() {
queries.removeItem("Queries");
sidePanel.removeAll();
queries.setBounds(50,50,100,20);
queries.setSelectedItem("Query 3");
queries.removeItem("Queries");
displayPanel.removeAll();
displayPanel.add(dispTable);
sidePanel.add(warning);
sidePanel.add(title);
sidePanel.add(queries);
sidePanel.add(title1);
sidePanel.add(predYear);
sidePanel.add(authName);
sidePanel.add(submit);
sidePanel.add(reset);
mainFrame.revalidate();
mainFrame.repaint();
submit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
query3Table.setRowCount(0);
tableWorking=0;
if(authName.getText().length()==0){
warning.setText("Author Name can not be empty");
} else if(predYear.getText().length()==0){
warning.setText("year can not be empty");
}
else {
if(isInteger(predYear.getText())) {
warning.setText(" ");
q.queryThreeFind(Integer.parseInt(predYear.getText()),authName.getText());
tableWorking=1;
double a =q.queryThreeGetData();
if(a==-1.0){
warning.setText("No result Found");
} else{
query3Table.addRow(new Object[]{1,authName.getText(),a});}
}
else {
warning.setText("Year field should be numbers");}
}
}
});
}
}