Java Code Examples for java.awt.event.MouseListener

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project sikuli, under directory /extensions/guide/src/main/java/org/sikuli/guide/.

Source file: UndoDrawing.java

  22 
vote

public UndoableDrawingPanel(){
  MouseListener mouseListener=new MouseAdapter(){
    public void mouseReleased(    MouseEvent mouseEvent){
      undoableEditSupport.postEdit(new UndoableDrawEdit(UndoableDrawingPanel.this));
      polygon.addPoint(mouseEvent.getX(),mouseEvent.getY());
      repaint();
    }
  }
;
  addMouseListener(mouseListener);
}
 

Example 2

From project codjo-data-process, under directory /codjo-data-process-common/src/test/java/net/codjo/dataprocess/common/eventsbinder/dynalistener/.

Source file: DynamicListenerTest.java

  21 
vote

@Test public void mouseListener(){
  assertThat(eventReactionMock.getEventObject(),nullValue());
  assertThat(eventReactionMock.getMethodCalled(),nullValue());
  MouseEvent mouseEvent=new MouseEvent(new JButton(),1,1,1,1,1,1,false);
  MouseListener mouseListener=(MouseListener)DynamicListener.createEventListener(MouseListener.class,eventReactionMock,eventCheckerMock);
  mouseListener.mouseClicked(mouseEvent);
  assertThat("mouseClicked",equalTo(eventReactionMock.getMethodCalled()));
  assertThat(mouseEvent,is(sameInstance(eventReactionMock.getEventObject())));
  eventReactionMock.clear();
  assertThat(eventReactionMock.getEventObject(),nullValue());
  assertThat(eventReactionMock.getMethodCalled(),nullValue());
  mouseListener.mouseEntered(mouseEvent);
  assertThat("mouseEntered",equalTo(eventReactionMock.getMethodCalled()));
  assertThat(mouseEvent,is(sameInstance(eventReactionMock.getEventObject())));
  eventReactionMock.clear();
  assertThat(eventReactionMock.getEventObject(),nullValue());
  assertThat(eventReactionMock.getMethodCalled(),nullValue());
  mouseListener.mouseExited(mouseEvent);
  assertThat("mouseExited",equalTo(eventReactionMock.getMethodCalled()));
  assertThat(mouseEvent,is(sameInstance(eventReactionMock.getEventObject())));
  eventReactionMock.clear();
  assertThat(eventReactionMock.getEventObject(),nullValue());
  assertThat(eventReactionMock.getMethodCalled(),nullValue());
  eventCheckerMock.setMockCkeckEvent(false);
  mouseListener.mouseExited(mouseEvent);
  assertThat(eventReactionMock.getEventObject(),nullValue());
  assertThat(eventReactionMock.getMethodCalled(),nullValue());
}
 

Example 3

From project codjo-standalone-common, under directory /src/main/java/net/codjo/gui/.

Source file: ExplorerDataWindow.java

  21 
vote

/** 
 * Init GUI.
 */
