Adding Images to JLabels in a panel in Java -
I am trying to set the pictures as new jlables and then those JAlbels have been created in the design scene. Add to panels. The program runs fine but no point of view of the pictures or the zylabs can be seen. Here's an example of my code for creating labels
JLabel J0 = new JLab (); J0.setIcon (new imitin ("4.jpeg")); Jellabell j1 = new jlab (); J1.setIcon (new Imagine ("5.jpeg")); Jellabell j2 = new jlab (); J2.setIcon (new Imagine ("6.jpeg")); Jellabell j3 = new jlab (); J3.setIcon (new imeon ("7.jpeg")); Jellabell J4 = New JLab (); J4.setIcon (new imitin ("8.jpeg")); Jellabell j5 = new jlab (); J5.setIcon (new image ("9.jpeg"));
And here is an example of code for adding JLLL to me in the panel.
p1.add (j1); P1.add (j2); P1.add (j3); P1.add (j4); P1.add (j5); P1.add (j6); P1.add (j7); P2.add (j8); P2.add (J9); P2.add (J10);
< Img src = "https://i.stack.imgur.com/jvh8Q.png" alt = "This is a running program, there is no one of the pictures or JLABLES can be seen in the panel">
You must provide a path to all images in your image icon constructor.
Sample, say the path of a picture is e: \\ picture \\ label \\ 1.jpg
.
Then, your code will be added to the image
JLabel J 0 = new JLab (); J0.setIcon (New Imevin ("E: \\ Picture \\ Label \\ 1.jpg")); // ........ and so on ....
Comments
Post a Comment