本文整理汇总了Java中javax.swing.plaf.basic.BasicSliderUI.TrackListener方法的典型用法代码示例。如果您正苦于以下问题:Java BasicSliderUI.TrackListener方法的具体用法?Java BasicSliderUI.TrackListener怎么用?Java BasicSliderUI.TrackListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.plaf.basic.BasicSliderUI
的用法示例。
在下文中一共展示了BasicSliderUI.TrackListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTrackListener
import javax.swing.plaf.basic.BasicSliderUI; //导入方法依赖的package包/类
protected BasicSliderUI.TrackListener createTrackListener(final JSlider s) {
return new TrackListener();
}
示例2: DurationPanel
import javax.swing.plaf.basic.BasicSliderUI; //导入方法依赖的package包/类
public DurationPanel() {
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
current = "0:00";
maximum = "0:00";
currentTime = new JLabel(current);
currentTime.setForeground(Color.WHITE);
maximumTime = new JLabel(maximum);
maximumTime.setForeground(Color.WHITE);
seek = new JSlider() {
private static final long serialVersionUID = -4931644654633925931L;
{
final MouseListener[] listeners = getMouseListeners();
for (final MouseListener l : listeners) {
removeMouseListener(l); // remove UI-installed TrackListener
}
final BasicSliderUI ui = (BasicSliderUI) getUI();
final BasicSliderUI.TrackListener tl = ui.new TrackListener() {
// this is where we jump to absolute value of click
@Override
public void mouseClicked(final MouseEvent e) {
final Point p = e.getPoint();
final int value = ui.valueForXPosition(p.x);
setValue(value);
System.out.println(value);
PlayerFunctions.seek(value);
}
// disable check that will invoke scrollDueToClickInTrack
@Override
public boolean shouldScroll(final int dir) {
return false;
}
};
addMouseListener(tl);
}
};
seek.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(final MouseEvent e) {
if (UISession.getMediaPlayer() != null) {
PlayerFunctions.seek(seek.getValue());
}
}
});
seek.setPreferredSize(new Dimension(250, 25));
setOpaque(false);
add(currentTime);
add(Box.createRigidArea(new Dimension(3, 0)));
add(seek);
add(Box.createRigidArea(new Dimension(3, 0)));
add(maximumTime);
add(Box.createRigidArea(new Dimension(5, 0)));
}