Results 1 to 5 of 5
- 03-30-2010, 12:10 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 4
- Rep Power
- 0
Little help with Drawing canvas needed
Hello :)
I am a newbie to java, and i am trying to get the user to input a value between one and 500, and have it graphed onto the drawing canvas. Im a bit stuck here and i have got the basics of it drawn onto it, but its not drawing the bars properly where i want them too. can you please have a look at my code and tell me what i am doing wrong.
thankyou
Java Code:public void plotPrices() { // Set up the window for drawing JFrame frame = new JFrame("Core: Plot of numbers"); frame.setSize(700, 600); // 700 pixels wide, 600 pixels high. DrawingCanvas canvas = new DrawingCanvas(); frame.getContentPane().add(canvas, BorderLayout.CENTER); frame.setVisible(true); canvas.drawLine(50,500,600,500); canvas.drawLine(50,500,50,200); Scanner scan = new Scanner(System.in); System.out.println("Enter numbers between 1 & 500, end with 'close'"); double number = 0; double total = 0; double min = Double.MAX_VALUE; double max = Double.MIN_VALUE; while(scan.hasNext()) { int baseX = 500; int baseY = 30; String stringValue = scan.next(); double nextValue = 0; try { nextValue = Double.parseDouble(stringValue); } catch(NumberFormatException nFE) { if(stringValue.equals("close")) { break; } else { System.out.println("Please enter a Number, or 'Close'"); continue; } } total = total + nextValue; if(nextValue < min) min = nextValue; if(nextValue > max) max = nextValue; number++; canvas.drawRect(nextValue, baseX, baseY, nextValue); }
-
- 03-30-2010, 05:27 AM #3
Member
- Join Date
- Mar 2010
- Posts
- 4
- Rep Power
- 0
- 03-30-2010, 10:19 AM #4
Member
- Join Date
- Mar 2010
- Posts
- 4
- Rep Power
- 0
no one can help? This is urgent!
-
Please understand that this is your urgency, not ours. You still haven't given us much to go on as we still have little clue as to what the DrawCanvas class is or does. Please read this section in the smart questions link: How To Ask Questions The Smart Way
Best of luck.
Similar Threads
-
Major help needed with drawing rectangles using JFrame and Mouse Events
By DamienCurr in forum New To JavaReplies: 1Last Post: 07-16-2009, 02:15 PM -
SWT Canvas drawing realtive to image space not canvas space.
By bobbie in forum SWT / JFaceReplies: 0Last Post: 07-05-2009, 12:31 PM -
Using a Canvas
By a_klasanov in forum CLDC and MIDPReplies: 3Last Post: 12-08-2008, 10:36 AM -
a little help needed for card drawing
By carlos123 in forum New To JavaReplies: 3Last Post: 01-09-2008, 03:40 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks