-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuiQuery1Control.java
70 lines (65 loc) · 2.08 KB
/
GuiQuery1Control.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
/**
*@file GuiQuery1Control.java
*This file contains GUI Query1 Controls
*@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.*;
/**Controls how Query1 functions*/
public class GuiQuery1Control extends GUIQuery
{
private JComboBox<String> searchBy = new JComboBox<String>();
public GuiQuery1Control(JFrame mainFrame, JComboBox<String> queries,JPanel sidePanel,JPanel displayPanel,QueryFacade q1)
{
this.mainFrame=mainFrame;
this.queries=queries;
this.sidePanel=sidePanel;
this.displayPanel=displayPanel;
this.q=q1;
searchBy.addItem("Search By");
searchBy.addItem("Author Name");
searchBy.addItem("Title Tag");
searchBy.setSelectedItem("Search By");
searchBy.setBounds(50,50,100,20);
searchBy.setFont(new Font("Calibri", Font.PLAIN, 10));
}
public void initQuery()
{
}
public void setQuery()
{
queries.removeItem("Queries");
sidePanel.removeAll();
displayPanel.removeAll();
queries.setBounds(50,20,100,20);
queries.setSelectedItem("Query 1");
//----
sidePanel.add(searchBy);
sidePanel.add(queries);
mainFrame.revalidate();
mainFrame.repaint();
searchBy.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
JComboBox<? extends Object> t= (JComboBox<? extends Object>) event.getSource();
String selectedQuery = (String) t.getSelectedItem();
if (selectedQuery.equals("Author Name")) {
GuiQuery1Author ga= new GuiQuery1Author(mainFrame,queries,sidePanel,displayPanel,q,searchBy);
ga.setQueryAuthor();
} else if (selectedQuery.equals("Title Tag")) {
GuiQuery1Title gt= new GuiQuery1Title(mainFrame,queries,sidePanel,displayPanel,q,searchBy);
gt.setQueryTitle();
}
}
});
}
}