FaceDraw.Java....i cant compile it idk what is wrong


#1
import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;
import javax.swing.JPanel;
import javax.swing.*;

//Face class

public class FaceDraw{

int width,height,x,y;
String smileStatus; //default constructor
public FaceDraw()

{

}

// Getters and Setters for width,height,x,y

public int getWidth(){
return width;
}

public void setWidth(int width){

this.width=width;

}

public int getHeight()

{

return height;

}

public void setHeight(int height)

{

this.height=height;

}

public int getX()

{

return x;

}

public void setX(int x)

{

this.x=x;

}

public int getY()

{

return y;

}

public void setY(int y)

{

this.y=y;

}

public String getSmileStatus()

{

return smileStatus;

}

public void setSmileStatus(String smileStatus)

{

this.smileStatus=smileStatus;

}

// to my string method

public String toString()

{

return super.toString();

}

}

//=========== FacePanel.java ===========


//FacePanel class

public class FacePanel extends JPanel

{

private static final long serialVersionUID = 1L;

ArrayList<Face>faces;

public FacePanel (ArrayList<Face>faces)

{

this.faces=faces;

}

@Override

protected void paintComponent(Graphics graph)

{

//Super paint component

graph.setColor(Color.BLUE);

// For each Dimension in the Arraylist

for(int i=0;i<faces.size();i++){

String smileStatus=faces.get(i).getSmileStatus();

if(smileStatus!=null){

if(smileStatus=="Smile")

graph.drawArc(faces.get(i).getX(), faces.get(i).getY(), faces.get(i).getWidth(), faces.get(i).getHeight(), 0, -180);

else

graph.drawArc(faces.get(i).getX(), faces.get(i).getY(), faces.get(i).getWidth(), faces.get(i).getHeight(), 0, 180);

System.out.println(smileStatus);

}

}

}

}

//===== FaceFrame.java ==============



//FaceFrame class

public class FaceFrame extends JFrame

{

private static final long serialVersionUID = 1L;

public static ArrayList<Face> facelist = new ArrayList<Face>();

public FaceFrame(String title)

{

new JFrame(title);

setBackground(Color.WHITE);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setVisible(true);

setSize(1700, 800);

add(new FacePanel(facelist));

}

public static void addToList(Face face)

{

facelist.add(face);

}

public static void main(String args[])

{

//First Face

Face face1 = new Face();

//Lip dimensions

face1.setX(180);

face1.setY(350);

face1.setWidth(150);

face1.setHeight(20);

face1.setSmileStatus("Smile");

// face dimensions

Face face2 = new Face();

face2.setX(100);

face2.setY(100);

face2.setWidth(300);

face2.setHeight(400);

//Left Eye

Face face3 = new Face();

face3.setX(195);

face3.setY(210);

face3.setWidth(20);

face3.setHeight(20);

//Right eye

Face face4 = new Face();

face4.setX(295);

face4.setY(210);

face4.setWidth(20);

face4.setHeight(20);

//Second Face

Face face5 = new Face();

//Lip dimensions

face5.setX(580);

face5.setY(350);

face5.setWidth(150);

face5.setHeight(40);

face5.setSmileStatus("Frown");

// face dimensions

Face face6 = new Face();

face6.setX(500);

face6.setY(100);

face6.setWidth(300);

face6.setHeight(400);

//Left Eye

Face face7 = new Face();

face7.setX(595);

face7.setY(210);

face7.setWidth(20);

face7.setHeight(20);

//Right eye

Face face8 = new Face();

face8.setX(695);

face8.setY(210);

face8.setWidth(20);

face8.setHeight(20);

//Third Face

Face face9 = new Face();

//Lip dimensions

face9.setX(980);

face9.setY(350);

face9.setWidth(150);

face9.setHeight(0);

face9.setSmileStatus("Neutral");

// face dimensions

Face face10 = new Face();

face10.setX(900);

face10.setY(100);

face10.setWidth(300);

face10.setHeight(400);

//Left Eye

Face face11 = new Face();

face11.setX(995);

face11.setY(210);

face11.setWidth(20);

face11.setHeight(20);

//Right eye

Face face12 = new Face();

face12.setX(1095);

face12.setY(210);

face12.setWidth(20);

face12.setHeight(20);

//Adding all the face objects to list

addToList(face1);

addToList(face2);

addToList(face3);

addToList(face4);

addToList(face5);

addToList(face6);

addToList(face7);

addToList(face8);

addToList(face9);

addToList(face10);

addToList(face11);

addToList(face12);

new FaceFrame("Draw Face Example");

//drawing face

}

}

#2

every time i compile i get this
PS C:\Users\Crist\FaceDraw> javac ./FaceDraw.java
.\FaceDraw.java:112: error: class FacePanel is public, should be declared in a file named FacePanel.java
public class FacePanel extends JPanel
^
.\FaceDraw.java:170: error: class FaceFrame is public, should be declared in a file named FaceFrame.java
public class FaceFrame extends JFrame
^
.\FaceDraw.java:118: error: cannot find symbol
ArrayListfaces;
^
symbol: class Face
location: class FacePanel
.\FaceDraw.java:120: error: cannot find symbol
public FacePanel (ArrayListfaces)
^
symbol: class Face
location: class FacePanel
.\FaceDraw.java:176: error: cannot find symbol
public static ArrayList facelist = new ArrayList();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:196: error: cannot find symbol
public static void addToList(Face face)
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:176: error: cannot find symbol
public static ArrayList facelist = new ArrayList();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:210: error: cannot find symbol
Face face1 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:210: error: cannot find symbol
Face face1 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:226: error: cannot find symbol
Face face2 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:226: error: cannot find symbol
Face face2 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:238: error: cannot find symbol
Face face3 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:238: error: cannot find symbol
Face face3 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:250: error: cannot find symbol
Face face4 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:250: error: cannot find symbol
Face face4 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:262: error: cannot find symbol
Face face5 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:262: error: cannot find symbol
Face face5 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:278: error: cannot find symbol
Face face6 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:278: error: cannot find symbol
Face face6 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:290: error: cannot find symbol
Face face7 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:290: error: cannot find symbol
Face face7 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:302: error: cannot find symbol
Face face8 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:302: error: cannot find symbol
Face face8 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:314: error: cannot find symbol
Face face9 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:314: error: cannot find symbol
Face face9 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:330: error: cannot find symbol
Face face10 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:330: error: cannot find symbol
Face face10 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:342: error: cannot find symbol
Face face11 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:342: error: cannot find symbol
Face face11 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:354: error: cannot find symbol
Face face12 = new Face();
^
symbol: class Face
location: class FaceFrame
.\FaceDraw.java:354: error: cannot find symbol
Face face12 = new Face();
^
symbol: class Face
location: class FaceFrame
31 errors
PS C:\Users\Crist\FaceDraw>