Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(TCO 3) What does the following Java code do? JPanel pane = new JPanel( ); A) Cr

ID: 2316065 • Letter: #

Question

(TCO 3) What does the following Java code do?

            JPanel pane = new JPanel( );

A)       Creates a panel which will organize its components into 5 areas, NORTH, SOUTH, EAST, WEST, CENTER.
    B)   Creates a panel which will organize its components left to right, top to bottom.
       C)Creates a panel which will organize its components into a specific number of rows and columns.
       D)None of the above.

(TCO 3) Given a JFrame object named frame with a default layout manager, what would the display look like given the following code?
            frame.add(button1, BorderLayout.NORTH);
            frame.add(button2, BorderLayout.NORTH);

A)     button1 would be displayed at the top of the window with button 2 beneath it.
    B)   only button 1 would be displayed at the top of the window.
       C)only button 2 would be displayed at the top of the window.
       D)button1 and button2 would be displayed beside each other at the top of the window.

Explanation / Answer

This class inherits methods from the following classes:

java.lang.Object

BorderLayout Example

Create the following java program using any editor of your choice in say D:/ > SWING > com > tutorialspoint > gui >

SwingLayoutDemo.java

Compile the program using command prompt. Go to D:/ > SWING and type the following command.

If no error comes that means compilation is successful. Run the program using following command.

Verify the following output