Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello! Modify the IntroPanel class of the LayoutDemo program so that it uses a box layout manager. Use invisible components to put space before and

Hello!

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.

I've been having a lot of trouble with this program. Below I will put the IntroPanel.java and LayoutDemo.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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Support For Data Mining Applications Discovering Knowledge With Inductive Queries Lnai 2682

Authors: Rosa Meo ,Pier L. Lanzi ,Mika Klemettinen

2004th Edition

3540224793, 978-3540224792

More Books

Students also viewed these Databases questions