클릭하면 웹 사이트로 직접 이동하는 버튼을 만듭니다. 하지만 내 코드에 오류가 있습니다. 이 오류는 비 정적 변수를 정적 컨텍스트에서 참조 할 수 없다고 말합니다.정적 컨텍스트에서 비 정적 변수를 참조 할 수 없다는 메시지가 나타나는 이유는 무엇입니까?
public static void main(String[] args) throws Exception {
JFrame frame = new JFrame("JLinkButton");
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add("Center", new AnotherLinkButton("www.google.com"));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocation(100, 100);
frame.setVisible(true);
}
항상 오류 메시지와 전체 메시지를 제공하는 줄을 게시하십시오. – jzd
죄송합니다 ... 라인이 있습니다 : frame.getContentPane(). add ("Center", new AnotherLinkButton ("www.google.com")); – steph22