-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVjtableDemo.java
More file actions
100 lines (78 loc) · 1.63 KB
/
VjtableDemo.java
File metadata and controls
100 lines (78 loc) · 1.63 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
// design a screen for all vendor medicine
import javax.swing.*;
import java.awt.*;
import javax.swing.table.*;
import java.sql.*;
import java.awt.event.*;
class Vjtable implements ActionListener
{
JFrame f;
JButton b1;
JTable tb;
DefaultTableModel model;
JScrollPane js;
ResultSet rs;
Statement st;
Connection con;
Vjtable()
{
f=new JFrame("All Vendors");
f.setSize(650,450);
f.setResizable(false);
f.setLocationRelativeTo(null);
f.setLayout(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tb=new JTable();
model=new DefaultTableModel();
String heads[]={"vendor_id","name","address","mobile","email_id"};
model.setColumnIdentifiers(heads);
tb.setModel(model);
js=new JScrollPane(tb);
js.setBounds(30,30,550,250);//Jtable
f.add(js);
b1=new JButton("Back");
b1.setBounds(480,300,100,30);
//b1.setFont(f1);
f.add(b1);
//b1.setForeground(Color.BLUE);
b1.addActionListener(this);
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/medical","root","");
st=con.createStatement();
String ss="select * from vendor";
System.out.println("query:"+ss);
rs=st.executeQuery(ss);
while(rs.next())
{
String s1=rs.getString("vendor_id");
String s2=rs.getString("name");
String s3=rs.getString("address");
String s4=rs.getString("mobile");
String s5=rs.getString("email_id");
model.addRow(new Object[]{s1,s2,s3,s4,s5});
}
con.close();
}
catch(Exception e)
{
System.out.print(e);
}
f.setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
f.dispose();
Report r=new Report();
}
}
}
class VjtableDemo
{
public static void main(String s[])
{
Vjtable vj=new Vjtable();
}}