¿alguien me puede decir porqué se borra el botón cuando el graphics g hace un repaint y como hacer para que no lo haga y este siempre visible?
Código:
/**
*
* @author Paulo
*/
public class Panel extends JPanel{
int contador,sumaclick;
int choque;
int c1;
URL url,urltrian;
JButton boton1;
int pulso1;
public Panel(){
boton1=new JButton("boton1");
boton1=new JButton();
ImageIcon icono=new ImageIcon("/imagenes/boton-1.jpg");
boton1.setIcon(icono);
this.add(boton1);
boton1.setMargin(new Insets(30, 30,70, 70));
}
public void paint (Graphics g) {}
clase del jframe
Código:
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
/**
*
* @author Paulo
*/
public class Ventana extends JFrame/* implements MouseListener,KeyListener*/ {
public int n1,n2;
Panel panel;
JButton boton1;
int pulso1;
Botones botones;
public Ventana() throws InterruptedException{
int anchura=407;
int altura=500;
this.setBounds(0,0,anchura,altura);
this.setTitle("ventana");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
panel=new Panel();
this.add(panel);
this.setVisible(true);
}


