-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchBy.java
133 lines (110 loc) · 3.92 KB
/
SearchBy.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
129
130
131
132
133
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JComboBox;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class SearchBy extends JFrame {
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
SearchBy frame = new SearchBy();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public SearchBy() {
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 450, 277);
setLocationRelativeTo(this);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblNewLabel = new JLabel("New label");
JLabel lblSearchBy = new JLabel("Search By");
String value[]={"Select","All","Author","Subject","Categrory","Publication"};
JComboBox comboBox = new JComboBox(value);
JButton btnNewButton = new JButton("SEARCH");
btnNewButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent arg0)
{
String str=(String)comboBox.getSelectedItem();
if(str.equalsIgnoreCase("select"))
JOptionPane.showMessageDialog(getParent(), "Pls select any option", "Information", JOptionPane.WARNING_MESSAGE);
else if(str.equalsIgnoreCase("all"))
{
JFrame frm=new JFrame("All Records");
frm.setSize(1000, 600);
frm.setLocationRelativeTo(frm);
GetValue.searchAllValues();
JTable table=new JTable(GetValue.records, GetValue.colNames);
JScrollPane pane=new JScrollPane(table);
frm.add(pane);
frm.setVisible(true);
}
else
{
JFrame frm=new JFrame("Search by");
frm.setSize(400, 150);
frm.setLocationRelativeTo(frm);
SearchPanel obj=new SearchPanel(str);
frm.add(obj);
frm.setVisible(true);
}
}
});
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(165)
.addComponent(lblNewLabel))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(80)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addComponent(btnNewButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblSearchBy)
.addGap(28)
.addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 183, GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(64, Short.MAX_VALUE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblNewLabel)
.addGap(32)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblSearchBy)
.addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(32)
.addComponent(btnNewButton)
.addContainerGap(112, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
}
}