You are on page 1of 2

3.WAP to display an image and a string in a label on the jframe.

import java.awt.Color;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.ImageIcon;

public class Amity {

public static void main(String[] args) {

Color blue = new Color(150,250,150);

JFrame frame = new JFrame();

frame.setSize(400, 400);

JLabel label = new JLabel("Bhupen");

ImageIcon image = new ImageIcon("C:\\Users\\bhupen\\Desktop\\java


pics\\as.jpg");

JLabel imageLabel = new JLabel(image);

label.setOpaque(true);

label.setBackground(blue);

frame.add(imageLabel);

frame.add(label);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);

OUTPUT

You might also like