Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Project modified in class perform the same 2 modifications on Show GridLayout Project Create a single class with a GridLayout and 10 buttons (added

  • Using Project modified in class perform the same 2 modifications on Show GridLayout Project
  • Create a single class with a GridLayout and 10 buttons (added the long way), breaking the individual component buttons out of the loop to add as individual "object-named" objects and add them individually by name to the frame's content Pane
  • Break the single class into 2 classes: (1) with the default constructor for the frame and (2) with the main() method that creates an instance of the class in (1)
  • In the default constructor, break the individual component buttons out of the loop to add as individual "object-named" objects and add them individually by name to the frame's content Pane

// ShowGridLayout.java: Demonstrate using GridLayout import javax.swing.JButton; import javax.swing.JFrame; import java.awt.GridLayout; import java.awt.Container;

public class ShowGridLayout extends JFrame { /** Default constructor */ public ShowGridLayout() { // Get the content pane of the frame Container container = getContentPane();

// Set GridLayout, 4 rows, 3 columns, and gaps 5 between // components horizontally and vertically container.setLayout(new GridLayout(4, 3, 5, 5));

// Add buttons to the frame for (int i = 1; i <= 10; i++) container.add(new JButton("Component " + i)); }

/** Main method */ public static void main(String[] args) { ShowGridLayout frame = new ShowGridLayout(); frame.setTitle("Show GridLayout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 200); 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

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions

Question

List and describe the types of simulation.

Answered: 1 week ago

Question

=+7. What is progressive discipline?

Answered: 1 week ago

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago