Quick picture to show what is happening
The JSpinner is appearing twice as seen in the picture above. The first appearance at point (0,0) that should not be there is not selectable, editable or useable with no spinner buttons.
The odd thing here is that every other component has no problem. Only the jspinner. I am using Java 7 and developing in Netbeans (not gui developer kit). Is this a bug with java 7? If not what can I try to make my JSpinner paint only 1 time in the area i specified?
Code to illustrate the problem:
I am adding it to a subclass of JPanel as seen here:
public class MyCustomGUI extends JPanel {
private JSpinner entrySpinner;
public MyCustomGUI () {
super(null);
this.setDoubleBuffered(true);
entrySpinner = new JSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1));
add(entrySpinner);
....
I have a method to give it a location:
public void resize() {
entrySpinner.setBounds((int) (this.getWidth() * .2), (int) (this.getHeight() * 0.38), (int) (this.getWidth() * 0.3), (int) (this.getHeight() * 0.1));
}
And I override the paint method here:
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
.. draw shapes..
super.paintComponents(g);
super.validate();
Toolkit.getDefaultToolkit.sync();
g.dispose();
}