+ 1

Will this code work?

import javax.swing.JFrame ; import javax.swing.ImageIcon ; import javax.swing.JLabel ; class ShowPicture { public static void main (String arms[]){ throws InterruptedException { JFrame frame = new JFrame (); ImageIcon icon = new; ImageIcon ("androidbook.jpg"); JLabel label = new JLabel (icon); frame.add(label); Thread.sleep(5000); frame.setDefaultCloseOperation (JFrame.Exit_ON_CLOSE); frame.pack(); frame.setvisible(true); } } }

20th Jul 2017, 6:10 AM
Sarthak
Sarthak - avatar
1 Answer
+ 4
No you have some errors. Some extra curly braces and some semicolons in the wrong places. Also some method and enum names are wrong. Your code fixed below: package com.example; import javax.swing.JFrame ; import javax.swing.ImageIcon ; import javax.swing.JLabel ; public class ShowPicture { public static void main (String arms[]) throws InterruptedException { JFrame frame = new JFrame (); ImageIcon icon = new ImageIcon ("androidbook.jpg"); JLabel label = new JLabel (icon); frame.add(label); Thread.sleep(5000); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } }
20th Jul 2017, 6:29 AM
ChaoticDawg
ChaoticDawg - avatar