public class WelcomeGUIApp
class GUI extends JFrame
1: //WelcomeGUIApp.java
2: //Displays a welcome message and date in a window, in color.
4: import java.awt.Font;
5: import java.awt.Color;
6: import java.awt.Graphics;
7: import javax.swing.JFrame;
9: public class WelcomeGUIApp
10: {
11: public static void main(String[] args)
12: {
13: GUI app = new GUI("Welcome GUI Application");
14: app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
15: app.setSize(500, 120);
16: app.setVisible(true);
17: }
18: }
21: class GUI extends JFrame
22: {
23: public GUI(String s)
24: {
25: super(s);
26: }
28: public void paint(Graphics g)
29: {
30: //Set the background color (for the JFrame itself)
31: setBackground(Color.YELLOW); //inherited from Component
33: //Declare and set the font you want to use for writing:
34: Font font = new Font("SanSerif", Font.BOLD, 24);
35: g.setFont(font);
37: //Set the color you want to use for writing
38: g.setColor(Color.BLUE);
40: //Finally, display a welcome message and date on the screen
41: g.drawString("Welcome to the Java Workshop!", 65, 65);
42: g.drawString("Friday, May 6, 2005", 65, 90);
43: }
44: }