/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
import Images.MyLookAndFeel;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
/**
*
* @author wangcx
*/
public class Utuil {
private void Utuil() {
}
//让窗体的图标发送改变
public static void setFrameImage(JFrame jf) {
//this.setIconImage(new ImageIcon("srcImagesjjcc.jpg").getImage());
//Toolkit tool=frame.getToolkit(); //得到一个Toolkit对象
//1,this.setIconImage(new ImageIcon("srcImagesjjcc.jpg").getImage());
//2,Utuil.setFrameImage(this);
// 1和2等同效果
Toolkit tk = Toolkit.getDefaultToolkit();
Image i = tk.getImage("srcImagesjjcc.jpg");
jf.setIconImage(i);
}
//让窗体居中
public static void setFrameConter(JFrame jf) {
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension ds = tk.getScreenSize();
double width = ds.getWidth();
double height = ds.getHeight();
int width1=jf.getWidth();
int height1=jf.getHeight();
int x = ((int)(width-width1))/2;
int y=(int)(height-height1)/2;
jf.setLocation(x, y);
}
//改变窗体的皮肤
public static void setFrameSkin(JFrame jf){
try {
UIManager.setLookAndFeel(MyLookAndFeel.JTATTOO_MCWIN);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Utuil.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(Utuil.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(Utuil.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedLookAndFeelException ex) {
Logger.getLogger(Utuil.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
版权声明:未标注转载均为本站原创,转载时请以链接形式注明文章出处。如有侵权、不妥之处,请联系站长删除。敬请谅解!
常见资源合集和破解beqptwpmc...