누군가가 아래의 코드를 살펴보고 저에게 손을 돌려 주면 당신에게 내 인생을 빚을지도 모릅니다. 그래서 여기에 문제가 있습니다. 분명히 제가 playerCreationSelection
을 자신의 클래스에 넣으면 작동하게 할 수 있습니다. 내 질문은 작동하도록되어 있습니다. class superClass
내 삶에 대해 움직일 수 없으므로 움직일 수 없습니다. 어떤 도움도 좋을 것입니다, 모두에게 감사하십시오!메인 클래스에서 액션 리스너와 jframe을 재사용하십시오.
무엇이 잘못되었는지 깜빡했습니다! 그래서 일어날 것은 playerCreationSelection
는 "() playerCreationSeletion"
public class superClass
{
public static void main(String[] args)
{
playerCreationSeletion gui = new playerCreationSeletion();
}
public class playerCreateSelection extends JFrame implements ActionListener
{
//create label
public JLabel playerCreatedLabel;
public void playerCreationSeletion()
{
setSize(WIDTH,HEIGHT);
WindowDestroyer listener = new WindowDestroyer();
addWindowListener(listener);
Container contentPane = getContentPane();
contentPane.setBackground(Color.DARK_GRAY);
contentPane.setLayout(new FlowLayout());
//create button
JButton playerCreationButton = new JButton("Create New Player");
playerCreationButton.addActionListener(this);
contentPane.add(playerCreationButton);
//create label
playerCreatedLabel = new JLabel("Welcome New Player!");
playerCreatedLabel.setVisible(false);
}
public void actionPerformed(ActionEvent e)
{
String actionCommand = e.getActionCommand();
Container contentPane = getContentPane();
if(actionCommand.equals("Create New Player"))
{
contentPane.setBackground(Color.LIGHT_GRAY);
playerCreatedLabel.setVisible(true);
}
}
}
}
public class playerCreateSelection public static class playerCreateSelection – MadProgrammer