I am trying to create a simple JFrame with a text tip on hover.
The JFrame appears to appear well, however, the text tip never pops up. Can anyone help me troubleshoot what might be the problem? I am not getting any errors.
Main Class
import javax.swing.JFrame;
public class PracticeMain {
public static void main(String args[]){
Sub obj = new Sub();
obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
obj.setSize(275,150);
obj.setVisible(true);
}
}
Sub Class
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Sub extends JFrame{
private JLabel item1;
public Sub(){
//adds title
super("MY TITLE");
//gives us the default layout
setLayout(new FlowLayout());
item1 = new JLabel("This is a sentence");
item1.setToolTipText("help tip");
add(item1);
}
}
Well, I’ve compiled it and tooltip text appears. You should wait for about two seconds for it to show.