I am trying to use buttons to control the actions performed in a window. To do this, I try to return the lines to give commands through the program. So far, I have managed to get this code to work:
@Override public void actionPerformed(ActionEvent e) { setCommand(e.getActionCommand()); } public void setCommand(String g){ command = g; getCommand(); } public String getCommand() { return command; }
However, when I do this in another class, nothing happens:
System.out.print(button.getCommand());
Am I doing something wrong or just using the wrong solution?
source share