For some reasons I have to get the components in a custom JDilog. I tried to do that like this:
private class RepoListDialog extends JDialog {
public RepoListDialog(JFrame jf, String message){
//do something
JButton btConfirm = new JButton("Confirm");
btConfirm.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
for(Component c : RepoListDialog.this.getComponents()){
//do something}
}
});
this.add(btConfirm);
//do something
}
}
But it does not work. I want to know how can I get the components which added in this Dialog by myself? I know it can be done by use rootPane. But I want to know that is there any other ways?
Any help will be highly apreciated.