0

I see there are lots of example in JUNG where a combo box is used to change mouse action, from transforming to picking... however, I do not understand where this behavior is actually coded (unfortunately the code is not commented much and I sometimes have troubles figuring out by myself what each piece of code does)...

could someone point me to the right piece of code where the switch between transforming and picking behavior occurs? In the Show Layout demo I just see:

JComboBox modeBox = graphMouse.getModeComboBox();
modeBox.addItemListener(((DefaultModalGraphMouse<Integer,Number>)vv.getGraphMouse()).getModeListener());

is that all?

Best regards, Simone

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
user299791
  • 2,021
  • 3
  • 31
  • 57

1 Answers1

0

this is my solution so far:

private void mouseComboBoxActionPerformed(java.awt.event.ActionEvent evt) { 
    JComboBox jcb = (JComboBox) evt.getSource();
    String selectedItem = (String)jcb.getSelectedItem();
    if(selectedItem.equals("Transform")){
        gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    } else {
        gm.setMode(ModalGraphMouse.Mode.PICKING);
    }
    vv.repaint();
} 

HTH to someone else! Best, Simone

user299791
  • 2,021
  • 3
  • 31
  • 57