How to drag and drop a JPanel to another JPanel?

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

Was this solution helpful to you?

Just Added Q & A:

Find solution

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.