QONE:在JLable中插入适合大小的图片的设置
ImageIcon buttonIcon =new ImageIcon("jl1.jpg");//ImageIcon是一个ICON的接口,通过URL即"jl1.jpg"得到图片画出icon
jl3=new JLabel();//新建一个对象
Image temp = buttonIcon.getImage().getScaledInstance(80,80, buttonIcon.getImage().SCALE_DEFAULT);
//java.awt.Image.getScaledInstance(int width, int height, int hints)获得新的图像IMAGE
buttonIcon = new ImageIcon(temp); //将得到的图像重新给 buttonIconjl3.setIcon(buttonIcon);图片:
QTWO:设置窗口的图标,一个语句就可以搞定,只是注意图片的路径一定要写对
this.setIconImage(new ImageIcon("jl1.jpg").getImage());
QTHREE:java中数据库的语句的规范,我开始的时候总是弄不清楚什么时候用双引号,什么时候用单引号,现在用一个例子,谈一下自己的理解。
pre=dbConn1.prepareStatement("select * from Tbook where BookName like '%"+bookname+"%' and Author like '%"+authorname+"%' and Publisher like '%"+pub+"%' and ISBN like '%"+isbn+"%'" );
这是一个在图书馆系统中查询书籍功能中的一个语句,在数据库中双引号之间的原样输出。
我们可以用以下的步骤保证操作的正确性。
第一:把SQL语句先在数据库里执行一遍,若可以继续进行。以下是那条语句,BookName等都是字符型数据
select * from Tbook where BookName like '%bookname%' and Author like '%authorname%' and Publisher like '%pub%' and ISBN like '%isbn%'
第二:以上面的语句为例以我们获得的文本即BookName,Author等为中心,加上“+”号,再而在“+”前后加上“,下面红色与红色对应,黑色与黑色对应。在红色引号之间的原样输出。黑色引号之间的原样输出。
红色引号之间的原样输出:
select * from Tbook where BookName like '%
黑色之间的输出:
%‘
将两部分加起来就成了
select * from Tbook where BookName like '%bookname%'
上面是对上面做了一个简单的解释,下面有一个填空。
"select * from Tbook where BookName like '%"+填入字符+"%' and Author like '%"+填入字符+"%' and Publisher like '%"+填入字符+"%' and ISBN like '%"+填入字符+"%'"
还来一个含有数字的介绍
“select * from Tbook where num=" +数字+"")