# Use a class declared as .pde in a .java file

**URL:** <https://discourse.processing.org/t/use-a-class-declared-as-pde-in-a-java-file/1237>\
**Category:** Coding Questions\
**Created:** [June 25, 2018, 10:07am UTC](https://discourse.processing.org/t/use-a-class-declared-as-pde-in-a-java-file/1237 "2018-06-25T10:07:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manuel](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@Manuel](https://discourse.processing.org/u/Manuel)\
**Post date:** [June 25, 2018, 10:07am UTC](https://discourse.processing.org/t/use-a-class-declared-as-pde-in-a-java-file/1237/1 "2018-06-25T10:07:49Z")

</div>

Hi, I’m using a .java file to contain an enum with extended variables an behaviours, but I want it to contain an object of one of the classes contained in a .pde file, however the compiler says that that class does not exist.

enums.java:

```auto
enum ECAM_Buttons
{
  ECAM_Engines (0,0),
  ECAM_Clr_R(5,2.2f);

  float x_desfase_factor,y_desfase_factor;
  static final int size = ECAM_Buttons.values().length;

  Coordenada btn_desfase=new Coordenada(72, 50);

  ECAM_Buttons(float xdes,float ydes){
    this.x_desfase_factor = xdes;
    this.y_desfase_factor = ydes;
  }
  // ECAM_Buttons(int xdes,int ydes){
  // this.x_desfase_factor = float(xdes);
  // this.y_desfase_factor = float(ydes);
  // }
  ECAM_Buttons(Number xdes,Number ydes){
    this.x_desfase_factor = xdes.floatValue();
    this.y_desfase_factor = ydes.floatValue();
  }
}

```

coordenada.pde:

```auto
class Coordenada{

  float x;
  float y;
  
  Coordenada(){
    x=0;
    y=0;  
  }
  Coordenada(float _x){
    x=_x;
    y=0;  
  }
  Coordenada(float _x,float _y){
    x=_x;
    y=_y;  
  }
  Coordenada(Coordenada c){
    x=c.x;
    y=c.y;  
  }
}

```

I’m trying to do that because otherwise I can’t seem to get an Object of the class Coordenada within the enum, if there’s a better way to do so I’m here to learn 😉

Thanks!

---

<div class="post-metadata">

**Author:** ![mat650](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mat650/32/564_2.png) [@mat650](https://discourse.processing.org/u/mat650)\
**Post date:** [June 25, 2018, 10:54am UTC](https://discourse.processing.org/t/use-a-class-declared-as-pde-in-a-java-file/1237/2 "2018-06-25T10:54:13Z")

</div>

What about making your project a java project without the use of .pde files? Set processing as a library in your java project and extend the classes with PApplet.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 25, 2018, 11:28am UTC](https://discourse.processing.org/t/use-a-class-declared-as-pde-in-a-java-file/1237/3 "2018-06-25T11:28:39Z")

</div>

Simplest solution is to change the extension “.pde” of the file “coordenada.pde” to “.java” as well. 🕶

You can also use Processing’s PVector as a replacement of your Coordenada class: 🤠  
[https://Processing.org/reference/PVector.html](https://Processing.org/reference/PVector.html)

## “enums.java”:

```auto
import processing.core.PVector;

enum ECAM_Buttons {
  ECAM_Engines(0, 0), ECAM_Clr_R(5, 2.2f);

  static final int size = ECAM_Buttons.values().length;
  final PVector btn_desfase = new PVector(72, 50);
  float x_desfase_factor, y_desfase_factor;

  ECAM_Buttons(float xdes, float ydes) {
    x_desfase_factor = xdes;
    y_desfase_factor = ydes;
  }
}

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 25, 2018, 11:46am UTC](https://discourse.processing.org/t/use-a-class-declared-as-pde-in-a-java-file/1237/4 "2018-06-25T11:46:20Z")

</div>

Another replacement is Java’s Point2D.Float class: 🤩  
[https://Docs.Oracle.com/javase/10/docs/api/java/awt/geom/Point2D.Float.html](https://Docs.Oracle.com/javase/10/docs/api/java/awt/geom/Point2D.Float.html)

## “enums.java”:

```auto
//import processing.core.PVector;
import java.awt.geom.Point2D;

enum ECAM_Buttons {
  ECAM_Engines(0, 0), ECAM_Clr_R(5, 2.2f);

  static final int size = ECAM_Buttons.values().length;
  //final PVector btn_desfase = new PVector(72, 50);
  final Point2D.Float btn_desfase = new Point2D.Float(72, 50);
  float x_desfase_factor, y_desfase_factor;

  ECAM_Buttons(float xdes, float ydes) {
    x_desfase_factor = xdes;
    y_desfase_factor = ydes;
  }
}

```
