SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Basic Java Help

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Aug 2000
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am new to Java and enrolled in a course to help me learn some basic Java to see if I am interested. I am interested in it and wish to pursue it. Anyways this is my first project so bare with me.

    It is just a basic thermometer and conversion from Fahren. to Celsius.

    If you look here you will find it:
    http://webmasterlane.com/Convert.htm

    I am stuck! As you can see the graph fills downward instead of up. How to I change this I have tried everything.
    Here is the code in question:

    Code:
    private void drawThermometer(Graphics bar) {
    		bar.setColor(Color.red);		
    
    		bar.drawRect(40,40,43,220);		
    
    		bar.fillRect(40,40 + 220,44,sliderValue * 2);
    
    		bar.fillArc(40,235,44,50,360,-180);	
    
    		bar.drawString("20", 22,220);								
    		bar.drawLine(37,220,40,220);
    		bar.drawString("40", 22,180);
    		bar.drawLine(37,180,40,180);
    		bar.drawString("60", 22, 140);
    		bar.drawLine(37,140,40,140);
    		bar.drawString("80", 22, 100);
    		bar.drawLine(37,100,40,100);
    		bar.drawString("100", 15, 60);
    		bar.drawLine(37,60,40,60);
    	}
    Thanks!!
    "Over 2200 Free Webmaster Resources and Tools"
    Search through our continually updated directory of free webmaster resources.
    WebmasterLane.com

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2000
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could someone please take a look. It is due Monday morning and I am absolutly stumped. Please!!
    "Over 2200 Free Webmaster Resources and Tools"
    Search through our continually updated directory of free webmaster resources.
    WebmasterLane.com

  3. #3
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I know this is probably too late, but it looks like you're reading your vertical coordinates wrong. In Java user interfaces (as in most), positive is down and negative is up. Thus, you just need to change the line I've hilighted:

    Code:
    private void drawThermometer(Graphics bar) {
      bar.setColor(Color.red);		
    
      bar.drawRect(40,40,43,220);		
    
      bar.fillRect(40,40+220-(sliderValue*2),44,sliderValue * 2);
    
      bar.fillArc(40,235,44,50,360,-180);	
    
      bar.drawString("20", 22,220);								
      bar.drawLine(37,220,40,220);
      bar.drawString("40", 22,180);
      bar.drawLine(37,180,40,180);
      bar.drawString("60", 22, 140);
      bar.drawLine(37,140,40,140);
      bar.drawString("80", 22, 100);
      bar.drawLine(37,100,40,100);
      bar.drawString("100", 15, 60);
      bar.drawLine(37,60,40,60);
    }
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2000
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank You!

    I have already finished the assignment, but it is good to know anyways. I could never figure it out for the life of me. Now it seems so easy...how could I not get it.

    Thanks again!
    "Over 2200 Free Webmaster Resources and Tools"
    Search through our continually updated directory of free webmaster resources.
    WebmasterLane.com

  5. #5
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you take a look at the documentation of the methods? @java.sun
    I normally find it my best friend.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  6. #6
    SitePoint Zealot
    Join Date
    Aug 2000
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have visitied a few times. I actually looked for this, but could not find. Maybe I just overlooked it.

    I am really beginning to like Java, but the course I take is all in class work and only once a week in a lab, which means it is much harder to learn. It makes me so made because I can do everything like 99% on a computer, but when she gives me a question on paper I know like 80%.

    I wish they gave the tests on the computer, since in real life you are using a computer to code your Java.


    Thanks again!
    "Over 2200 Free Webmaster Resources and Tools"
    Search through our continually updated directory of free webmaster resources.
    WebmasterLane.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •