当前位置: 技术问答>java相关
怎么改变Cursor的大小......过节..我还在加班....
来源: 互联网 发布时间:2015-09-10
本文导语: 我有一个16*16的图片做成Cursor 后就变成32*32大小了...... 总是比正常的大2倍.....高手救我。。。。 立即结帖 | try我这个例子 import java.awt.*; import java.awt.image.*; public class Test extends java.applet....
我有一个16*16的图片做成Cursor 后就变成32*32大小了......
总是比正常的大2倍.....高手救我。。。。
立即结帖
总是比正常的大2倍.....高手救我。。。。
立即结帖
|
try我这个例子
import java.awt.*;
import java.awt.image.*;
public class Test extends java.applet.Applet {
public void init()
{
Image image = getImage(getCodeBase(), "Cursor/zoomin.gif");
MediaTracker mt = new MediaTracker(this);
mt.addImage(image, 0);
try{
mt.waitForID(0);
}catch(Exception e) {}
Cursor cursor = createCustomCursor(image, new Point(0,0), "TEST", this);
setCursor(cursor);
}
private Cursor createCustomCursor(Image cursor, Point hotSpot, String name, ImageObserver ob) {
Dimension bestCursorSize = Toolkit.getDefaultToolkit().getBestCursorSize(cursor.getWidth(ob), cursor.getHeight(ob) );
BufferedImage bufferedImage = new BufferedImage(
bestCursorSize.width,
bestCursorSize.height,
BufferedImage .TYPE_INT_ARGB
);
for(int x=0;x
import java.awt.*;
import java.awt.image.*;
public class Test extends java.applet.Applet {
public void init()
{
Image image = getImage(getCodeBase(), "Cursor/zoomin.gif");
MediaTracker mt = new MediaTracker(this);
mt.addImage(image, 0);
try{
mt.waitForID(0);
}catch(Exception e) {}
Cursor cursor = createCustomCursor(image, new Point(0,0), "TEST", this);
setCursor(cursor);
}
private Cursor createCustomCursor(Image cursor, Point hotSpot, String name, ImageObserver ob) {
Dimension bestCursorSize = Toolkit.getDefaultToolkit().getBestCursorSize(cursor.getWidth(ob), cursor.getHeight(ob) );
BufferedImage bufferedImage = new BufferedImage(
bestCursorSize.width,
bestCursorSize.height,
BufferedImage .TYPE_INT_ARGB
);
for(int x=0;x