289 |
comboBox.addKeyListener(keyListener); |
comboBox.addKeyListener(keyListener); |
290 |
|
|
291 |
mouseListener = createMouseListener(); |
mouseListener = createMouseListener(); |
292 |
comboBox.addMouseListener(mouseListener); |
arrowButton.addMouseListener(mouseListener); |
293 |
|
|
294 |
// install listeners that listen to combo box model |
// install listeners that listen to combo box model |
295 |
listDataListener = createListDataListener(); |
listDataListener = createListDataListener(); |
296 |
comboBox.getModel().addListDataListener(listDataListener); |
comboBox.getModel().addListDataListener(listDataListener); |
|
|
|
|
configureArrowButton(); |
|
297 |
} |
} |
298 |
|
|
299 |
/** |
/** |
337 |
comboBox.removeKeyListener(keyListener); |
comboBox.removeKeyListener(keyListener); |
338 |
keyListener = null; |
keyListener = null; |
339 |
|
|
340 |
comboBox.removeMouseListener(mouseListener); |
arrowButton.removeMouseListener(mouseListener); |
341 |
mouseListener = null; |
mouseListener = null; |
342 |
|
|
343 |
comboBox.getModel().removeListDataListener(listDataListener); |
comboBox.getModel().removeListDataListener(listDataListener); |
344 |
listDataListener = null; |
listDataListener = null; |
|
|
|
|
unconfigureArrowButton(); |
|
345 |
} |
} |
346 |
|
|
347 |
/** |
/** |
551 |
*/ |
*/ |
552 |
public void configureArrowButton() |
public void configureArrowButton() |
553 |
{ |
{ |
554 |
arrowButton.addMouseListener(mouseListener); |
arrowButton.setEnabled(comboBox.isEnabled()); |
555 |
|
arrowButton.setFont(comboBox.getFont()); |
556 |
} |
} |
557 |
|
|
558 |
/** |
/** |
562 |
*/ |
*/ |
563 |
public void unconfigureArrowButton() |
public void unconfigureArrowButton() |
564 |
{ |
{ |
|
arrowButton.removeMouseListener(mouseListener); |
|
565 |
} |
} |
566 |
|
|
567 |
/** |
/** |
1266 |
public void mousePressed(MouseEvent e) |
public void mousePressed(MouseEvent e) |
1267 |
{ |
{ |
1268 |
if (comboBox.isEnabled()) |
if (comboBox.isEnabled()) |
1269 |
{ |
toggleOpenClose(); |
|
if (e.getSource() instanceof JComboBox) |
|
|
{ |
|
|
arrowButton.getModel().setPressed(true); |
|
|
arrowButton.getModel().setArmed(true); |
|
|
} |
|
|
|
|
|
comboBox.repaint(); |
|
|
|
|
|
if (e.getSource() instanceof BasicArrowButton) |
|
|
toggleOpenClose(); |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* This method is invoked when mouse is released over the combo box. It |
|
|
* repaints the combo box accordinglly |
|
|
* |
|
|
* @param e the MouseEvent |
|
|
*/ |
|
|
public void mouseReleased(MouseEvent e) |
|
|
{ |
|
|
if (comboBox.isEnabled()) |
|
|
{ |
|
|
if (e.getSource() instanceof JComboBox) |
|
|
{ |
|
|
arrowButton.getModel().setPressed(false); |
|
|
arrowButton.getModel().setArmed(false); |
|
|
} |
|
|
|
|
|
comboBox.repaint(); |
|
|
} |
|
1270 |
} |
} |
1271 |
} |
} |
1272 |
} |
} |