Java Image Create createImagePanel(Image image, Color backColor)

Here you can find the source of createImagePanel(Image image, Color backColor)

Description

create Image Panel

License

Open Source License

Declaration

public static JPanel createImagePanel(Image image, Color backColor) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 Open Door Logistics (www.opendoorlogistics.com)
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v3
 * which accompanies this distribution, and is available at http://www.gnu.org/licenses/lgpl.txt
 ******************************************************************************/

import java.awt.Color;

import java.awt.Image;

import javax.swing.ImageIcon;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class Main {
    public static JPanel createImagePanel(Image image, Color backColor) {
        JPanel panel = new JPanel();
        panel.add(new JLabel(new ImageIcon(image)));
        if (backColor != null) {
            panel.setBackground(backColor);
        }//from ww w.j av a 2s  .  c  o m
        return panel;
    }
}

Related

  1. createImage(URL url, String description, boolean checkPresence)
  2. createImageCopy(Image image)
  3. createImageFromBase64String(String s)
  4. createImageFromInvisibleComponent(JComponent component)
  5. createImageFromVisibleComponent(JComponent comp, int cw, int ch)
  6. getImage(Class clazz, String path)
  7. getImage(Component component)
  8. getImage(Component component)
  9. getImage(File imageFile)