private void jbInit(){
  final JTree tree=explorer.getTree();
  border1=BorderFactory.createEtchedBorder(Color.white,new Color(134,134,134));
  titledBorder1=new TitledBorder(border1,"Filtres d'affichage");
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.putClientProperty("JTree.lineStyle","Angled");
  tree.setShowsRootHandles(true);
  ToolTipManager.sharedInstance().registerComponent(tree);
  setFrameIcon(UIManager.getIcon("DataExplorer.open"));
  this.setPreferredSize(new Dimension(325,600));
  this.getContentPane().setBackground(Color.lightGray);
  this.getContentPane().setLayout(borderLayout2);
  MouseListener ml=new java.awt.event.MouseAdapter(){
    /** 
 * Determine la table s?ectionn? par un double click.
 * @param evt Evenement de la souris.
 */
    public void mousePressed(    MouseEvent evt){
      DefaultMutableTreeNode nodeInfo=(DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
      int selRow=tree.getRowForLocation(evt.getX(),evt.getY());
      if (selRow != -1) {
        if (evt.getClickCount() == 2) {
          Table table=(Table)nodeInfo.getUserObject();
          execute(table);
        }
      }
    }
  }
;
  tree.addMouseListener(ml);
  filterPanel.setBorder(titledBorder1);
  explorerPanel.setLayout(borderLayout1);
  JScrollPane treeView=new JScrollPane(tree);
  this.getContentPane().add(explorerPanel,BorderLayout.CENTER);
  explorerPanel.add(treeView,BorderLayout.CENTER);
  this.getContentPane().add(filterPanel,BorderLayout.NORTH);
}
 

Example 4

From project ISAcreator, under directory /src/main/java/org/isatools/isacreator/settings/.

Source file: SettingsUtil.java

  21 
vote

public void createGUI(){
  setLayout(new BorderLayout());
  menuPanels.getMain().hideGlassPane();
  createSouthPanel(false);
  createWestPanel(logo,info);
  MouseListener backButtonListener=new MouseAdapter(){
    public void mouseEntered(    MouseEvent mouseEvent){
      backButton.setIcon(backOver);
    }
    public void mouseExited(    MouseEvent mouseEvent){
      backButton.setIcon(back);
    }
    public void mousePressed(    MouseEvent mouseEvent){
      backButton.setIcon(back);
      SwingUtilities.invokeLater(new Runnable(){
        public void run(){
          callUpdate();
          menuPanels.getMain().setCurrentPage(menuPanels);
          menuPanels.getMain().setGlassPanelContents(menuPanels.getMainMenuGUI());
          menuPanels.startAnimation();
        }
      }
);
    }
  }
;
  assignListenerToLabel(backButton,backButtonListener);
  setOpaque(false);
}
 

Example 5

From project jPOS, under directory /jpos/src/main/java/org/jpos/iso/gui/.

Source file: ISOMeter.java

  21 
vote

public ISOMeter(ISOChannelPanel parent){
  super();
  this.parent=parent;
  fontBig=new Font("Helvetica",Font.ITALIC,mass * 3 / 4);
  fontSmall=new Font("Helvetica",Font.PLAIN,10);
  yPoints=new int[width];
  xPoints=new int[width];
  for (int i=0; i < width; i++) {
    xPoints[i]=i;
    yPoints[i]=mass;
  }
  positiveText=null;
  negativeText=null;
  positiveCounter=negativeCounter="";
  connected=false;
  MouseListener mouseListener=new MouseAdapter(){
    public void mouseClicked(    MouseEvent e){
      showLogList();
    }
  }
;
  addMouseListener(mouseListener);
}
 

Example 6

From project packetsamurai, under directory /src/com/l2j/packetsamurai/gui/.

Source file: Main.java

  21 
vote

public void showInterfaceSelector(String[] interfaceNames){
  _selectInterfaceWindow=new JDialog(_frame);
  _selectInterfaceWindow.setTitle("Double-Click to Select the Interface");
  _selectInterfaceWindow.setLocationRelativeTo(_frame);
  _interfaceList=new JList(interfaceNames);
  _interfaceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  JScrollPane scrollPane=new JScrollPane(_interfaceList);
  MouseListener mouseListener=new MouseAdapter(){
    public void mouseClicked(    MouseEvent e){
      if (e.getClickCount() == 2) {
        int index=_interfaceList.locationToIndex(e.getPoint());
        if (Captor.getInstance().getCurrentDeviceId() == index) {
          _selectInterfaceWindow.dispose();
          return;
        }
        Captor.getInstance().openDevice(index);
        PacketSamurai.setConfigProperty("NetworkInterface",Integer.toString(index));
        _selectInterfaceWindow.dispose();
      }
    }
  }
;
  _interfaceList.addMouseListener(mouseListener);
  _selectInterfaceWindow.add(scrollPane);
  _selectInterfaceWindow.setSize(400,350);
  _selectInterfaceWindow.setVisible(true);
}
 

Example 7

From project Agot-Java, under directory /src/main/java/got/test/.

Source file: TestMainUI.java

  20 
vote

public MainPanel(TestMainUI fram){
  this.screen=Utility.createImage(width,height,true);
  this.setPreferredSize(new Dimension(width,height));
  this.graphics=(Graphics2D)screen.getGraphics();
  graphics.drawImage(backgroundImage,0,0,null);
  this.fram=fram;
  this.repaint();
  this.addMouseListener(new MouseListener(){
    @Override public void mouseClicked(    MouseEvent e){
      Timer timer=new Timer(3000,new ActionListener(){
        @Override public void actionPerformed(        ActionEvent e){
          Random random=new Random(System.nanoTime());
          if (MainPanel.this.fram.state == 0) {
            new InfoStatusDialog(TestMainUI.this,String.valueOf(random.nextLong()));
          }
        }
      }
);
      timer.start();
      timer.setRepeats(true);
    }
    @Override public void mouseEntered(    MouseEvent e){
    }
    @Override public void mouseExited(    MouseEvent e){
    }
    @Override public void mousePressed(    MouseEvent e){
    }
    @Override public void mouseReleased(    MouseEvent e){
    }
  }
);
}
 

Example 8

From project Clotho-Core, under directory /ClothoFabApps/FabDash/src/org/clothocore/widget/fabdash/browser/.

Source file: SearchBar.java

  20 
vote

public void setResults(final Collection outcoll,final ObjType type,final JList list){
  list.setModel(new ListModel(){
    @Override public int getSize(){
      return outcoll.getAll(type).size();
    }
    @Override public ObjBase getElementAt(    int index){
      return outcoll.getAll(type).get(index);
    }
    @Override public void addListDataListener(    ListDataListener l){
    }
    @Override public void removeListDataListener(    ListDataListener l){
    }
  }
);
  repaint();
  list.addMouseListener(new MouseListener(){
    @Override public void mouseClicked(    MouseEvent e){
      if (list.getSelectedIndex() > -1) {
        _obp=new ObjBasePopup(list,(ObjBase)list.getModel().getElementAt(list.getSelectedIndex()));
      }
    }
    @Override public void mousePressed(    MouseEvent e){
    }
    @Override public void mouseReleased(    MouseEvent e){
    }
    @Override public void mouseEntered(    MouseEvent e){
    }
    @Override public void mouseExited(    MouseEvent e){
    }
  }
);
}
 

Example 9

From project hudsontrayapp-plugin, under directory /client-common/src/main/java/org/hudson/trayapp/gui/.

Source file: ServerResultsPanel.java

  20 
vote

/** 
 * This method initializes resultsTable	
 * @return javax.swing.JTable	
 */
private JTable getResultsTable(){
  if (resultsTable == null) {
    resultsTable=new JTable();
    resultsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    resultsTable.addMouseListener(new MouseListener(){
      public void mouseClicked(      MouseEvent e){
        int column=resultsTable.columnAtPoint(e.getPoint());
        if (e.getClickCount() == 2) {
          int row=resultsTable.rowAtPoint(e.getPoint());
          try {
            String value=resultsTable.getValueAt(row,column).toString();
            if (value.indexOf("http://") != -1 || value.indexOf("https://") != -1) {
              HudsonTrayApp.getHudsonTrayAppInstance().getTray().browse(new URL(Job.getRFC2396CompliantURL(value)));
            }
          }
 catch (          Exception ex) {
            ex.printStackTrace();
          }
        }
      }
      public void mouseEntered(      MouseEvent e){
      }
      public void mouseExited(      MouseEvent e){
      }
      public void mousePressed(      MouseEvent e){
      }
      public void mouseReleased(      MouseEvent e){
      }
    }
);
  }
  return resultsTable;
}
 

Example 10

From project jgraphx, under directory /examples/com/mxgraph/examples/swing/editor/.

Source file: EditorPalette.java

  20 
vote

/** 
 */
@SuppressWarnings("serial") public EditorPalette(){
  setBackground(new Color(149,230,190));
  setLayout(new FlowLayout(FlowLayout.LEADING,5,5));
  addMouseListener(new MouseListener(){
    public void mousePressed(    MouseEvent e){
      clearSelection();
    }
    public void mouseClicked(    MouseEvent e){
    }
    public void mouseEntered(    MouseEvent e){
    }
    public void mouseExited(    MouseEvent e){
    }
    public void mouseReleased(    MouseEvent e){
    }
  }
);
  setTransferHandler(new TransferHandler(){
    public boolean canImport(    JComponent comp,    DataFlavor[] flavors){
      return true;
    }
  }
);
}
 

Example 11

From project milton, under directory /milton/milton-client-app/src/main/java/bradswebdavclient/.

Source file: BradsWebdavClientView.java

  20 
vote

private void initTree(){
  ResourceTreeModel model=ResourceTreeModel.create(this);
  tree.setModel(model);
  tree.setCellRenderer(new MyCellRenderer());
  tree.addMouseListener(new MouseListener(){
    public void mouseClicked(    MouseEvent e){
      checkPopup(e);
    }
    public void mousePressed(    MouseEvent e){
      checkPopup(e);
    }
    public void mouseReleased(    MouseEvent e){
      checkPopup(e);
    }
    public void mouseEntered(    MouseEvent e){
    }
    public void mouseExited(    MouseEvent e){
    }
    void checkPopup(    MouseEvent e){
      if (e.isPopupTrigger()) {
        JTree tree=(JTree)e.getSource();
        int row=tree.getRowForLocation(e.getX(),e.getY());
        TreePath path=tree.getPathForLocation(e.getX(),e.getY());
        if (path != null) {
          AbstractTreeNode node=(AbstractTreeNode)path.getLastPathComponent();
          if (node != null) {
            node.updatePopupMenu(popupMenu);
            popupMenu.show(tree,e.getX(),e.getY());
          }
        }
      }
    }
  }
);
  treeHandler=new TreeResourceTransferHandler(tree);
}
 

Example 12

From project milton2, under directory /milton-client-app/src/main/java/bradswebdavclient/.

Source file: BradsWebdavClientView.java

  20 
vote

private void initTree(){
  ResourceTreeModel model=ResourceTreeModel.create(this);
  tree.setModel(model);
  tree.setCellRenderer(new MyCellRenderer());
  tree.addMouseListener(new MouseListener(){
    public void mouseClicked(    MouseEvent e){
      checkPopup(e);
    }
    public void mousePressed(    MouseEvent e){
      checkPopup(e);
    }
    public void mouseReleased(    MouseEvent e){
      checkPopup(e);
    }
    public void mouseEntered(    MouseEvent e){
    }
    public void mouseExited(    MouseEvent e){
    }
    void checkPopup(    MouseEvent e){
      if (e.isPopupTrigger()) {
        JTree tree=(JTree)e.getSource();
        int row=tree.getRowForLocation(e.getX(),e.getY());
        TreePath path=tree.getPathForLocation(e.getX(),e.getY());
        if (path != null) {
          AbstractTreeNode node=(AbstractTreeNode)path.getLastPathComponent();
          if (node != null) {
            node.updatePopupMenu(popupMenu);
            popupMenu.show(tree,e.getX(),e.getY());
          }
        }
      }
    }
  }
);
  treeHandler=new TreeResourceTransferHandler(tree);
}
 

Example 13

From project niravCS2103, under directory /CS2103/src/gui/mainWindow/.

Source file: MainJFrame.java

  20 
vote

/** 
 * set the expand/contract button to be a contract button to contract when clicked
 */
public void setdownButtonActionContract(){
  downButton.setToolTipText("Contract");
  downButton.setIcon(Resource.up);
  downButton.removeMouseListener(curdownButton);
  downButton.addMouseListener(curdownButton=new MouseListener(){
    @Override public void mouseClicked(    MouseEvent arg0){
      downButton.setIcon(Resource.upPress);
      if (MainJFrame.this.expand) {
        contractFrame();
      }
 else {
        expandFrame();
      }
      Timer timer=new Timer(100,new ActionListener(){
        @Override public void actionPerformed(        ActionEvent arg0){
          downButton.setIcon(Resource.down);
        }
      }
);
      timer.setRepeats(false);
      timer.start();
    }
    @Override public void mouseEntered(    MouseEvent arg0){
      downButton.setIcon(Resource.upOn);
    }
    @Override public void mouseExited(    MouseEvent arg0){
      downButton.setIcon(Resource.up);
    }
    @Override public void mousePressed(    MouseEvent arg0){
      downButton.setIcon(Resource.upPress);
    }
    @Override public void mouseReleased(    MouseEvent arg0){
      if (!MainJFrame.this.expand)       downButton.setIcon(Resource.down);
    }
  }
);
}
 

Example 14

From project OMS3, under directory /src/main/java/ngmf/ui/.

Source file: JConsolePanel.java

  20 
vote

public JConsolePanel(Prompt p,CommandHandler cmd,History hist){
  setPromptProvider(p);
  setCommandHandler(cmd);
  setHistory(hist);
  setText(prompt.getPrompt());
  cp=prompt.getPrompt().length();
  setEditable(true);
  setLineWrap(true);
  addKeyListener(new KListener());
  setCaretPosition(getText().length());
  setFont(new Font("Monospaced",1,12));
  addMouseListener(new MouseListener(){
    @Override public void mouseClicked(    MouseEvent e){
    }
    @Override public void mousePressed(    MouseEvent e){
    }
    @Override public void mouseEntered(    MouseEvent e){
    }
    @Override public void mouseExited(    MouseEvent e){
    }
    @Override public void mouseReleased(    MouseEvent e){
      int caretPosition=getCaretPosition();
      Element el=getDocument().getDefaultRootElement();
      int msel=el.getElementIndex(caretPosition) + 1;
      int last=el.getElementIndex(getText().length()) + 1;
      if (msel != last) {
        setCaretPosition(getText().length());
      }
    }
  }
);
}
 

Example 15

From project PenguinCMS, under directory /PenguinCMS/tests/vendor/sahi/src/net/sf/sahi/ui/.

Source file: Dashboard.java

  20 
vote

private Component getLinksPanel3(){
  trafficLabel=new JLabel();
  trafficLabel.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
  trafficLabel.setHorizontalAlignment(JButton.LEADING);
  trafficLabel.addMouseListener(new MouseListener(){
    public void mouseReleased(    MouseEvent arg0){
    }
    public void mousePressed(    MouseEvent arg0){
    }
    public void mouseExited(    MouseEvent arg0){
    }
    public void mouseEntered(    MouseEvent arg0){
    }
    public void mouseClicked(    MouseEvent arg0){
      setTrafficLink(!isTrafficEnabled);
      setTrafficLog((isTrafficEnabled) ? false : true);
    }
  }
);
  trafficLabel.addMouseMotionListener(new MouseMotionListener(){
    public void mouseMoved(    MouseEvent arg0){
      trafficLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    }
    public void mouseDragged(    MouseEvent arg0){
    }
  }
);
  JPanel buttonPane=new JPanel();
  buttonPane.setBackground(new Color(255,255,255));
  buttonPane.setLayout(new FlowLayout());
  buttonPane.add(trafficLabel);
  return buttonPane;
}
 

Example 16

From project twistDemo, under directory /twist-libs/com.thoughtworks.webdriver.recorder_1.0.0.11288/sahi/src/net/sf/sahi/ui/.

Source file: Dashboard.java

  20 
vote

private Component getLinksPanel3(){
  trafficLabel=new JLabel();
  trafficLabel.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
  trafficLabel.setHorizontalAlignment(JButton.LEADING);
  trafficLabel.addMouseListener(new MouseListener(){
    public void mouseReleased(    MouseEvent arg0){
    }
    public void mousePressed(    MouseEvent arg0){
    }
    public void mouseExited(    MouseEvent arg0){
    }
    public void mouseEntered(    MouseEvent arg0){
    }
    public void mouseClicked(    MouseEvent arg0){
      setTrafficLink(!isTrafficEnabled);
      setTrafficLog((isTrafficEnabled) ? false : true);
    }
  }
);
  trafficLabel.addMouseMotionListener(new MouseMotionListener(){
    public void mouseMoved(    MouseEvent arg0){
      trafficLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    }
    public void mouseDragged(    MouseEvent arg0){
    }
  }
);
  JPanel buttonPane=new JPanel();
  buttonPane.setBackground(new Color(255,255,255));
  buttonPane.setLayout(new FlowLayout());
  buttonPane.add(trafficLabel);
  return buttonPane;
}
 

Example 17

From project VisiCut, under directory /src/com/t_oster/visicut/gui/beans/.

Source file: SelectThumbnailButton.java

  20 
vote

private void prepareMenu(){
  final JPopupMenu menu=new JPopupMenu();
  JMenuItem mi=new JMenuItem("remove");
  mi.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent ae){
      SelectThumbnailButton.this.setThumbnailPath(null);
    }
  }
);
  menu.add(mi);
  this.addMouseListener(new MouseListener(){
    public void mouseClicked(    MouseEvent me){
      if (me.getButton() == MouseEvent.BUTTON3 && SelectThumbnailButton.this.getThumbnailPath() != null) {
        menu.show(SelectThumbnailButton.this,me.getX(),me.getY());
      }
    }
    public void mousePressed(    MouseEvent me){
    }
    public void mouseReleased(    MouseEvent me){
    }
    public void mouseEntered(    MouseEvent me){
    }
    public void mouseExited(    MouseEvent me){
    }
  }
);
}
 

Example 18

From project ceres, under directory /ceres-ui/src/test/java/com/bc/ceres/swing/.

Source file: TreeCellExtenderTest.java

  19 
vote

public void testActiveState(){
  JTree tree=new JTree();
  TreeCellExtender extender=new TreeCellExtender(tree);
  assertSame(tree,extender.getTree());
  assertEquals(false,extender.isActive());
  MouseListener[] listeners=tree.getMouseListeners();
  assertNotNull(listeners);
  int oldLength=listeners.length;
  extender.setActive(true);
  assertEquals(true,extender.isActive());
  listeners=tree.getMouseListeners();
  int newLength=listeners.length;
  assertEquals(oldLength + 1,newLength);
}
 

Example 19

From project dawn-isencia, under directory /com.isencia.passerelle.commons/src/main/java/com/isencia/util/swing/calendar/.

Source file: JDayChooser.java

  19 
vote

/** 
 * Default JDayChooser constructor.
 */
public JDayChooser(){
  locale=Locale.getDefault();
  days=new JButton[49];
  selectedDay=null;
  Calendar calendar=Calendar.getInstance(locale);
  today=(Calendar)calendar.clone();
  setLayout(new GridLayout(7,7));
  for (int y=0; y < 7; y++) {
    for (int x=0; x < 7; x++) {
      int index=x + 7 * y;
      if (y == 0) {
        days[index]=new JButton(){
          public void addMouseListener(          MouseListener l){
          }
          public boolean isFocusTraversable(){
            return false;
          }
        }
;
        days[index].setBackground(new Color(180,180,200));
      }
 else {
        days[index]=new JButton("x");
        days[index].addActionListener(this);
        days[index].addKeyListener(this);
        days[index].addFocusListener(this);
        days[index].addMouseListener(this);
      }
      days[index].setMargin(new Insets(0,0,0,0));
      days[index].setFocusPainted(false);
      add(days[index]);
    }
  }
  init();
  setDay(Calendar.getInstance().get(Calendar.DAY_OF_MONTH));
  initialized=true;
}
 

Example 20

From project freemind, under directory /freemind/freemind/view/mindmapview/.

Source file: EditNodeTextField.java

  19 
vote

private void hideMe(){
  final JComponent parent=(JComponent)textfield.getParent();
  final Rectangle bounds=textfield.getBounds();
  textfield.removeFocusListener(textFieldListener);
  textfield.removeKeyListener((KeyListener)textFieldListener);
  textfield.removeMouseListener((MouseListener)textFieldListener);
  mFocusListener.removeComponentListener((ComponentListener)textFieldListener);
  parent.remove(textfield);
  parent.revalidate();
  parent.repaint(bounds);
  textFieldListener=null;
}
 

Example 21

From project GraphLab, under directory /src/graphlab/ui/components/gpropertyeditor/.

Source file: GPropertyEditor.java

  19 
vote

public GPropertyEditor(){
  super();
  setMinimumSize(new Dimension(300,200));
  setPreferredSize(new Dimension(300,300));
  table.setModel(model);
  table.setDefaultRenderer(table.getColumnClass(1),renderer);
  table.setDefaultEditor(table.getColumnClass(1),editor);
  table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  table.setAutoCreateColumnsFromModel(true);
  table.setSurrendersFocusOnKeystroke(true);
  table.addMouseListener(new MouseAdapter(){
    public void mouseClicked(    MouseEvent e){
      int row=table.getSelectedRow();
      if (row == -1)       return;
      MouseListener[] mouseListeners=renderer.getLastCreatedRenderer(row).getMouseListeners();
      if (mouseListeners != null) {
        for (        MouseListener ml : mouseListeners) {
          ml.mouseClicked(e);
        }
      }
    }
  }
);
  initComponents();
  l.setEditable(false);
  l.setLineWrap(true);
  l.setWrapStyleWord(true);
}
 

