求一个关于jtooltip的例子,越简单越好!本人初学者

来源:百度知道 编辑:UC知道 时间:2024/06/14 08:00:38

import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;

/**
* Tool Tip(提示框)的使用
*
* @author ajax_2003
*/
public class ToolTipExample {
public static void main(String[] args ) {
JFrame frame = new JFrame("Tool Tip Demo");
frame.setSize(200, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JLabel label = new JLabel("Hover on me!");
//
// Setting tool tip for our Swing JLabel component
//
label.setToolTipText("My JLabel Tool Tip");

frame.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));
frame.getContentPane().add(label);

frame.setVisible(true);
}
}