Java Reference
In-Depth Information
int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
int weekday = cal.get(Calendar.DAY_OF_WEEK);
// 1 is Sunday, 2 is Monday, ..., 7 is Saturday
Your task is to write a program that prints the following information:
ȗ
The date and weekday that is 100 days from today
ȗ
The weekday of your birthday
ȗ
The date that is 10,000 days from your birthday
Use the birthday of a computer scientist if you don't want to reveal your
own birthday.
΢΢΢G Project 2.2. Run the following program:
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class FrameTester
{
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setSize(200, 200);
JTextField text = new JTextField
("Hello, World!");
text.setBackground(Color.PINK);
frame.add(text);
frame.setDefaultCloseOperation(JFrame.EXIT_
frame.setVisible(true);
}
}
Modify the program as follows:
ȗ
Double the frame size
ȗ
Change the greeting to ȒHello, your name!ȓ
ȗ
Change the background color to pale green (see Exercise P2.5)
78
Search WWH ::




Custom Search