Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.ToolTipManager;

public class Main extends JPanel {
    JButton button = new JButton("ToolTipHere");

    public Main() {
        button.setToolTipText("Press the button !");
        button.addActionListener(e -> {
            JOptionPane.showMessageDialog(button.getParent(), "This disables ToolTips!");
            button.setToolTipText("This is Java! There is no help");
        });
        add(button);
    }

    void start() {
        ToolTipManager ttm = ToolTipManager.sharedInstance();
        ttm.setInitialDelay(0);
        ttm.setDismissDelay(10000);

        Main newContentPane = new Main();
        newContentPane.setOpaque(true);

        JFrame frame = new JFrame("Main");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setContentPane(newContentPane);
        frame.pack();
        frame.setLocation(150, 150);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        Main tte = new Main();
        tte.start();
    }
}