and cation is run 12.4 abels, that displays shows one text Using J Labels to the
ID: 3820386 • Letter: A
Question
and cation is run 12.4 abels, that displays shows one text Using J Labels to the window when the Anderson, display text and images Franceschi 5 import java awt.Container. 6 import javax.swing.JFrame import javax.swing. ImageIcon; 8 import javax.swing.JLabel g import java.awt FlowLayout: 10 import java.awt.Color; 12 pu class Dinner extends JFrame 4 private container contents; 15 private JLabel label Text; 16 private JLabel label Image; 18 Constructor 19 public Dinner Super "What's for dinner?" call JFrame constructor 21 23 contents getContent Pane get content pane contents. setLayout new FlowLayout set layout manager use the JLabel constructor with a string argument label Text new JLabel "Sushi tonight?" set label properties color.HHITE label Text setBackground( color. label Text label Text setopaque trueExplanation / Answer
The functionality of the program is, a new window opens and asks the question, "What's for the dinner?". Below that, a text will be visible saying "Sushi Tonight?". Image of sushi is made visible with a text "photo of sushi". And the window will be closed when clicked on the close button.
For this process to run smoothly, a class named "Dinner" is created.which is used as a constructor.In the next few lines of the code, a GUI is designed and properties are set to the GUI to load the image of sushi. In the Main method, an object is created and called.
The import statements in the beginning of the code denote that the properties of this program are being imported from the mentioned packages.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.