fastreport如何显示SQLSERVER数据库中的JPG
我觉得图片最好别写如数据库,把路径写进表里,用的事后直接连接就行了
private JTable getJTable() {
if (jTable == null) {
jTable = new JTable();
jTable.setForeground(Color.blue);
jTable.setGridColor(Color.black);
Object[][] p=null;
ay=getstudent();
p=new Object[ay.size()][7];
for(int i=0;i<ay.size();i++){
student stu=(student)ay.get(i);
p[i][0]=String.valueOf(stu.getStu_id());
p[i][1]=stu.getStu_name();
p[i][2]=stu.getStu_pass();
p[i][3]=stu.getStu_sex();
p[i][4]=stu.getStu_tel();
p[i][5]=stu.getStu_address();
p[i][6]=stu.getStu_photo();
}
Object[] table={"编号","姓名","密码","性别","电话","地址","照片"};
jTable = new JTable(p,table);
jTable.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
int rows=getrows();//得到选中的行
String img=String.valueOf(jTable.getValueAt(rows, 6));
jLabel3.setIcon(new ImageIcon(img));
// System.out.println("您选择的行是"+rows+"截取的列是"+img);
}
});
}
return jTable;
}
这是java截取路径的类