Daniel Sega
Daniel Sega

Reputation: 333

I cannot call my methods from jframe

I have a class called FrameRadar, it is a jframe and implements my interface app, which contains some methods such as update, draw and inputs and so on.

public class FrameRadar extends javax.swing.JFrame implements IApp{
    ...
}

However FrameRadar does not have the main method in it, instead i made another class called StateMenu, which extends a abstract class state. On it i created a jframe object and latter i initialize it.

class StateMenu extends State {

private JFrame mFrame;
...

public void init() {
    java.awt.EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    mFrame = new FrameRadar();
                    mFrame.setVisible(true);
                }
        });
    }
}

The problem is that i was expecting mFrame to be able to call those method but it does not. What i am doing wrong?

Upvotes: 0

Views: 50

Answers (1)

resueman
resueman

Reputation: 10613

You can't call the methods because there are no guarantees that mFrame is a FrameRadar. Either declare it as a FrameRadar, or you need to cast it to FrameRadar before calling the functions.

Upvotes: 1

Related Questions