[Java] 툴팁 매니저 구현
[Java] 툴팁 매니저 구현
import java.awt.*;
import javax.swing.*;
public class tooltiptest extends JFrame{
Container contentPane;
//생성자구현
public tooltiptest(){
setTitle("툴팁 지연 시간 제어 실습");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
JLabel cherry = new JLabel(new ImageIcon("이미지/체리.jpg"));
cherry.setToolTipText("체리이미지 툴팁입니다.");
JLabel apple = new JLabel(new ImageIcon("이미지/사과.jpg"));
apple.setToolTipText("사과이미지 툴팁입니다.");
contentPane.add(cherry);
contentPane.add(apple);
ToolTipManager m = ToolTipManager.sharedInstance();
m.setInitialDelay(0);//커서가 올라간 몇초후에 툴을 보여줄것인가 0으로 지정했기에 바로나옴
m.setDismissDelay(10000);//툴이 얼마나 보여질것인가 5000으로 지정했다.
setBounds(400, 200, 500, 300);
setVisible(true);
}
public static void main(String[] args){
new tooltiptest();
}
}