Question

In the field create: Two Font objects. Call them nameFont and dateFont. Set them to whatever...

In the field create:

Two Font objects. Call them nameFont and dateFont. Set them to whatever name, style, and size that you wish. Just make sure they are different.

Two Color objects. Call them nameColor and dateColor. In one use the whole number constructor to create a custom color for your name. In the other use the constructor that takes floating point numbers as percentages to create a color for the date.

An instance of the content pane so that you can add components to it.

Create three JLabels one called lblFName which has your first name in it, one called lblLName that has your last name in it, and one called lblDate that has the date in it.

Create a constructor that will allow you to initialize your application. In it:

Set the application to visible, the size to 300, 300, the title to "First GUI App", and the default close operation to EXIT_ON_CLOSE

Set the layout of the content pane to a GridLayout that is 3 rows by 1 column.

Set the text color and Font to the JLabels that hold you name and date using the Font and Color objects you created.

Add the JLabels to the content pane. In the order of, First Name, Last Name, Date.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.awt.Color;

import java.awt.Font;

import java.awt.GridLayout;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

public class GuiApp

{

public static void main(String args[])

{

GuiApp g=new GuiApp();

}

GuiApp()

{

JFrame jframe;

JPanel anchor;

jframe = new JFrame("First GUI App");

anchor = new JPanel();

  

Font nameFont=new Font("Serif", Font.PLAIN, 15);

Font dateFont=new Font("Serif", Font.ITALIC, 25);

  

Color nameColor=new Color(85,45,55);

Color dateColor=new Color((float)0.3,(float)0.5,(float)0.4);

  

JLabel lblFName =new JLabel("firstname");

JLabel lblLName =new JLabel("lastname");

JLabel lblDate =new JLabel("Date");

  

lblDate.setFont(dateFont);

lblDate.setForeground(nameColor);

  

lblFName.setFont(nameFont);

lblFName.setForeground(nameColor);

  

lblLName.setFont(nameFont);

lblLName.setForeground(nameColor);

anchor.setLayout(new GridLayout(3,1));

anchor.add(lblLName);

anchor.add(lblFName);

anchor.add(lblDate);

  

jframe.setContentPane(anchor);

jframe.setSize(300, 300);

jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

jframe.setVisible(true);

}

}

--------------------

i ajava D RouletteWhe D RecursionTe M GuiAppjava × D WidgetViewiava >99+ 2 import java. awt.Font; 3 import java.awt.GridLayou

Add a comment
Know the answer?
Add Answer to:
In the field create: Two Font objects. Call them nameFont and dateFont. Set them to whatever...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT