

A user can input non-formatted text in the box. JTextField renders an editable single-line text box.

This constructor returns a label with text. It does not generate any event.Įxample: JLabel textLbl = new JLabel("This is a text label.") JLabel class is used to render a read-only text label or images on the UI. It returns a button with the home icon and text Home. JButton btn2 = new JButton(homeIcon, "Home") It returns a button with a homeIcon on it. This constructor returns a button with text Ok on it. A JButton can be implemented in the application by calling one of its constructors.Įxample: JButton okBtn = new JButton("Ok")

It generates an event when clicked and double-clicked. The button can contain some display text or image. JButton class is used to create a push-button on the UI. Note: We would be using this image icon in further examples.
