473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

problem with ImageIcon

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.

Expand|Select|Wrap|Line Numbers
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.util.*;
  4. class test1{
  5. public static void main(String args[])
  6. {
  7. JFrame f = new JFrame();
  8. f.setSize(1800,2880);
  9. ImageIcon i = new ImageIcon("background.jpg");
  10. JLabel l = new JLabel();
  11. l.setIcon(i);
  12.  
  13. JPanel p = new JPanel();
  14. p.add(l);
  15. //JPanel p = new JPanel(new JLabel(new ImageIcon("background.jpg"))); 
  16. f.add(p);
  17. f.setVisible(true);
  18. f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  19. }
  20. }
  21.  
Attached Images
File Type: jpg background.jpg (33.4 KB, 55 views)
File Type: jpg Screenshot from 2015-10-10 20-47-32.jpg (32.4 KB, 43 views)
Oct 10 '15 #1
0 1121

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: David | last post by:
Hello, I'm starting with java and i'm having problems to display an image in a splitpanel with a scrollbar. I have different files but those required are described below. I think the problem is...
1
by: David | last post by:
Hello I'm writting an apllication and i like to display and offscreen image. However my code doesn't seem to work. It compiles and runs properly but What i want is to associate the button of the...
0
by: Mik | last post by:
I have a problem with drawing ImageIcon objects on a JPanel in a JApplet Everything is ok when I run applet locally, but when it's run from a server the images are not showing ImageIcon objects...
7
by: ITAutobot25 | last post by:
My delete button is not working in my GUI and my due date is today before midnight. Can anyone show me how to correct this error? My assignment statement is below as well as 5 classes. InventoryGUI...
1
by: Neverhood | last post by:
Hi folks, I'm trying to make a small game about being a drug dealer, with a 10x8 grid JPanel. On top of that i have another 10x8 grid JPanel as glassPane for the player icon. I have all the...
5
by: wajedali | last post by:
Hi I am having trouble rendering a combo box with icon near the text. Below is a simple code which demonstrates my problem. import java.awt.Component; import java.util.HashMap; import...
1
crystal2005
by: crystal2005 | last post by:
Hi all, Can anyone tell me why my image doesn't appear in my frame's container? When I change imageIcon to just normal Label, it does go work. In another condition, if i don't use method...
2
by: Coreyja | last post by:
Im trying to display a png image by setting it as a ImageIcon and then putting that in a JLabel. I cant get it to display the image. I am using a null layout as it is the simplest way for me to get...
5
by: Scaran54 | last post by:
Hello, I am following a tutorial but have a problem. With the following code the icons will not appear unless I specify the entire path to where they are located, I cant work out why it wont work,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.