Question

When i'm calling the setter in method setButtonGui, my sysout contains the values of exempleBouton. If i make a sysout in another method, buttonGui equals null

public void createGUIButton() {

        JButton exempleBouton = new JButton("Exemple de bouton");
        exempleBouton.setActionCommand("demo");
        exempleBouton.addActionListener(new ButtonListener());

        JFrameGui window = new JFrameGui("test", "test", JFrame.EXIT_ON_CLOSE);
        window.setButtonGui(exempleBouton);
    }

public JButton getButtonGui() {

        return buttonGui;
    }

    public void setButtonGui(JButton buttonGui) {
        System.out.println("SET " + buttonGui);
        this.buttonGui = buttonGui;
    }
Was it helpful?

Solution

i've created a new class and in put my object in there

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top