-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplaintBrowser.java
More file actions
101 lines (84 loc) · 2.5 KB
/
Copy pathComplaintBrowser.java
File metadata and controls
101 lines (84 loc) · 2.5 KB
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
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.*;
import net.proteanit.sql.DbUtils;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.*;
public class ComplaintBrowser extends JFrame {
private JPanel contentPane;
private JTable table;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ComplaintBrowser frame = new ComplaintBrowser();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
Connection conn = null; //Connection ------------------------------------------------------------------------------
private JButton btnNewButton;
/**
* Create the frame.
*/
public ComplaintBrowser() {
conn = db.dbConnector();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(0, 67, 434, 153);
contentPane.add(scrollPane);
table = new JTable();
scrollPane.setViewportView(table);
JButton btnData = new JButton("Load Data");
btnData.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try
{
String query = "SELECT CaseID, Complaintiff,ComplaintText,Defendant,DateCreated FROM complaint";
PreparedStatement ps =conn.prepareStatement(query);
ResultSet rs = ps.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
}
catch(Exception ee)
{
}
}
});
btnData.setBounds(144, 11, 145, 23);
contentPane.add(btnData);
btnNewButton = new JButton("Course of Action");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try
{
int selectedRowIndex = table.getSelectedRow(); //number of SelectedRow
int value = (int) table.getModel().getValueAt(selectedRowIndex, 0);
System.out.println(value);
CourseOfAction coa = new CourseOfAction(value);
coa.setVisible(true);
}
catch(Exception ee)
{
JOptionPane.showMessageDialog(null, "You did not select a row");
}
}
});
btnNewButton.setBounds(144, 227, 145, 23);
contentPane.add(btnNewButton);
}
}