Bax*_*Bax 11 java icons swing image
为摆动动作设置图像:
Action action = ...
// ImageIcon icon = new ImageIcon(getClass().getResource("/icon.ico"));
ImageIcon icon = new ImageIcon(getClass().getResource("/icon_16x16.png"));
action.putValue(Action.SMALL_ICON, icon);
Run Code Online (Sandbox Code Playgroud)
*.ico文件不会被渲染,只有png/jpg.
这是设计的吗?
And*_*son 13
制造商和版本可能会更改支持的类型,但您通常可以依赖PNG,JPG和GIF.
import javax.imageio.ImageIO;
public class QuickTest {
public static void main(String[] args) throws Exception {
String[] types = ImageIO.getReaderFileSuffixes();
System.out.println("This JRE supports image types:");
for (String type : types) {
System.out.println("Type: " + type);
}
}
}
Run Code Online (Sandbox Code Playgroud)
This JRE supports image types:
Type: bmp
Type: jpg
Type: wbmp
Type: jpeg
Type: png
Type: gif
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9127 次 |
| 最近记录: |