JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false); // Insert
URL insertUrl = getClass().getClassLoader().getResource(
"org/jgraph/example/resources/insert.gif");
ImageIcon insertIcon = new ImageIcon(insertUrl);
toolbar.add(new AbstractAction("", insertIcon) {
/**
*
*/
private static final long serialVersionUID = -6458545622185018671L; public void actionPerformed(ActionEvent e) {
insert(new Point(10, 10));
}
});如上代码中,如何为工具栏的项加入tooltip???
toolbar.setFloatable(false); // Insert
URL insertUrl = getClass().getClassLoader().getResource(
"org/jgraph/example/resources/insert.gif");
ImageIcon insertIcon = new ImageIcon(insertUrl);
toolbar.add(new AbstractAction("", insertIcon) {
/**
*
*/
private static final long serialVersionUID = -6458545622185018671L; public void actionPerformed(ActionEvent e) {
insert(new Point(10, 10));
}
});如上代码中,如何为工具栏的项加入tooltip???
toolbar的ToolTipText应加在其按钮上,但楼主是用的是AbstractAction,不清楚这样用的意图是?
Image image = icon.getImage();
button.setIcon(icon);
button.setToolTipText(tip);然后,toolBar.add(button);
javax.swing.plaf.ToolTipUI
URL insertUrl = getClass().getClassLoader().getResource(
"org/jgraph/example/resources/insert.gif");
ImageIcon insertIcon = new ImageIcon(insertUrl);
button = toolbar.add(new AbstractAction("", insertIcon) {
/**
*
*/
private static final long serialVersionUID = -6458545622185018671L;
//System.out.println(x); public void actionPerformed(ActionEvent e) {
insert(new Point(10, 10), false, "周期 ");
}
});
button.setToolTipText("新建");