Java JFrame Icon setIconOnFrame(JFrame frame)

Here you can find the source of setIconOnFrame(JFrame frame)

Description

set Icon On Frame

License

Open Source License

Declaration

public static void setIconOnFrame(JFrame frame) 

Method Source Code


//package com.java2s;
/*/*from  ww w. ja  v a 2  s.  co m*/
 * Copyright (C) 2014 J. Soendermann
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

import java.awt.Image;

import java.net.*;

import javax.swing.ImageIcon;
import javax.swing.JFrame;

public class Main {
    private static Image logoImage = null;

    public static void setIconOnFrame(JFrame frame) {
        if (logoImage == null) {
            URL logoResourceURL = frame.getClass().getResource("/resources/SkyggeLogo.png");
            ImageIcon logoImageIcon = new ImageIcon(logoResourceURL);
            logoImage = logoImageIcon.getImage();
        }
        frame.setIconImage(logoImage);
    }
}

Related

  1. setApplicationIcon(JFrame frame)
  2. setDefaultIcon(final JFrame window, final String imagepath)
  3. setIcon(javax.swing.JFrame jFrame, String icon)
  4. setIconImage(JFrame frame, Class clazz, String path)
  5. setIconImageFromResource(JFrame frame, String resource)
  6. setWindowIcon(JFrame jd)