Question: Open the Java project 1410_LABS and add a new package called guiIntro. Create a new JFrame called LabGuiIntro.java Add a blue label on top with
- Open the Java project 1410_LABS and add a new package called guiIntro.
- Create a new JFrame called LabGuiIntro.java
- Add a blue label on top with a green, centered text of size 33. The name of the label should be lblTitle. Refactor the code by extracting a method called newLblTitle. Just as it was demonstrated in Practice - Building a Simple GUI Part 2, we should now have two lines in the constructor that refer to lblTitle. One line that creates the variable and assigns it a new label by calling the method newLblTitle. A second line that adds lblTitle to the North position of the contentPane.
- Add a simple button on the left that says "WEST" Again, refactor the code. This time, extract a method that creates the button. Similar to before, you should end up with two lines of code in the constructor that refer to the button.
- Add a JPanel on the bottom. It is called textPanel. It has a gray background and it includes both a label and a text field. Refactor early on by extracting a method called newTextPanel The label inside textPanel says "Name: " and the font size of the label is 16 The text field is 16 characters wide and the font size is also set to 16
- Fill the remaining area of the JFrame with a red label that has a large orange text. The text size is 77 and it says "Hi" Analogous to the refactoring you did already, extract a method that creates the red label.
- Choose appropriate alignment and add margins/padding to the GUI to achieve a look that is similar to the image provided. There should be some blue space above and below the green title text, there should be some grey space above and below the text field, and there should be some space between the label and the text field at the bottom.
Notice: The GUI is not interactive. No event handlers have been implemented and nothing happens when you click any of the GUI components.This 1410Labs is just a project and will not affect the code. I only need the code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
