Playing Compiler
Find the errors in the following program, which is supposed to display a picture of a smile with the heading “Smile”.
import javax.swing.*; public class MySecondFrame extends JFrame { public MySecondFrame () { add(new JButton("Smile"), BorderLayout.NORTH); // adds image of smile add(new IconImage(“smile.jpg”, BorderLayout.CENTER); // in center with heading setBounds(0,0,300,3 // below } public MySecondFrame (String title) { super(title); setBounds(0, 0, 300, 300); } }The following test class creates, displays, and closes a MySecondFrame frame.
import javax.swing.*; public class TestMySecondFrame { public static void main(String[] args) { JFrame frame = new MySecondFrame ("This is a test"); frame.setVisible(true); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.