Java JFrame Icon setDefaultIcon(final JFrame window, final String imagepath)

Here you can find the source of setDefaultIcon(final JFrame window, final String imagepath)

Description

Sets the icon for a window.

License

Apache License

Parameter

Parameter Description
window the target window
imagepath the image which should be icon

Declaration

public static void setDefaultIcon(final JFrame window, final String imagepath) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (C) 2009, 2015, Danilo Pianini and contributors
 * listed in the project's build.gradle or pom.xml file.
 *
 * This file is distributed under the terms of the Apache License, version 2.0
 *******************************************************************************/

import java.awt.Toolkit;

import javax.swing.JFrame;

public class Main {
    /**//from  w  ww  . j  a v a 2  s  . co m
     * Sets the icon for a window.
     * 
     * @param window
     *            the target window
     * @param imagepath
     *            the image which should be icon
     */
    public static void setDefaultIcon(final JFrame window, final String imagepath) {
        window.setIconImage(Toolkit.getDefaultToolkit().getImage(imagepath));
    }
}

Related

  1. getResourceIcon(JFrame fr, String name, Class callingClass)
  2. loadIMageIconToPanel(JFrame frame, JPanel panel, ImageIcon icon)
  3. SET_FRAME_ICON(JFrame f, String iconPath)
  4. setApplicationIcon(JFrame frame)
  5. setIcon(javax.swing.JFrame jFrame, String icon)
  6. setIconImage(JFrame frame, Class clazz, String path)
  7. setIconImageFromResource(JFrame frame, String resource)
  8. setIconOnFrame(JFrame frame)