I have some available x,y values to show some spesific points on a picture and i will send the x,y values to make it draw lines. I am foreign to swing and paint so firstly i made a prototype like this but i have an issue with measures (dimensions).
import javax.swing.*;
import java.awt.*;
class form1 extends JPanel{
public void paint(Graphics g){
super.paint(g);
Stroke stroke = new BasicStroke(4f);
Graphics2D g2d = (Graphics2D) g;
ImageIcon img = new ImageIcon("picture.png"); // not sure if i should use this way to upload a pic
img.paintIcon(this,g,0,0);
g2d.setStroke(stroke);
g2d.drawLine(282,421,547,251); // parameters are x1,y1,x2,y2
}
}
public class test {
public static void main(String[] args) {
JFrame frame = new JFrame("TITLE");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
form1 f = new form1();
frame.add(f);
frame.setSize(1920,1024);
frame.setVisible(true);
}
}
So my x,y values are drawing the correct lines on the true points but my image doesnt be opened in full size, it s like 3/5 of the full image in the shown picture above, image has 2470x1262 size. If i make it smaller via photoshop, then my x,y values wont show the correct points + image is being blurred, i couldn't find a method to set the sizes of image in java, how can i solve this ?