package org.kodejava.swing;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.WindowConstants;
import java.awt.FlowLayout;
import java.awt.HeadlessException;
public class DisableToolTip extends JFrame {
public DisableToolTip() throws HeadlessException {
initComponent();
}
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new DisableToolTip().setVisible(true));
}
private void initComponent() {
setSize(500, 500);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));
JButton disable = new JButton("DISABLE");
disable.setToolTipText("Application tool tip will be disabled.");
disable.addActionListener(e -> {
// Disable tool tip for the entire application
ToolTipManager.sharedInstance().setEnabled(false);
});
JButton enable = new JButton("ENABLE");
enable.setToolTipText("Application tool tip will be enabled.");
enable.addActionListener(e -> {
// Enable tool tip for the entire application
ToolTipManager.sharedInstance().setEnabled(true);
});
getContentPane().add(enable);
getContentPane().add(disable);
}
}
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024