Image

Imagematthias382 wrote in Imagejava_dev 😡frustrated

NoSuchMethodError

OK, so I've got this code snippet that's throwing a NoSuchMethodError, and I can't figure out what the cause is. As far as I can tell, all the methods that I'm calling should exist. It only shows up when I try to use the regular Java compiler. If I try to compile it in Netbeans, it seems to work fine.

import java.awt.*;
import javax.swing.*;

public class MyWindow extends JFrame {

    public void maximize() {
        Toolkit tk;
        Dimension d;
        int w, h;

        tk = getToolkit();

        if(tk.isFrameStateSupported(Frame.MAXIMIZED_BOTH) == false) {
            d = tk.getScreenSize();

            w = new Double(d.getWidth()).intValue();
            h = new Double(d.getHeight()).intValue();

            setSize(w, h);
        } else {
            setExtendedState(Frame.MAXIMIZED_BOTH);
        }
    }

}