1 package devisor2.grid.GUI.dialogs; 2 3 import javax.swing.*; 4 import javax.swing.event.*; 5 6 import java.awt.*; 7 import java.awt.event.*; 8 9 import java.util.*; 10 11 import devisor2.grid.options.*; 12 13 /** 14 * The ListSelectionListener class to detect changes in the table 15 * on the Accelerators Tab in OptionsDialog class 16 * 17 * @author Dominik Goeddeke 18 * @version 1.0 (fully tested) 19 */ 20 class AcceleratorTableListSelectionListener implements ListSelectionListener 21 { 22 /** 23 * reference to the OptionsDialog where the JTable is located 24 */ 25 private OptionsDialog parent; 26 27 /** 28 * the constructor just sets references correctly 29 * 30 * @param parent - an OptionsDialog reference 31 */ AcceleratorTableListSelectionListener(OptionsDialog parent)32 public AcceleratorTableListSelectionListener (OptionsDialog parent) 33 { 34 super (); 35 this.parent = parent; 36 } 37 38 /** 39 * updates the parent reference 40 * 41 * @parent - the new Optionsdialog reference 42 */ setParent(OptionsDialog parent)43 public void setParent (OptionsDialog parent) 44 { 45 this.parent = parent; 46 } 47 48 /** 49 * the overridden method declared in the interface 50 */ valueChanged(ListSelectionEvent e)51 public void valueChanged (ListSelectionEvent e) 52 { 53 ListSelectionModel lsm = (ListSelectionModel)e.getSource(); 54 if (e.getValueIsAdjusting() && (!(lsm.isSelectionEmpty()))) 55 return; 56 else 57 { 58 int selectedRow = parent.getAcceleratorTable().getSelectedRow(); 59 if (selectedRow != -1) 60 { 61 Vector data = parent.getAcceleratorTableData(); 62 Object o = data.elementAt(selectedRow); 63 String[] pair = (String[])o; 64 String accString = pair[1]; 65 // set radiobuttons 66 int posplus = accString.indexOf ('+'); 67 if (posplus != -1) 68 { 69 if (accString.substring(0,posplus).equals("CTRL")) 70 parent.getCTRLbutton().doClick(); 71 else 72 { 73 if (accString.substring(0,posplus).equals("ALT")) 74 parent.getALTbutton().doClick(); 75 else 76 { 77 if (accString.substring(0,posplus).equals("SHIFT")) 78 parent.getSHIFTbutton().doClick(); 79 } 80 } 81 } 82 else 83 { 84 parent.getNONEbutton().doClick(); 85 } 86 //set ComboBox 87 parent.getKeySelectionComboBox ().setSelectedItem (accString.substring(posplus+1,accString.length())); 88 } 89 } 90 } 91 } 92