试图替换a to的JButton
控制器。但由于某种原因,它似乎不听任何添加)。任何想法为什么以及如何解决?JSpinner
ImageIcon
mouseclicks(installButtonListeners()
BasicSpinnerUI
MouseListener
public class SpinnerIconBtn extends JFrame {
public SpinnerIconBtn(){
JSpinner spinner = new JSpinner();
spinner.setUI(new JSpinnerArrow());
this.add(spinner);
this.pack();
this.setVisible(true);
}
class JSpinnerArrow extends BasicSpinnerUI {
@Override
protected Component createNextButton() {
Component c = createArrowButton(SwingConstants.NORTH);
c.setName("Spinner.nextButton");
installNextButtonListeners(c);
return c;
}
@Override
protected Component createPreviousButton() {
Component c = createArrowButton(SwingConstants.SOUTH);
c.setName("Spinner.previousButton");
installPreviousButtonListeners(c);
return c;
}
private Component createArrowButton(int direction) {
String path = "/Users/tst.png";
JLabel icon = new JLabel(new ImageIcon(path));
return icon;
}
}
public static void main(String[] args) {
new SpinnerIconBtn();
}
}