O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required