Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4336859

ToolTipManager setReshowDelay() is not working

XMLWordPrintable

    • beta
    • sparc
    • solaris_7

      As demonstrated in the following program which has 2 pink test buttons that
      has the tooltip texts and 3 comboboxes to select the timing for the 3
      parameter of delays. The "initial" and "dismiss" work as expected. However,
      the "reshow" which doesn't matter whether I set it greater or less than
      the "initial", the tooltip always wait for an "initial" time interval to pop up?

      Roger Pham 5/9/2000
      --------------------------------------------------------------------------------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.event.*;

      public class JTT extends JFrame {

          JTT() {
      Container C = getContentPane();
      C.setLayout(new FlowLayout());

      JButton b1 = new JButton("Button 1");
      JButton b2 = new JButton("Button 2");
      C.add(b1);
      C.add(b2);

      b1.setBackground(Color.pink);
      b2.setBackground(Color.pink);
      b1.setToolTipText("Button 1");
      b2.setToolTipText("Button 2");

      final ToolTipManager ttm = ToolTipManager.sharedInstance();
      System.out.println(ttm.isEnabled());
      ttm.setInitialDelay(0);
      ttm.setDismissDelay(0);
      ttm.setReshowDelay(0);

      JCheckBox cb = new JCheckBox("enable tooltip", true);
      cb.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent e) {
      ttm.setEnabled((e.getStateChange() == ItemEvent.SELECTED));
      }
      });

      final JComboBox initial = new JComboBox(new Object[] {
      "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
      });
      initial.addActionListener(new ActionListener () {
      public void actionPerformed(ActionEvent e) {
      int delay = initial.getSelectedIndex();
      delay *= 1000;
      ttm.setInitialDelay(delay);
      System.out.println("Initial delay = " + delay);
      }
      });

      final JComboBox dismiss = new JComboBox(new Object[] {
      "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
      });
      dismiss.addActionListener(new ActionListener () {
      public void actionPerformed(ActionEvent e) {
      int delay = dismiss.getSelectedIndex();
      delay *= 1000;
      ttm.setDismissDelay(delay);
      System.out.println("Dismiss delay = " + delay);
      }
      });

      final JComboBox reshow = new JComboBox(new Object[] {
      "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
      });
      reshow.addActionListener(new ActionListener () {
      public void actionPerformed(ActionEvent e) {
      int delay = reshow.getSelectedIndex();
      delay *= 1000;
      ttm.setReshowDelay(delay);
      System.out.println("reshow delay = " + delay);
      }
      });

      C.add(new JLabel("Initial Delay"));
      C.add(initial);
      C.add(new JLabel("Dismiss Delay"));
      C.add(dismiss);
      C.add(new JLabel("Reshow Delay"));
      C.add(reshow);
      C.add(cb);

      pack();
      setSize(750, 200);
      setVisible(true);
      addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent we) {
                      System.exit(0);
                  }
              });
          }

          public static void main(String argv[]) {
      new JTT();
          }
      }

            svioletsunw Scott Violet (Inactive)
            rphamsunw Roger Pham (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: