JButton saveButton = new JButton("Save"); saveButton.setToolTipText("Click to save changes");
JButton deleteButton = new JButton("Delete"); deleteButton.setToolTipText("Click to delete selected record");In this example, the tooltip text for the deleteButton is set to "Click to delete selected record". This gives the user a clear idea of what will happen when they click the button. The setToolTipText method is a part of the java.awt.event package, which is a standard Java library for implementing GUI events.