Java Code Examples for javax.swing.JFrame.setIconImages()

The following are Jave code examples for showing how to use setIconImages() of the javax.swing.JFrame class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Wurst-MC-1.12   File: FrameHook.java   View Source Code Vote up 4 votes
public static void createFrame(DefaultResourcePack mcDefaultResourcePack,
	Logger logger) throws LWJGLException
{
	// check if frame should be created
	if(!isAutoMaximize() && !WurstBot.isEnabled())
		return;
	
	// create frame
	frame = new JFrame("Minecraft " + WMinecraft.DISPLAY_VERSION);
	
	// add LWJGL
	Canvas canvas = new Canvas();
	canvas.setBackground(new Color(16, 16, 16));
	Display.setParent(canvas);
	Minecraft mc = Minecraft.getMinecraft();
	canvas.setSize(mc.displayWidth, mc.displayHeight);
	frame.add(canvas);
	
	// configure frame
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.pack();
	frame.setLocationRelativeTo(null);
	
	// add icons
	InputStream icon16 = null;
	InputStream icon32 = null;
	try
	{
		icon16 = mcDefaultResourcePack.getInputStreamAssets(
			new ResourceLocation("icons/icon_16x16.png"));
		icon32 = mcDefaultResourcePack.getInputStreamAssets(
			new ResourceLocation("icons/icon_32x32.png"));
		ArrayList<BufferedImage> icons = new ArrayList<>();
		icons.add(ImageIO.read(icon16));
		icons.add(ImageIO.read(icon32));
		frame.setIconImages(icons);
	}catch(Exception e)
	{
		logger.error("Couldn't set icon", e);
	}finally
	{
		IOUtils.closeQuietly(icon16);
		IOUtils.closeQuietly(icon32);
	}
	
	// show frame
	if(!WurstBot.isEnabled())
		frame.setVisible(true);
}