-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathFrmDocList.java
More file actions
71 lines (65 loc) · 1.58 KB
/
FrmDocList.java
File metadata and controls
71 lines (65 loc) · 1.58 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
package hms;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import java.awt.print.*;
public class FrmDocList extends JInternalFrame implements ActionListener
{
/**
*
*/
private static final long serialVersionUID = 1L;
JButton jbt;
JTable jtb;
ResultSet rst;
JScrollPane jsp;
String[] heads={"Doctor Id","Name","Contact","Degree","Specialization","Fees","Mail id","Timings"};
Object data[][];
DConnection dc;
FrmDocList()
{
super("Doctor List",true,true,true,true);
jbt=new JButton("Print");
jbt.addActionListener(this);
add(jbt,"South");
try
{
dc=new DConnection();
rst=dc.executeQuery("select count(*) from doctor");//tabale name??
rst.next();
int n=rst.getInt(1);
data=new Object[n][8];
rst=dc.executeQuery("select * from doctor");
for(int i=0;rst.next();i++)
{
for(int j=0;j<8;j++)
data[i][j] = rst.getString(j+1);
}
dc.close();
}
catch(Exception e)
{
e.printStackTrace();
}
jtb=new JTable(data,heads);
jtb.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
jtb.setFillsViewportHeight(true);
jsp = new JScrollPane(jtb);
jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
add(jsp);
setVisible(true);
setSize(900,500);
}
public void actionPerformed(ActionEvent ae)
{
try
{
jtb.print();
}
catch(PrinterException e)
{
e.printStackTrace();
}
}
}