I'm trying to make a Weather applet for school but I'm having a problem calling a class to a main class. In the end I will want 3 permanent components (Location, Temperature, Precipitation) then in image box I want to do an if statement that pics the appropriate image from the data in components.
Layout idea
Main Class code
// The "Weather" class.
import java.applet.*;
import javax.swing.*;
import java.awt.*;
public class Weather extends Applet
{
//TempBar Intergers
//int x=
//int y=
//int H= //H = Heat
//PercipBar Intergers
//int x2=
//int y2=
//int P = //P = pericipitation
public void init ()
{
GridLayout umm = new GridLayout(0,2);
PercipBar percip = new PercipBar();
getContentPane.addItem (percip());
}
public void paint (Graphics g)
{
}
}
PercipBar Code
import java.awt.*;
import java.applet.*;
public class PercipBar extends Applet
{
int x2 =2;
int y2 =2;
int P =80;//P = percipitation will be declared in main file
public void paint (Graphics g)
{
g.setColor (Color.black);
g.drawRect (x2, y2, 100, 20);//outline of bar
g.setColor (Color.blue);
g.fillRect (x2+1, y2+4, P, 14 ); //indicator bar (+4 puts space beetween outline bar)
}
}