|
How to use an Icon Editor for use with the JSpinner component |
|
|
This Java Swing tip illustrates a method of using an Icon Editor for use with
the JSpinner component. This editor can display an icon from a list stored in
the spinner.
import javax.swing.*;
import javax.swing.event.*;
public class IconEditor extends JLabel implements ChangeListener {
JSpinner spinner;
Icon icon;
public IconEditor(JSpinner s) {
super((Icon)s.getValue(), CENTER);
icon = (Icon)s.getValue();
spinner = s;
spinner.addChangeListener(this);
}
public void stateChanged(ChangeEvent ce) {
icon = (Icon)spinner.getValue();
setIcon(icon);
}
public JSpinner getSpinner() { return spinner; }
public Icon getIcon() { return icon; }
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.