Workshop: Displaying a Danger Message
You can use Java to present news headlines and other information in different ways. One special effect you might see on a web page or graphical user interface is text that fades to black. You also might see the reverse—text that brightens from black to white. This hour's workshop uses the Font and Color classes to create text that cycles in brightness from dark to bright. The text looks like an alert about impending danger, so the panel will be called Danger.
To make the class more useful, the text of the warning will be set as an argument to a constructor. The text that will be used in this example warns of a “Core Breach in Sector 12,” but you can substitute other threatening text of similar length.
Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.