-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupplier_view.java
More file actions
102 lines (87 loc) · 2.43 KB
/
supplier_view.java
File metadata and controls
102 lines (87 loc) · 2.43 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
102
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
public class supplier_view {
private JFrame frame;
private JTable table;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
supplier_view window = new supplier_view();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public supplier_view() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize()
{
frame = new JFrame();
frame.setBounds(200, 400, 779, 467);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
},
new String[] {
"Supplier No.", "Name", "Address", "Contact No", "E-mail Id"
}
));
table.getColumnModel().getColumn(0).setPreferredWidth(92);
try {
Connection conObject=DriverManager.getConnection("jdbc:ucanaccess://d:/electronics1.accdb");
Statement stmt = conObject.createStatement();
String query = "Select * from supplier";
ResultSet rs = stmt.executeQuery(query);
int i=1;
while(rs.next())
{
table.setValueAt(rs.getString(1), i, 0);
table.setValueAt(rs.getString(2), i, 1);
table.setValueAt(rs.getString(3), i, 2);
table.setValueAt(rs.getString(4), i, 3);
table.setValueAt(rs.getString(5), i, 4);
i++;
}
frame.getContentPane().add(new JScrollPane(table));
stmt.close();
conObject.close();
}
catch(Exception e1)
{
JOptionPane.showMessageDialog(null, e1);
}
}
}