本文整理汇总了Java中javax.swing.JLabel.addMouseMotionListener方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.addMouseMotionListener方法的具体用法?Java JLabel.addMouseMotionListener怎么用?Java JLabel.addMouseMotionListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.addMouseMotionListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPie1
import javax.swing.JLabel; //导入方法依赖的package包/类
private JLabel setPie1() {
int[] angle = new int[numClust];
double[] prc = info.percent;
int i;
angle[0] = 0;
for (i = 1; i < numClust; i++) {
angle[i] = angle[i - 1] + (int) ((360) * prc[i - 1]);
}
for (; i < angle.length; i++) {
angle[i] = 360;
}
final JLabel l = new JLabel();
final pieChartIcon p = new pieChartIcon(numClust);
l.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
int pos;
pos = p.getPosXY(e.getX(), e.getY());
if (pos != -1) {
l.setToolTipText(tableClusters.getValueAt(pos, 2).toString());
} else {
l.setToolTipText("");
}
}
});
p.setAngle(angle);
l.setIcon(p);
return l;
}
示例2: setPie2
import javax.swing.JLabel; //导入方法依赖的package包/类
private JLabel setPie2(int var) {
int[] angle = new int[numClust];
int i;
angle[0] = 0;
for (i = 1; i < numClust; i++) {
angle[i] = angle[i - 1] + (int) ((360) * info.infoCluster[i].percVar[var]);
}
for (; i < angle.length; i++) {
angle[i] = 360;
}
final JLabel l = new JLabel();
pieChartVars = new pieChartIcon(numClust);
l.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
int pos;
pos = pieChartVars.getPosXY(e.getX(), e.getY());
if (pos != -1) {
l.setToolTipText(tableVars.getValueAt(pos, 1).toString());
} else {
l.setToolTipText("");
}
}
});
pieChartVars.setAngle(angle);
l.setIcon(pieChartVars);
return l;
}