Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

   

Reply
 
LinkBack Thread Tools Display Modes
Old 10-20-2004, 07:21 PM   #1 (permalink)
Contributing Member
 
cbolts's Avatar
 
Join Date: 02-15-04
Location: Victoria, Canada
Posts: 555
iTrader: 0 / 0%
Latest Blog:
None

cbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of light
Need help with a java app

Hi, I'm writing a lab for a comp course, and i just can't get it to work properly. Could anyone take a look and figure out whats up with it? Its virtually all done...just need to work out a bug or 2. Any help would be awesome.

Lab outline http://hal.cs.camosun.bc.ca/%7Eshadi...bs/F04Lab4.htm

/*
* Author: C. Bolton
* Date: 10/18/04
* Purpose: To call on multiple methods in one program.
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Lab4 extends Applet implements ActionListener, AdjustmentListener{


String myName;
TextField name, seconds;
int totalSeconds;
private Scrollbar slider;
private int sliderValue;
double fran;




public void paint(Graphics g) {


time(g, totalSeconds, 200, 70 );
fran= convert(sliderValue);
tempBox(g);
showStatus("The temp in Fahrenheit is " +fran);
g.drawString("Fahrenheit "+fran+" Celcius "+sliderValue,200,200);
tempChange();

colorInfo(g, 50,70, Color.blue); //calls on the name and info


}//paint method

private void colorInfo(Graphics g, int x, int y, Color c){//draws the name information

g.setColor(c);
g.drawString("****", x,y);
g.drawString("****"+myName, x,y+15);
g.drawString("***Comp 132",x,y+30);
g.drawString("****Section ? ",x,y+45);
g.drawString("*****",x,y+60);
g.drawString("****",x,y+75);

}//colorInfo method


public void init(){

name = new TextField("", 15);
add(name);
name.addActionListener(this);
seconds = new TextField("", 15);
add(seconds);
seconds.addActionListener(this);
}//end of init method

public void actionPerformed(ActionEvent event){
myName = name.getText();
totalSeconds = Integer.parseInt (seconds.getText());
repaint();

}//end of actionPerformed


private void time(Graphics g, int totalSeconds, int x, int y ){

//int totalSeconds = x;
int hr, min, sec;
int rem;
final int CONV1=3600;
final int CONV2=60;

//caculation

g.drawString("the total second is =" + totalSeconds, x,y); //total amount of seconds
hr= totalSeconds/CONV1;
g.drawString("the number of hours is =" + hr, x,y+15); //conversion from sec to hr
rem= totalSeconds % CONV1;
min=rem/CONV2;
g.drawString("the number of minutes is =" + min, x, y+30); //conversion to minutes
sec= rem % CONV2;
g.drawString("the number of seconds is =" + sec, x, y+45); //remainder of all operations in secs

}//end of time method

public double convert(int sliderValue){
return ((sliderValue*9/5) + 32);
}

}
public void adjustmentValueChanged(AdjustmentEvent e){
sliderValue = slider.getValue();
repaint();
}

public void tempChange(){
slider=new Scrollbar(Scrollbar.HORIZONTAL, 0,1,0,45);
add(slider);
slider.addAdjustmentListener(this);
}



private void tempBox(Graphics g){
g.drawRect(70, 200, 5, 100);
g.drawOval(66,298,13,13);
g.setColor(Color.red);
g.fillOval(67,299,12,12);
g.fillRect(71,300-(int)fran, 4, (int)fran+1);


}//class Lab4
cbolts is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-20-2004, 07:41 PM   #2 (permalink)
v7n Mentor
 
imaginemn's Avatar
 
Join Date: 02-18-04
Location: Minneapolis, Minnesota
Posts: 1,946
iTrader: 0 / 0%
Latest Blog:
None

imaginemn is a name known to allimaginemn is a name known to allimaginemn is a name known to allimaginemn is a name known to allimaginemn is a name known to allimaginemn is a name known to allimaginemn is a name known to allimaginemn is a name known to allimaginemn is a name known to allimaginemn is a name known to allimaginemn is a name known to all
Send a message via MSN to imaginemn Send a message via Yahoo to imaginemn Send a message via Skype™ to imaginemn
Without looking at the code start by removing the extra close bracket.

===========================================

public double convert(int sliderValue){
return ((sliderValue*9/5) + 32);
}

} <- Remove this bracket
public void adjustmentValueChanged(AdjustmentEvent e){
sliderValue = slider.getValue();
repaint();
}

===========================================

You have 7 open brackets and 8 close brackets.

imaginemn
__________________
Need a project done? - Set Your Own Price!
Imagine Creative Services
- Design : Marketing : Multimedia : More
imaginemn is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-20-2004, 07:55 PM   #3 (permalink)
Contributing Member
 
cbolts's Avatar
 
Join Date: 02-15-04
Location: Victoria, Canada
Posts: 555
iTrader: 0 / 0%
Latest Blog:
None

cbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of lightcbolts is a glorious beacon of light
Thanks, I corrected that. Its still not working though...compiles without error, but the slider value doesnt register publicly
cbolts is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java vs PHP vs ASP ajhendel Web Design Lobby 3 03-30-2006 02:14 PM
Java - Alternative Sketch Coding Forum 1 07-26-2005 06:23 AM
.NET or Java? Ashish Web Hosting Forum 1 09-09-2004 12:26 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 02:56 AM.
© Copyright 2008 V7 Inc