I'm trying to draw a series of points (coordinates) in eclipse, these coordinates are read through two ArrayList, but I have no idea to represent them in the JPanel, I leave some code:
MAIN
public class Servidor extends JFrame {
private static ArrayList<Integer> xPasos=new ArrayList<Integer>();
private static ArrayList<Integer> yPasos=new ArrayList<Integer>();
public static void main(String args[]){
Servidor fondo= new Servidor();
fondo.setSize(380,456);
fondo.setVisible(true);
TestPane p=new TestPane("/imagenes/planta2.png");
fondo.add(p);
Class with the JPanel
public class TestPane extends JPanel {
public void paintComponent(Graphics g){
Dimension d=getSize();
imagen=new ImageIcon(getClass().getResource(url));
g.drawImage(imagen.getImage(),0,0,d.width,d.height, null);
setOpaque(false);
//Dibujar la coordenada en un sitio exacto
g.setColor(Color.red);
g.fillOval(x, y, SIZE, SIZE);
g.drawString("Punto de partida:("+x+", "+y+")", 5, 15);
//Intento de dibujar las coordenadas en un sitio exacto
g.setColor(Color.green);
for(int i=0;i<xPasos.size();i++){
g.fillOval(xPasos.get(i), yPasos.get(i), 3,3);
super.paintComponent(g);
}
}
That is, my goal is to pass the values of the ArrayList (which have values even if it is not visible in the code) to the class with the JPanel to draw them, if code is included I would appreciate it a lot
Greetings