Results 1 to 1 of 1
 12192010, 01:50 PM #1Member
 Join Date
 Dec 2010
 Posts
 17
 Rep Power
 0
he graph continues to emerge each time the coordinates is calculated
I want the window remains open and the graph continues to emerge each time the coordinates is calculated the first step: the window opens and there's just ordinate and abscissa. the second stage: once the factorial function computes factorial (k = 2) then the window displays the graph (k = 1, fact (k = 1) = 1) (k = 2, fact (k = 2) = 2) (the line) (as it did the update to the window and it displays the line and the window remains open after the factorial function computes factorial (k = 3) while the window displays the graph (k = 2, fact (k = 2) = 2) (k = 3, fact (k = 3) = 6) (line) ex ..
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;
public class GraphingData11 extends JPanel {
final int PAD = 20;
/*3 variables to draw the line
(k = 1, fact (k = 1) = 1) (k = 2, fact (k = 2) = 2)*/
static int multi;static int multi1;static int k;
/*factorial function*/
public static double factorial(int N){for (int i = 1; i <= N; i++){multi = multi*i;}return multi;}
/*a function that calculates the factorial of k = 1 to 100, and I draw the graph
for each k*/
public static double FUNCTION(){
int k=1;multi1=0;
while (k<=100){factorial(k);
/*can not with the method paintComponent (Graphics g)
paintComponent (Graphics g) I want to call the paintComponent (Graphics g) each time with new cords (k = 1, fact (k = 1) = 1) (k = 2, fact (k = 2) = 2 ) fact (k = 1) is variable and MULTI1 fact (k = 2) is the multivariable
*/
multi1=multi;
k=k+1;}
return 0;}
//the function that draws the dots and lines
protected void paintComponent1(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASIN G,RenderingHints.VALUE_ANTIALIAS_ON);
int w = getWidth(); // Window Width
// Window height
int h = getHeight();
// draw axis.
g2.draw(new Line2D.Double(PAD, PAD, PAD, hPAD));
// draw horizontal axis.
g2.draw(new Line2D.Double(PAD, hPAD, wPAD, hPAD));
// line color
g2.setPaint(Color.red);
// draw the line
g2.draw(new Line2D.Double(PAD + (20*(k1)),h  (PAD +multi1), PAD + (20*(k)), h  (PAD + multi)));
// color dot
g2.setPaint(Color.red);
// draw point
g2.fill(new Ellipse2D.Double(PAD +(20*(k1)),h  (PAD + multi1),2,2));
}
public static void main(String[] args) {
FUNCTION();
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new GraphingData11());
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
}
}
there is the repaint method but I do not know if it works or how it chews and thank you in advance......
Similar Threads

JAVA Programmers Wanted  FullTime and PartTime Positions open
By javatrek2020 in forum Jobs OfferedReplies: 3Last Post: 08232011, 12:46 PM 
Draw graph calculated by the cord at the same time
By khiat in forum New To JavaReplies: 13Last Post: 02012011, 01:34 AM 
real time graph plotting in swing
By elsanthosh in forum AWT / SwingReplies: 1Last Post: 11222010, 04:06 PM 
Java program: ISBN calculated by other 9 digits?
By SNFA in forum New To JavaReplies: 5Last Post: 10092010, 05:22 AM 
Drawing 2D multi axis graph with option to get the coordinates of 2 points (user sel)
By saachin2005 in forum New To JavaReplies: 5Last Post: 10012010, 09:26 PM
Bookmarks