I am making a swing app and I have am having trouble getting the input from my check box which I have embedded inside a JOptionPane
At the moment I click a button (comparison) which loads the JOptionPane and I select the two animations to run. I am thinking the reason this won't work is because I am getting the source of the button and not the embedded JCheckBox is there anyway of doing this ??
comparison.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JPanel a1=new JPanel();
a1.add(bubbleCheckBox);
a1.add(quickCheckBox);
a1.add(insertionCheckBox);
a1.add(selectionCheckBox);
a1.add(mergeCheckBox);
JOptionPane.showConfirmDialog(null, a1);
Object buttonPressed =e.getSource();
if (buttonPressed.equals(insertionCheckBox)&&buttonPressed.equals(bubbleCheckBox)) {
SortAnimator animator = new SortAnimator(new InsertionSorter(),new BubbleSorter());
}else if(buttonPressed.equals(insertionCheckBox)&&buttonPressed.equals(quickCheckBox)){
// SortAnimator animator = new SortAnimator(new InsertionSorter(),new quickSorter());
}else if(buttonPressed.equals(insertionCheckBox)&&buttonPressed.equals(selectionCheckBox)){
SortAnimator animator = new SortAnimator(new InsertionSorter(),new SelectionSorter());
}else if(buttonPressed.equals(insertionCheckBox)&&buttonPressed.equals(mergeCheckBox)){
// SortAnimator animator = new SortAnimator(new InsertionSorter(),new mergeSorter());
}else if(buttonPressed.equals(quickCheckBox)&&buttonPressed.equals(bubbleCheckBox)){
//
}else if(buttonPressed.equals(quickCheckBox)&&buttonPressed.equals(mergeCheckBox)){
}else if(buttonPressed.equals(quickCheckBox)&&buttonPressed.equals(selectionCheckBox)){
}else if(buttonPressed.equals(selectionCheckBox)&&buttonPressed.equals(bubbleCheckBox)){
SortAnimator animator = new SortAnimator(new SelectionSorter(),new BubbleSorter());
}else if(buttonPressed.equals(selectionCheckBox)&&buttonPressed.equals(mergeCheckBox)){
}else if (buttonPressed.equals(mergeCheckBox)&&buttonPressed.equals(bubbleCheckBox)){
}else{
//Invalid selection please select a maximum of two different algorithms
}