Example 22

From project ISAvalidator-ISAconverter-BIImanager, under directory /val_conv_manager_gui/src/main/java/org/isatools/gui/datamanager/studyaccess/.

Source file: ControlPanel.java

  19 
vote

private MouseListener createMouseListenerForLabel(final JLabel label,final ImageIcon icon,final ImageIcon icon_over,final String eventCall){
  return new MouseAdapter(){
    public void mouseEntered(    MouseEvent mouseEvent){
      if (label.isEnabled()) {
        label.setIcon(icon_over);
      }
    }
    public void mouseExited(    MouseEvent mouseEvent){
      if (label.isEnabled()) {
        label.setIcon(icon);
      }
    }
    public void mousePressed(    MouseEvent mouseEvent){
      if (label.isEnabled()) {
        label.setIcon(icon);
        firePropertyChange(eventCall,"","event");
      }
    }
  }
;
}
 

Example 23

From project jchempaint, under directory /src/main/org/openscience/jchempaint/dialog/.

Source file: PeriodicTablePanel.java

  19 
vote

/** 
 * Constructor for the ElementButton object
 * @param element Description of the Parameter
 * @param e       Description of the Parameter
 * @param color   Description of the Parameter
 * @param controlViewer Description of the Parameter
 */
public ElementButton(String element,MouseListener e,String buttonString,Color color){
  super(buttonString);
  setForeground(color);
  this.element=element;
  setFont(new Font("Times-Roman",Font.BOLD,15));
  setBorder(new BevelBorder(BevelBorder.RAISED));
  setToolTipText(elementTranslator(PeriodicTable.getAtomicNumber(element)));
  addMouseListener(e);
}
 

