Ecco il codice(Se vuoi posto anche gli errori ricevuti da console):
codice:import java.awt.*; public class area extends Canvas { public void paint(Graphics g) { int a, b; a = Integer.parseInt(pianoCartesiano.X); b = Integer.parseInt(pianoCartesiano.Y); g.drawLine(-300, 0, 300, 0); g.drawLine(0, -300, 0, 300); g.drawLine(a, b, 0, 0); } }
codice:import java.awt.*; public class pianoCartesiano { public static String X; public static String Y; public static void main(String argv[]) { Frame f = new Frame ("traccia linee"); Panel p = new Panel(); Label l1 = new Label("Coordinata x: "); Label l2 = new Label("Coordinata y: "); TextField x = new TextField(20); TextField y = new TextField(20); area a = new area(); f.setSize(640,480); f.setLocation(640,480); f.setVisible(true); f.add(p); f.add(a); p.setLayout(null); p.setBackground(Color.white); p.add(l1); p.add(l2); p.add(x); p.add(y); l1.setBounds(30,20,80,25); l2.setBounds(30,45,80,25); x.setBounds(55,20,110,20); y.setBounds(55,45,110,20); String X = x.getText(); String Y = y.getText(); } }

Rispondi quotando

