Question: *Edit: It doesn't really specify a required input or output format. As long as you get a result, that's fine. It has to be in

*Edit: It doesn't really specify a required input or output format. As long as you get a result, that's fine. It has to be in Java.*

Please help me with this Java assignment. I'll place the IntroPanel.java and LayoutDemo.java templates below.

The following statement below is my assignment:

Modify the IntroPanel class of the LayoutDemo program so that it uses a box layout manager. Use invisible components to put space before and between the two labels on the panel.

IntroPanel.java

//******************************************************************** // IntroPanel.java Authors: Lewis/Loftus // // Represents the introduction panel for the LayoutDemo program. //********************************************************************

import java.awt.*; import javax.swing.*;

public class IntroPanel extends JPanel { //----------------------------------------------------------------- // Sets up this panel with two labels. //----------------------------------------------------------------- public IntroPanel() { setBackground (Color.green);

JLabel l1 = new JLabel ("Layout Manager Demonstration"); JLabel l2 = new JLabel ("Choose a tab to see an example of " + "a layout manager.");

add (l1); add (l2); } }

========================================================================

LayoutDemo.java

//******************************************************************** // LayoutDemo.java Authors: Lewis/Loftus // // Demonstrates the use of flow, border, grid, and box layouts. //********************************************************************

import javax.swing.*;

public class LayoutDemo { //----------------------------------------------------------------- // Sets up a frame containing a tabbed pane. The panel on each // tab demonstrates a different layout manager. //----------------------------------------------------------------- public static void main (String[] args) { JFrame frame = new JFrame ("Layout Manager Demo"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

JTabbedPane tp = new JTabbedPane(); tp.addTab ("Intro", new IntroPanel()); // IntroPanel object created, added to tp tp.addTab ("Flow", new FlowPanel()); // FlowPanel object created tp.addTab ("Border", new BorderPanel()); // BorderPanel object created tp.addTab ("Grid", new GridPanel()); // GridPanel object created tp.addTab ("Box", new BoxPanel()); // BoxPanel object created

frame.getContentPane().add(tp); frame.pack(); frame.setVisible(true); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!