问题
I need to add image in JFrame title bar, can anybody tell me the way to do this?
回答1:
You could use Window#setImageIcons(List<Image>) which allows you to supply a series of different sized, which allows the underlying platform to choose a icon that is best suited to the platform and look and feel...
List<Image> images = new ArrayList<Image>(4);
images.add(ImageIO.read(getClass().getResource("/icons/icon16x16.png"));
images.add(ImageIO.read(getClass().getResource("/icons/icon24x24.png"));
images.add(ImageIO.read(getClass().getResource("/icons/icon32x32.png"));
images.add(ImageIO.read(getClass().getResource("/icons/icon48x48.png"));
frame.setImageIcons(images);
回答2:
use frame.setIconImage(Image image)
see http://docs.oracle.com/javase/6/docs/api/javax/swing/JFrame.html for details.
Use BufferedImage to represent your image.
来源:https://stackoverflow.com/questions/13817565/how-to-add-images-icon-in-the-title-bar-of-jframe