简体   繁体   中英

No Suitable Method Found

This is the method im trying to invoke.

    public void update(int status) {
        if (status == 1)
        {
            setBorder(new LineBorder(Color.YELLOW, BORDERSIZE+1));
        }
        else if (status == 2)
        {
            setBorder(new LineBorder(Color.CYAN, BORDERSIZE+1));
        }
        else if (status == 3)
        {
            setBorder(new LineBorder(Color.BLACK, BORDERSIZE));
        }

        revalidate();
    }

This is the code trying to use it.

private void handleMouseClick(int x, int y, int button) {
    try {
        // This is called by the board squares when they are clicked
        // Handle the logic of updates to the client/game here

        if(button == 1){
            if(x != -1 && y != -1){
                update(1);
                x = -1;
                y = -1;
                updateGrids();
                }
            else{
                update(3);
            }
        }
        else if(button == 3){

        }


    }
    catch (IOException ex) {
        System.err.println(ex);
    }

The update method is inside a class called GridLayout, I've tried to just simply use GridLayout.update(aninteger); but it didn't work for me.

You need an instance of GridLayout object in order to call the update function.

Withouth knowning how GridLayout is related to your existing code I cannot advice further. However if GridLayout is a temporary object you could try:

GridLayout worker = new GridLayout(... whatever ...);
worker.update(aninteger);

Otherwise, you might need to get it from the framework involved, or something along these lines:

this.getGridLayout().update(aninteger);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM