Labels and Buttons

Label and Button are the simplest AWT components. Labels and buttons both display text—the difference is that buttons typically have a 3D border, and you can activate a button, which should initiate an action of some sort.

java.awt.Label

A Label is a simple textual label that doesn't do much; in fact a label doesn't do anything other than display text. You can set the component properties of a label, its foreground and background colors, font, cursor, etc.[1]

[1] This is true, of course, for all extensions of java.awt.Component, so we will not mention the fact for any subsequent components we discuss.

Since a label can be resized to be bigger than the text it displays, it comes with the ability to set its alignment—you can display ...

Get Graphic Java™ 1.2, Volume I: AWT, Third 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.