public class Main extends JFrame{
public static void main(String[] args) {
JFrame jp1 = new JFrame();
jp1.setTitle("Diagram");
Print m = new Print();
jp1.setLayout(null);
jp1.setSize(500,500);
m.setBounds(0,0,500,500);
jp1.add(m);
jp1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jp1.setVisible(true);
}
static class Print extends JPanel{
public void drawDiagram(Graphics g, double[] x, double[] y){
g.setColor(Color.BLUE);
int scale = 100;
int lastX = 0, lastY = 0;
for (int i = 0; i < x.length; i++) {
g.drawLine(lastX*scale, lastY*scale,(int) x[i] * scale,(int) y[i]* scale);
lastX = (int) x[i];
lastY = (int) y[i];
}
}
}
}
I am using java swing and I dont understand why my digram isnt printing.
I have tried using object of class Main but it didnt help.
Could ypu help me with my problem?
Thanks in advance
New contributor
НЕОНОВЫЙ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.