JButton Example

JButton and ActionListener

It is a simple example which has only two components in it. One is JButton and the other one JLabel. When user clicks the Flip Mode button, the Label changes its caption from Read Mode to Write Mode. Upon clicking the button again, the label restores its original caption Read Mode. So during each click, the Label will alternate between the text Read Mode & Write Mode. Let us proceed with the coding: