首页javajbuttonJava Swing - 如何设置JButton的工具提示

Java Swing - 如何设置JButton的工具提示

我们想知道如何设置JButton的工具提示。
import javax.swing.JButton;
import javax.swing.JOptionPane;

public class Main {
  public static void main(final String args[]) {
    JButton button = new JButton("Test");
    button.setToolTipText("Help text for the button");

    JOptionPane.showMessageDialog(null, button);
  }
}