I was trying to put a image on jpanel but i was gettong a zoomed in image.Can someone tell how to make it clear.
Actual image and screenshot of output are attached.
Actual image and screenshot of output are attached.
Code:
import javax.swing.*; import java.awt.*; import java.util.*; class test1{ public static void main(String args[]) { JFrame f = new JFrame(); f.setSize(1800,2880); ImageIcon i = new ImageIcon("background.jpg"); JLabel l = new JLabel(); l.setIcon(i); JPanel p = new JPanel(); p.add(l); //JPanel p = new JPanel(new JLabel(new ImageIcon("background.jpg"))); f.add(p); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }