저는 스윙의 초록색 사용자입니다. java.sun 튜토리얼의 예제를 사용하여 테이블 클래스를 만들었고 데이터를 동적으로로드 할 수있었습니다. 대화 상자를 표시하여 행에 대한 클릭에 반응 할 수 있기를 원합니다. 선택한 행 번호를 식별하는 이벤트 처리기를 어떻게 추가합니까?스윙 테이블에 mouseClicked 이벤트를 추가하려면 어떻게해야합니까?
주요 기능 코드 :
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
MainWindow window = new MainWindow();
window.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
createAndShowGUI();
//...
}
}
}
}
및
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("Data Table");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up data of the content pane.
TableClass mainTable = new TableClass(fh.getColNames(), fh.getTableContent());
mainTable.setOpaque(true);
frame.setContentPane(mainTable);
//Display the window.
frame.pack();
frame.setVisible(true);
}
당신
서식있는 코드; 잘못된 경우 되돌려주십시오. – trashgod