Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 15th, 2005, 3:27 AM   #1
jch02140
Newbie
 
Join Date: Jul 2005
Posts: 15
Rep Power: 0 jch02140 is on a distinguished road
Graphic Problem

I am trying to display a line graph from a given arrays of integers, which are stores as x and y points consecutively. (ie. int values[] = {x0,y0,x1,y1,etc...})

However, after I compiled and run the code, no graph is displayed. What's wrong?...

import java.awt.*;
import javax.swing.*;
 
public class GraphicTest extends JPanel
{
	private int values[]={2,5,6,34,12,28,18,24,22,26,25,16,30,41,34,7,39,18};
	
	public void paintGraph(Graphics aGraphics, int values[])
	{
		int x = values[0];
		int y = values[1];
		aGraphics.drawRect(x-2,y-2,x+2,y+2);
		for (int i=0; i<values.length; i+=2)
		{
			aGraphics.drawLine(x,y,values[i],values[i+1]);
			x = values[i];
			y = values[i+1];
			aGraphics.drawRect(x-2,y-2,x+2,y+2);
		}
		
	}
	
	public static void main (String args[])
	{
		JFrame frame = new JFrame();
		frame.setLocation(100,100);
		frame.setSize(400,300);
		frame.getContentPane().add(new GraphicTest());
		frame.show();
	}
}
jch02140 is offline   Reply With Quote
Old Aug 15th, 2005, 11:04 AM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Well, you don't seem to be calling the paintGraph function...
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC