I developed a simple plugin for NetBeans IDE. I have a little problem with default key event on TopComponenet
of Wizard panel:
For example:
I have a wizard with 3 steps. In second step I have a JTextField
where user put some values and after that appear a JList
below this text field. Everything is okay until user choose a some value from list and than press key ENTER then my panel goes to next Step 3. I attach a key listener to list something like:
list = new JList(new PackagesListModel());
list.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(java.awt.event.KeyEvent evt) {
int keyCode = evt.getKeyCode();
if(keyCode == KeyEvent.VK_ENTER){
JList list = (JList)evt.getSource();
Object selectedPackage = list.getSelectedValue();
typePackageField.setText((String)selectedPackage);
}
}
});
But this listener probably is invoking after default listener of TopComponenet
on wizard. How can I prevent moving user to next step using ENTER key?
I don't want this action (when user press ENTER then they go to the next step).
UPDATE:
Forwarding to Kraal answer:
Problem is that i dont know where i can lookking for a JButton Next (to shuting down a listener). It sound strange but how i wrote. Im using a Netbeans Plaform WizzardDescriptor to generate a Wizzard (with 3 steps) . WizzardDescriptor is from package:
org.openide.WizardDescriptor; // Dialogs API
i puted to him a 3 instances of panels: WizardDescriptor.Panel from same package:
org.openide.WizardDescriptor // Dialogs API
it looks like:
panels = new ArrayList<>();
panels.add(new LayoutWizardPanel1(selectedLayout));
panels.add(new LayoutWizardPanel2(selectedLayout));
panels.add(new LayoutWizardPanel3(selectedLayout));
WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator<>(panels));
After this will generated something like:
in my program i have access to WizardDescriptor
http://bits.netbeans.org/dev/javadoc/org-openide-dialogs/org/openide/WizardDescriptor.html
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…