本文整理匯總了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;
}