Example 24

From project multibit, under directory /src/main/java/org/multibit/viewsystem/swing/view/yourwallets/.

Source file: SingleWalletPanel.java

  19 
vote

@Override public void addMouseListener(MouseListener mouseListener){
  super.addMouseListener(mouseListener);
  walletDescriptionTextField.addMouseListener(mouseListener);
  amountLabel.addMouseListener(mouseListener);
  walletFilenameLabel.addMouseListener(mouseListener);
}
 

Example 25

From project vlcj, under directory /src/main/java/uk/co/caprica/vlcj/runtime/windows/.

Source file: WindowsMouseHook.java

  19 
vote

/** 
 * Fire a mouse event to the registered listeners.
 * @param eventType
 * @param button
 * @param lParam
 */
private void fireMouseEvent(int eventType,int button,MSLLHOOKSTRUCT lParam){
  Logger.trace("fireMouseEvent(eventType={},button={},lParam={})",eventType,button,lParam);
  MouseListener[] listeners=listenerList.getListeners(MouseListener.class);
  if (listeners.length > 0) {
    MouseEvent evt=createMouseEvent(eventType,button,lParam);
    for (int i=listeners.length - 1; i >= 0; i--) {
switch (eventType) {
case MouseEvent.MOUSE_PRESSED:
        listeners[i].mousePressed(evt);
      break;
case MouseEvent.MOUSE_RELEASED:
    listeners[i].mouseReleased(evt);
  break;
case MouseEvent.MOUSE_ENTERED:
listeners[i].mouseEntered(evt);
break;
case MouseEvent.MOUSE_EXITED:
listeners[i].mouseExited(evt);
break;
}
}
}
}