How to Create a Label in Java

A label component is used for displaying static text. In Figure 1, the text ''How often do you shop with us:" is displayed using a label. To create a label, first declare the object to be
of type JLabel. For example,

JLabel freqLabel;

Then invoke the javax.swing.JLabel constructor, as follows:

freqLabel = new JLabel("How often do you shop with us: ");

No comments:

Post a Comment