Saturday, 6 February 2016

Make an image under java JFrame

Program

import javax.swing.*;
import java.awt.*;

public class Image_demo
{
   public static void main(String[] args)
    {
  JFrame f = new JFrame("welcome");
   ImageIcon img = new ImageIcon("Desert.jpg");

JLabel lab = new JLabel("",img,JLabel.CENTER);
  f.add(lab);

  f.setLayout(new FlowLayout(FlowLayout.CENTER));
  f.pack();
  f.setVisible(true);
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.setResizable(false);

}
}

output


No comments:

Post a Comment