Java JButton class

Introduction

JButton is a push button or a command button.

Constructors of the JButton Class

Constructor                                    Description
JButton()                                      Creates a JButton without any label or icon.
JButton(String text)                           Creates a JButton and sets the specified text as its label.
JButton(Icon icon)                             Creates a JButton with an icon and no label.
JButton(String text, Icon icon)                Creates a JButton with the specified label and icon.
JButton(Action action)                         Creates a JButton with an Action object.

To create a JButton with its text:

JButton closeButton = new JButton("Close");



PreviousNext

Related