Can't use loadImage in JFrame NetBeans
in
Integration and Hardware
•
5 months ago
I have add project to NetBeans.
I used in processing and it was good.
Wrote in this way in Interface.class
Error:
I used in processing and it was good.
- PImage img;
- public void setup()
- {
- size(640,360);
- img = loadImage("Grumpy.jpg");
- }
- public void draw()
- {
- image(img,0,0);
- }
Wrote in this way in Interface.class
- public class Interface extends javax.swing.JFrame {
- PImage img;
- /**
- * Creates new form Interface
- */
- public Interface() {
- initComponents();
- MyGrumpy setup = new MyGrumpy();
- setup.loadImage("Grumpy.jpg");
- MyGrumpy draw = new MyGrumpy();
- draw.image(img,20,20,640,360);
- }
Error:
- Exception in thread "main" java.lang.NullPointerException
- at processing.core.PApplet.image(PApplet.java:12258)
- at grumpy.Interface.<init>(Interface.java:24)
- at grumpy.Grumpy.main(Grumpy.java:14)
1