Java - Problems loading up image on window?
-
I have no errors compiling my program, but when I execute, the window is not displaying any images unless I drag the window... How can I fix this? Image is 134 by 114 code: import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Tutorial extends JFrame { JPanel jp = new JPanel(); JLabel jl = new JLabel(); public Tutorial() { setTitle("Tutorial"); setVisible(true); setSize(400,200); setDefaultCloseOperation(EXIT_ON_CLO… jl.setIcon(new ImageIcon ("C:\\Users\\J\\Desktop\\ICON.png")); jp.add(jl); add(jp); } public static void main(String[] args) { Tutorial t = new Tutorial(); } }
-
Answer:
dude add one more line of code validate( ); after the line add( jp ); thats it...
John at Yahoo! Answers Visit the source
Related Q & A:
- How do I make a window in Java?Best solution by Stack Overflow
- Why the Window tab gets closed without closing the window?Best solution by support.google.com
- How to Implement Gateway Service something similar to Oracle API gateway Using Java and Java based Open Source frameworks only?Best solution by Quora
- How to get real path of an image in Java?Best solution by Stack Overflow
- Is A Lazy Image Loading Possible?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.