在java开发中 怎样更换标题栏默认的coffe图标 本人是个菜鸟,正在做毕业设计项目,想把自已的项目搞得漂亮,但是对API又不太熟悉,请各位能给我支几招,怎么样做能达到意想不到的效果,或者说是特效,让人看了之后耳目一新的感觉,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class Frame1 extends Frame { public Frame1() { try { jbInit(); } catch (Exception exception) { exception.printStackTrace(); } } private void jbInit() throws Exception { Image img = Toolkit.getDefaultToolkit().createImage("C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\示例图片\\Blue hills.jpg"); this.setIconImage(img); this.setVisible(true); } public static void main(String[] args) { Frame1 frame1 = new Frame1(); }} 谢谢你的回答,我在做项目时,还发现一个问题,就是往JLabel里插图片时,图片过大,只显示图片的一部分,要怎么样做调整呢? 学习 谢谢liujun999999(减肥中...) 用以下代码修改图片的大小,我算是服务到家了:private static String dir = "";private static String newDir = ""; public static void zoomIconInDir(int width,int height){ File dirFile = new File(dir); if(dirFile.exists() && dirFile.isDirectory()){ File [] children = dirFile.listFiles(); for(int i = 0; i<children.length; i++){ zoomIcon(children[i].getName(),width,height); } }}public static Icon zoomIcon(String iconPath,int width,int height){ File file = new File(dir+"\\"+iconPath); BufferedImage bi = null; try { bi = ImageIO.read(file); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if(bi==null)return null; double wRatio = width/new Integer(bi.getWidth()).doubleValue(); double hRatio = height/new Integer(bi.getHeight()).doubleValue(); System.out.print(iconPath+" : "); System.out.println(wRatio+" "+hRatio); Image Itemp = bi.getScaledInstance (width,height,bi.SCALE_SMOOTH); AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(wRatio, hRatio), null); Itemp = op.filter(bi,null); try{ ImageIO.write((BufferedImage)Itemp, "png" , new File(newDir+"\\"+iconPath)); }catch (Exception ex){ System.out.println( " ######## here error : " + ex); } return new ImageIcon(Itemp);}public static void main(String[] args){ dir = "********"; newDir = "*************"; MethordSet.zoomIconInDir(24, 24);}//我想不用解释了吧,功能应该很明显才对。 ajax爬虫 背景颜色 tableviewer新录入的数据怎么设置为红色 为什么排序时间会为0 为什么在jdk帮助文档中找不到:java.uti.Array 昨天又去图书馆借了一本书,大家说这本书怎么样? 请教java怎样实现字体对话框? 请教几个类! 集合的问题,很纠结,求大神指教 一个关于SERVERLET。JAR的问题,大家帮帮忙。 在JF中怎么才可以控制icon的对象的移动? 为什么ResultSet 的类型为forward时,其 absolute 操作不能使用?
public Frame1() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
} private void jbInit() throws Exception {
Image img = Toolkit.getDefaultToolkit().createImage("C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\示例图片\\Blue hills.jpg");
this.setIconImage(img);
this.setVisible(true);
} public static void main(String[] args) {
Frame1 frame1 = new Frame1();
}
}
private static String newDir = "";
public static void zoomIconInDir(int width,int height){
File dirFile = new File(dir);
if(dirFile.exists() && dirFile.isDirectory()){
File [] children = dirFile.listFiles();
for(int i = 0; i<children.length; i++){
zoomIcon(children[i].getName(),width,height);
}
}
}
public static Icon zoomIcon(String iconPath,int width,int height){
File file = new File(dir+"\\"+iconPath);
BufferedImage bi = null;
try {
bi = ImageIO.read(file);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(bi==null)return null;
double wRatio = width/new Integer(bi.getWidth()).doubleValue();
double hRatio = height/new Integer(bi.getHeight()).doubleValue();
System.out.print(iconPath+" : ");
System.out.println(wRatio+" "+hRatio);
Image Itemp = bi.getScaledInstance (width,height,bi.SCALE_SMOOTH);
AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(wRatio, hRatio), null);
Itemp = op.filter(bi,null);
try{
ImageIO.write((BufferedImage)Itemp, "png" , new File(newDir+"\\"+iconPath));
}catch (Exception ex){
System.out.println( " ######## here error : " + ex);
}
return new ImageIcon(Itemp);
}
public static void main(String[] args){
dir = "********";
newDir = "*************";
MethordSet.zoomIconInDir(24, 24);
}//我想不用解释了吧,功能应该很明显才对。