LAB ACTIVITY 2A
SWING COMPONENTS WITH LAYOUTS
SWING COMPONENTS WITH LAYOUTS
Learning Outcomes
By the end of this lab, students should be able to :
Write a Java Program using GUI objects from Swing package.
Write a Java program using various type of Layout manager.
Hardware/ Software : Personal Computer, Java Development Kit version X.x.x., NetBeans IDE 12.0
LAB ACTIVITY 2A
Question:
Follow the instructions below to build an interface as depicted in the image below. You are required to use Java Swing components to construct this interface and utilize an appropriate layout.
Open Your IDE: Start your Integrated Development Environment (IDE) like Eclipse, NetBeans, or IntelliJ IDEA.
Create a New Project:
In your IDE, select File > New > Project.
Choose Java Project and click Next.
Name your project ("LabActivity_2") and click Finish.
Create a New Class:
Right-click on the src folder in your project and select New > Class.
Name your class ( "LabActivity_1B") and check the box to include the main method.
Click Finish.
Step 2: Set Up the JFrame
Import Packages: At the top of your class, import both AWT and Swing packages to access necessary GUI components.
Define the Constructor: Define the constructor for your class LabActivity2A, where you configure the JFrame.
Main Method: The main method creates an instance of LabActivity2A, which activates the constructor and initializes the graphical user interface
Set the properties as coding below:
Step 7: Construct all the other components
Step 7: Add the components into Paneand add panels into JFrame
Step 7:Observe your output.