Example usage for java.awt.event MouseEvent getClickCount

List of usage examples for java.awt.event MouseEvent getClickCount

Introduction

In this page you can find the example usage for java.awt.event MouseEvent getClickCount.

Prototype

public int getClickCount() 

Source Link

Document

Returns the number of mouse clicks associated with this event.

Usage

From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java

private void createMouseListener() {
    graphComponent.getGraphControl().addMouseListener(new MouseAdapter() {

        @Override//w  ww  .  j av a  2  s.  com
        public void mousePressed(MouseEvent e) {
            if (isPopupShown) {
                isPopupShown = false;
                mxCell cell = (mxCell) graphComponent.getGraph().getSelectionModel().getCell();
                getGraphModel().remove(cell);
                return;
            }
            if (SwingUtilities.isRightMouseButton(e)) {
                xPos = e.getX();
                yPos = e.getY();
                Object obj = graphComponent.getCellAt(e.getX(), e.getY());

                if (obj instanceof mxCell) {
                    mxCell cell = (mxCell) obj;
                    if (cell.getStyle() != null && cell.getStyle().indexOf(ENTITYSTYLE) >= 0
                            && cell.getValue() instanceof EntityMetaDataVO) {
                        JPopupMenu pop = createPopupMenuEntity(cell, false);
                        pop.show(e.getComponent(), e.getX(), e.getY());
                    } else if (cell.getStyle() != null && cell.getStyle().indexOf(ENTITYSTYLE) >= 0) {
                        JPopupMenu pop = createPopupMenuEntity(cell, true);
                        pop.show(e.getComponent(), e.getX(), e.getY());
                    } else {
                        if (cell.getStyle() != null && cell.getStyle().indexOf("oval") >= 0) {
                            JPopupMenu pop = createRelationPopupMenu(cell, true, true);
                            pop.show(e.getComponent(), e.getX(), e.getY());
                        } else {
                            JPopupMenu pop = createRelationPopupMenu(cell, true, false);
                            pop.show(e.getComponent(), e.getX(), e.getY());
                        }
                    }
                } else {
                    JPopupMenu pop = createPopupMenu();
                    pop.show(e.getComponent(), e.getX(), e.getY());
                }
            } else if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
                mxCell cell = (mxCell) graphComponent.getGraph().getSelectionModel().getCell();
                if (cell == null)
                    return;
                if (cell.getValue() != null && cell.getValue() instanceof EntityMetaDataVO) {
                    EntityMetaDataVO voMeta = (EntityMetaDataVO) cell.getValue();
                    EntityMetaDataVO vo = MetaDataClientProvider.getInstance().getEntity(voMeta.getEntity());
                    new ShowNuclosWizard.NuclosWizardEditRunnable(false, mf.getHomePane(), vo).run();
                } else if (cell.getValue() != null && cell.getValue() instanceof EntityFieldMetaDataVO) {
                    if (cell.getStyle() != null && cell.getStyle().indexOf(OPENARROW) >= 0)
                        editMasterdataRelation(cell);
                    else if (cell.getStyle() != null && cell.getStyle().indexOf(DIAMONDARROW) >= 0) {
                        editSubformRelation(cell);
                    }

                } else if (cell.getValue() != null) {
                    if (cell.getStyle() != null && cell.getStyle().indexOf(OVALARROW) >= 0) {
                        try {

                            mxCell cellSource = (mxCell) cell.getSource();
                            mxCell cellTarget = (mxCell) cell.getTarget();

                            EntityMetaDataVO sourceModule = (EntityMetaDataVO) cellSource.getValue();
                            EntityMetaDataVO targetModule = (EntityMetaDataVO) cellTarget.getValue();

                            String sSourceModule = sourceModule.getEntity();
                            String sTargetModule = targetModule.getEntity();

                            boolean blnFound = false;

                            for (MasterDataVO voGeneration : MasterDataCache.getInstance()
                                    .get(NuclosEntity.GENERATION.getEntityName())) {
                                String sSource = (String) voGeneration.getField("sourceModule");
                                String sTarget = (String) voGeneration.getField("targetModule");

                                if (org.apache.commons.lang.StringUtils.equals(sSource, sSourceModule)
                                        && org.apache.commons.lang.StringUtils.equals(sTarget, sTargetModule)) {
                                    GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory
                                            .getInstance().newMasterDataCollectController(
                                                    NuclosEntity.GENERATION.getEntityName(), null, null);
                                    gcc.runViewSingleCollectableWithId(voGeneration.getId());
                                    blnFound = true;
                                    break;
                                }

                            }
                            if (!blnFound) {
                                GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory
                                        .getInstance().newMasterDataCollectController(
                                                NuclosEntity.GENERATION.getEntityName(), null, null);
                                Map<String, Object> mp = new HashMap<String, Object>();
                                mp.put("sourceModule", sSourceModule);
                                mp.put("sourceModuleId", new Integer(MetaDataClientProvider.getInstance()
                                        .getEntity(sSourceModule).getId().intValue()));
                                mp.put("targetModule", sTargetModule);
                                mp.put("targetModuleId", new Integer(MetaDataClientProvider.getInstance()
                                        .getEntity(sTargetModule).getId().intValue()));
                                MasterDataVO vo = new MasterDataVO(NuclosEntity.GENERATION.getEntityName(),
                                        null, null, null, null, null, null, mp);
                                gcc.runWithNewCollectableWithSomeFields(vo);
                            }
                        } catch (NuclosBusinessException e1) {
                            LOG.warn("mousePressed failed: " + e1, e1);
                        } catch (CommonPermissionException e1) {
                            LOG.warn("mousePressed failed: " + e1, e1);
                        } catch (CommonFatalException e1) {
                            LOG.warn("mousePressed failed: " + e1, e1);
                        } catch (CommonBusinessException e1) {
                            LOG.warn("mousePressed failed: " + e1, e1);
                        }
                    }
                }
            }
        }

    });
}

From source file:org.pmedv.blackboard.components.BoardEditor.java

private void handleMousePressed(MouseEvent e) {
    if (e.isPopupTrigger()) {
        handleContextClick(e);/* www . j  a  va 2 s .c  o m*/
    }
    if (e.isControlDown()) {
        ctrlPressed = true;
    } else {
        ctrlPressed = false;
    }
    if (e.getButton() == 1) {
        if (!button1Pressed) {
            button1Pressed = true;
            if (editorMode.equals(EditorMode.SELECT)) {
                handleClickSelectionEvent(e);
            } else if (editorMode.equals(EditorMode.MOVE)) {
                dragStartX = e.getX();
                dragStartY = e.getY();
                dragStopX = e.getX();
                dragStopY = e.getY();
            } else if (editorMode.equals(EditorMode.DRAW_LINE) || editorMode.equals(EditorMode.DRAW_MEASURE)
                    || editorMode.equals(EditorMode.DRAW_RECTANGLE)
                    || editorMode.equals(EditorMode.DRAW_ELLIPSE)) {
                if (!model.getCurrentLayer().getName().equalsIgnoreCase("Board")) {
                    if (!drawing) {
                        handleClickDrawEvent(e);
                    } else {
                        handleReleaseDrawEvent(e);
                    }
                }
            } else if (editorMode.equals(EditorMode.CHECK_CONNECTIONS)) {
                handleCheckConnectionEvent(e);
            }
        }

    } else if (e.getButton() == 2) {
        button2Pressed = true;
    } else if (e.getButton() == 3) {
        button3Pressed = true;
    }
    if (e.getClickCount() == 2 && e.isShiftDown()) {
        if (selectedItem != null || getSelectedItems().size() > 0) {
            AppContext.getContext().getBean(EditPropertiesCommand.class).execute(null);
        }
    }
    refresh();
}

From source file:ca.phon.app.project.ProjectWindow.java

private void init() {
    /* Layout *//*from w w  w . j a  v a  2s  .com*/
    setLayout(new BorderLayout());

    final ProjectDataTransferHandler transferHandler = new ProjectDataTransferHandler(this);

    /* Create components */
    newCorpusButton = createNewCorpusButton();
    createCorpusButton = createCorpusButton();

    corpusList = new JList<String>();
    corpusModel = new CorpusListModel(getProject());
    corpusList.setModel(corpusModel);
    corpusList.setCellRenderer(new CorpusListCellRenderer());
    corpusList.setVisibleRowCount(20);
    corpusList.addListSelectionListener(e -> {
        if (getSelectedCorpus() != null) {
            String corpus = getSelectedCorpus();
            sessionModel.setCorpus(corpus);
            sessionList.clearSelection();
            corpusDetails.setCorpus(corpus);

            if (getProject().getCorpusSessions(corpus).size() == 0) {
                onSwapNewAndCreateSession(newSessionButton);
            } else {
                onSwapNewAndCreateSession(createSessionButton);
            }
        }
    });
    corpusList.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            doPopup(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            doPopup(e);
        }

        public void doPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                int clickedIdx = corpusList.locationToIndex(e.getPoint());
                if (clickedIdx >= 0 && Arrays.binarySearch(corpusList.getSelectedIndices(), clickedIdx) < 0) {
                    corpusList.setSelectedIndex(clickedIdx);
                }
                showCorpusListContextMenu(e.getPoint());
            }
        }
    });

    final DragSource corpusDragSource = new DragSource();
    corpusDragSource.createDefaultDragGestureRecognizer(corpusList, DnDConstants.ACTION_COPY, (event) -> {
        final List<ProjectPath> paths = new ArrayList<>();
        for (String corpus : getSelectedCorpora()) {
            final ProjectPath corpusPath = new ProjectPath(getProject(), corpus, null);
            paths.add(corpusPath);
        }
        final ProjectPathTransferable transferable = new ProjectPathTransferable(paths);
        event.startDrag(DragSource.DefaultCopyDrop, transferable);
    });

    corpusList.setDragEnabled(true);
    corpusList.setTransferHandler(transferHandler);

    corpusDetails = new CorpusDetailsPane(getProject());
    corpusDetails.setWrapStyleWord(true);
    corpusDetails.setRows(6);
    corpusDetails.setLineWrap(true);
    corpusDetails.setBackground(Color.white);
    corpusDetails.setOpaque(true);
    JScrollPane corpusDetailsScroller = new JScrollPane(corpusDetails);

    sessionList = new JList<String>();
    newSessionButton = createNewSessionButton();
    createSessionButton = createSessionButton();
    sessionModel = new SessionListModel(getProject());
    sessionList.setModel(sessionModel);
    sessionList.setCellRenderer(new SessionListCellRenderer());
    sessionList.setVisibleRowCount(20);
    sessionList.addListSelectionListener(e -> {
        if (sessionList.getSelectedValue() != null && !e.getValueIsAdjusting()) {
            String corpus = getSelectedCorpus();
            String session = getSelectedSessionName();

            sessionDetails.setSession(corpus, session);
        }
    });
    sessionList.addMouseListener(new MouseInputAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == 1) {
                // get the clicked item
                int clickedItem = sessionList.locationToIndex(e.getPoint());
                if (sessionList.getModel().getElementAt(clickedItem) == null)
                    return;

                final String session = sessionList.getModel().getElementAt(clickedItem).toString();
                final String corpus = ((SessionListModel) sessionList.getModel()).getCorpus();

                msgPanel.reset();
                msgPanel.setMessageLabel("Opening '" + corpus + "." + session + "'");
                msgPanel.setIndeterminate(true);
                msgPanel.repaint();

                SwingUtilities.invokeLater(() -> {
                    final ActionEvent ae = new ActionEvent(sessionList, -1, "openSession");
                    (new OpenSessionAction(ProjectWindow.this, corpus, session)).actionPerformed(ae);

                    msgPanel.setIndeterminate(false);
                });
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            doPopup(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            doPopup(e);
        }

        public void doPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                int clickedIdx = sessionList.locationToIndex(e.getPoint());
                if (clickedIdx >= 0 && Arrays.binarySearch(sessionList.getSelectedIndices(), clickedIdx) < 0) {
                    sessionList.setSelectedIndex(clickedIdx);
                }
                showSessionListContextMenu(e.getPoint());
            }
        }
    });

    sessionList.setDragEnabled(true);
    sessionList.setTransferHandler(transferHandler);

    final DragSource sessionDragSource = new DragSource();
    sessionDragSource.createDefaultDragGestureRecognizer(sessionList, DnDConstants.ACTION_COPY, (event) -> {
        final List<ProjectPath> paths = new ArrayList<>();
        final String corpus = getSelectedCorpus();
        if (corpus == null)
            return;
        for (String session : getSelectedSessionNames()) {
            final ProjectPath sessionPath = new ProjectPath(getProject(), corpus, session);
            paths.add(sessionPath);
        }
        final ProjectPathTransferable transferable = new ProjectPathTransferable(paths);
        event.startDrag(DragSource.DefaultCopyDrop, transferable);
    });

    sessionDetails = new SessionDetailsPane(getProject());
    sessionDetails.setLineWrap(true);
    sessionDetails.setRows(6);
    sessionDetails.setWrapStyleWord(true);
    sessionDetails.setBackground(Color.white);
    sessionDetails.setOpaque(true);
    JScrollPane sessionDetailsScroller = new JScrollPane(sessionDetails);

    JScrollPane corpusScroller = new JScrollPane(corpusList);
    JScrollPane sessionScroller = new JScrollPane(sessionList);

    blindModeBox = new JCheckBox("Blind transcription");
    blindModeBox.setSelected(false);

    msgPanel = new StatusPanel();

    corpusPanel = new JPanel(new BorderLayout());
    corpusPanel.add(newCorpusButton, BorderLayout.NORTH);
    corpusPanel.add(corpusScroller, BorderLayout.CENTER);
    corpusPanel.add(corpusDetailsScroller, BorderLayout.SOUTH);

    sessionPanel = new JPanel(new BorderLayout());
    sessionPanel.add(newSessionButton, BorderLayout.NORTH);
    sessionPanel.add(sessionScroller, BorderLayout.CENTER);
    sessionPanel.add(sessionDetailsScroller, BorderLayout.SOUTH);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setLeftComponent(corpusPanel);
    splitPane.setRightComponent(sessionPanel);
    splitPane.setResizeWeight(0.5);

    // invoke later
    SwingUtilities.invokeLater(() -> {
        splitPane.setDividerLocation(0.5);
    });

    // the frame layout
    String projectName = null;
    projectName = getProject().getName();

    DialogHeader header = new DialogHeader(projectName, StringUtils.abbreviate(projectLoadPath, 80));

    add(header, BorderLayout.NORTH);

    CellConstraints cc = new CellConstraints();
    final JPanel topPanel = new JPanel(new FormLayout("pref, fill:pref:grow, right:pref", "pref"));
    topPanel.add(msgPanel, cc.xy(1, 1));
    topPanel.add(blindModeBox, cc.xy(3, 1));

    add(splitPane, BorderLayout.CENTER);
    add(topPanel, BorderLayout.SOUTH);

    // if no corpora are currently available, 'prompt' the user to create a new one
    if (getProject().getCorpora().size() == 0) {
        SwingUtilities.invokeLater(() -> {
            onSwapNewAndCreateCorpus(newCorpusButton);
        });
    } else {
        SwingUtilities.invokeLater(() -> {
            corpusList.setSelectedIndex(0);
        });
    }
}

From source file:au.org.ala.delta.intkey.Intkey.java

/**
 * Creates and shows the GUI. Called by the swing application framework
 *///from  w  w w .j  a  va 2 s  . c  om
@Override
protected void startup() {
    final JFrame mainFrame = getMainFrame();
    _defaultGlassPane = mainFrame.getGlassPane();
    mainFrame.setTitle("Intkey");
    mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    mainFrame.setIconImages(IconHelper.getRedIconList());

    _helpController = new HelpController(HELPSET_PATH);

    _taxonformatter = new ItemFormatter(false, CommentStrippingMode.STRIP_ALL, AngleBracketHandlingMode.REMOVE,
            true, false, true);
    _context = new IntkeyContext(new IntkeyUIInterceptor(this), new DirectivePopulatorInterceptor(this));

    _advancedModeOnlyDynamicButtons = new ArrayList<JButton>();
    _normalModeOnlyDynamicButtons = new ArrayList<JButton>();
    _activeOnlyWhenCharactersUsedButtons = new ArrayList<JButton>();
    _dynamicButtonsFullHelp = new HashMap<JButton, String>();

    ActionMap actionMap = getContext().getActionMap();

    _rootPanel = new JPanel();
    _rootPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    _rootPanel.setBackground(SystemColor.control);
    _rootPanel.setLayout(new BorderLayout(0, 0));

    _globalOptionBar = new JPanel();
    _globalOptionBar.setBorder(new EmptyBorder(0, 5, 0, 5));
    _rootPanel.add(_globalOptionBar, BorderLayout.NORTH);
    _globalOptionBar.setLayout(new BorderLayout(0, 0));

    _pnlDynamicButtons = new JPanel();
    FlowLayout flowLayout_1 = (FlowLayout) _pnlDynamicButtons.getLayout();
    flowLayout_1.setVgap(0);
    flowLayout_1.setHgap(0);
    _globalOptionBar.add(_pnlDynamicButtons, BorderLayout.WEST);

    _btnContextHelp = new JButton();
    _btnContextHelp.setMinimumSize(new Dimension(30, 30));
    _btnContextHelp.setMaximumSize(new Dimension(30, 30));
    _btnContextHelp.setAction(actionMap.get("btnContextHelp"));
    _btnContextHelp.setPreferredSize(new Dimension(30, 30));
    _btnContextHelp.setMargin(new Insets(2, 5, 2, 5));
    _btnContextHelp.addActionListener(actionMap.get("btnContextHelp"));
    _globalOptionBar.add(_btnContextHelp, BorderLayout.EAST);

    _rootSplitPane = new JSplitPane();
    _rootSplitPane.setDividerSize(3);
    _rootSplitPane.setResizeWeight(0.5);
    _rootSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    _rootSplitPane.setContinuousLayout(true);
    _rootPanel.add(_rootSplitPane);

    _innerSplitPaneLeft = new JSplitPane();
    _innerSplitPaneLeft.setMinimumSize(new Dimension(25, 25));
    _innerSplitPaneLeft.setAlignmentX(Component.CENTER_ALIGNMENT);
    _innerSplitPaneLeft.setDividerSize(3);
    _innerSplitPaneLeft.setResizeWeight(0.5);

    _innerSplitPaneLeft.setContinuousLayout(true);
    _innerSplitPaneLeft.setOrientation(JSplitPane.VERTICAL_SPLIT);
    _rootSplitPane.setLeftComponent(_innerSplitPaneLeft);

    _pnlAvailableCharacters = new JPanel();
    _innerSplitPaneLeft.setLeftComponent(_pnlAvailableCharacters);
    _pnlAvailableCharacters.setLayout(new BorderLayout(0, 0));

    _sclPaneAvailableCharacters = new JScrollPane();
    _pnlAvailableCharacters.add(_sclPaneAvailableCharacters, BorderLayout.CENTER);

    _listAvailableCharacters = new JList();
    // _listAvailableCharacters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _listAvailableCharacters.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    _listAvailableCharacters.setCellRenderer(_availableCharactersListCellRenderer);
    _listAvailableCharacters.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                int selectedIndex = _listAvailableCharacters.getSelectedIndex();
                if (selectedIndex >= 0) {
                    try {
                        Character ch = (Character) _availableCharacterListModel.getElementAt(selectedIndex);
                        executeDirective(new UseDirective(), Integer.toString(ch.getCharacterId()));
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        }
    });

    _sclPaneAvailableCharacters.setViewportView(_listAvailableCharacters);

    _pnlAvailableCharactersHeader = new JPanel();
    _pnlAvailableCharacters.add(_pnlAvailableCharactersHeader, BorderLayout.NORTH);
    _pnlAvailableCharactersHeader.setLayout(new BorderLayout(0, 0));

    _lblNumAvailableCharacters = new JLabel();
    _lblNumAvailableCharacters.setBorder(new EmptyBorder(0, 5, 0, 0));
    _lblNumAvailableCharacters.setFont(new Font("Tahoma", Font.PLAIN, 15));
    _lblNumAvailableCharacters.setText(MessageFormat.format(availableCharactersCaption, 0));
    _pnlAvailableCharactersHeader.add(_lblNumAvailableCharacters, BorderLayout.WEST);

    _pnlAvailableCharactersButtons = new JPanel();
    FlowLayout flowLayout = (FlowLayout) _pnlAvailableCharactersButtons.getLayout();
    flowLayout.setVgap(2);
    flowLayout.setHgap(2);
    _pnlAvailableCharactersHeader.add(_pnlAvailableCharactersButtons, BorderLayout.EAST);

    // All toolbar buttons should be disabled until a dataset is loaded.
    _btnRestart = new JButton();
    _btnRestart.setAction(actionMap.get("btnRestart"));
    _btnRestart.setPreferredSize(new Dimension(30, 30));
    _btnRestart.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnRestart);

    _btnBestOrder = new JButton();
    _btnBestOrder.setAction(actionMap.get("btnBestOrder"));
    _btnBestOrder.setPreferredSize(new Dimension(30, 30));
    _btnBestOrder.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnBestOrder);

    _btnSeparate = new JButton();
    _btnSeparate.setAction(actionMap.get("btnSeparate"));
    _btnSeparate.setVisible(_advancedMode);
    _btnSeparate.setPreferredSize(new Dimension(30, 30));
    _btnSeparate.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnSeparate);

    _btnNaturalOrder = new JButton();
    _btnNaturalOrder.setAction(actionMap.get("btnNaturalOrder"));
    _btnNaturalOrder.setPreferredSize(new Dimension(30, 30));
    _btnNaturalOrder.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnNaturalOrder);

    _btnDiffSpecimenTaxa = new JButton();
    _btnDiffSpecimenTaxa.setAction(actionMap.get("btnDiffSpecimenTaxa"));
    _btnDiffSpecimenTaxa.setEnabled(false);
    _btnDiffSpecimenTaxa.setPreferredSize(new Dimension(30, 30));
    _pnlAvailableCharactersButtons.add(_btnDiffSpecimenTaxa);

    _btnSetTolerance = new JButton();
    _btnSetTolerance.setAction(actionMap.get("btnSetTolerance"));
    _btnSetTolerance.setPreferredSize(new Dimension(30, 30));
    _btnSetTolerance.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnSetTolerance);

    _btnSetMatch = new JButton();
    _btnSetMatch.setAction(actionMap.get("btnSetMatch"));
    _btnSetMatch.setVisible(_advancedMode);
    _btnSetMatch.setPreferredSize(new Dimension(30, 30));
    _btnSetMatch.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnSetMatch);

    _btnSubsetCharacters = new JButton();
    _btnSubsetCharacters.setAction(actionMap.get("btnSubsetCharacters"));
    _btnSubsetCharacters.setPreferredSize(new Dimension(30, 30));
    _btnSubsetCharacters.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnSubsetCharacters);

    _btnFindCharacter = new JButton();
    _btnFindCharacter.setAction(actionMap.get("btnFindCharacter"));
    _btnFindCharacter.setPreferredSize(new Dimension(30, 30));
    _btnFindCharacter.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnFindCharacter);

    _pnlAvailableCharactersButtons.setEnabled(false);

    _pnlUsedCharacters = new JPanel();
    _innerSplitPaneLeft.setRightComponent(_pnlUsedCharacters);
    _pnlUsedCharacters.setLayout(new BorderLayout(0, 0));

    _sclPnUsedCharacters = new JScrollPane();
    _pnlUsedCharacters.add(_sclPnUsedCharacters, BorderLayout.CENTER);

    _listUsedCharacters = new JList();
    _listUsedCharacters.setCellRenderer(_usedCharactersListCellRenderer);
    _listUsedCharacters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _listUsedCharacters.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                int selectedIndex = _listUsedCharacters.getSelectedIndex();
                if (selectedIndex >= 0) {
                    try {
                        Attribute attr = (Attribute) _usedCharacterListModel.getElementAt(selectedIndex);

                        if (_context.charactersFixed() && _context.getFixedCharactersList()
                                .contains(attr.getCharacter().getCharacterId())) {
                            return;
                        }

                        executeDirective(new ChangeDirective(),
                                Integer.toString(attr.getCharacter().getCharacterId()));
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        }
    });

    _sclPnUsedCharacters.setViewportView(_listUsedCharacters);

    _pnlUsedCharactersHeader = new JPanel();
    _pnlUsedCharacters.add(_pnlUsedCharactersHeader, BorderLayout.NORTH);
    _pnlUsedCharactersHeader.setLayout(new BorderLayout(0, 0));

    _lblNumUsedCharacters = new JLabel();
    _lblNumUsedCharacters.setBorder(new EmptyBorder(7, 5, 7, 0));
    _lblNumUsedCharacters.setFont(new Font("Tahoma", Font.PLAIN, 15));
    _lblNumUsedCharacters.setText(MessageFormat.format(usedCharactersCaption, 0));
    _pnlUsedCharactersHeader.add(_lblNumUsedCharacters, BorderLayout.WEST);

    _innerSplitPaneRight = new JSplitPane();
    _innerSplitPaneRight.setMinimumSize(new Dimension(25, 25));
    _innerSplitPaneRight.setDividerSize(3);
    _innerSplitPaneRight.setResizeWeight(0.5);
    _innerSplitPaneRight.setContinuousLayout(true);
    _innerSplitPaneRight.setOrientation(JSplitPane.VERTICAL_SPLIT);
    _rootSplitPane.setRightComponent(_innerSplitPaneRight);

    _pnlRemainingTaxa = new JPanel();
    _innerSplitPaneRight.setLeftComponent(_pnlRemainingTaxa);
    _pnlRemainingTaxa.setLayout(new BorderLayout(0, 0));

    _sclPnRemainingTaxa = new JScrollPane();
    _pnlRemainingTaxa.add(_sclPnRemainingTaxa, BorderLayout.CENTER);

    _listRemainingTaxa = new JList();

    _listRemainingTaxa.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                displayInfoForSelectedTaxa();
            }
        }
    });

    _sclPnRemainingTaxa.setViewportView(_listRemainingTaxa);

    _pnlRemainingTaxaHeader = new JPanel();
    _pnlRemainingTaxa.add(_pnlRemainingTaxaHeader, BorderLayout.NORTH);
    _pnlRemainingTaxaHeader.setLayout(new BorderLayout(0, 0));

    _lblNumRemainingTaxa = new JLabel();
    _lblNumRemainingTaxa.setBorder(new EmptyBorder(0, 5, 0, 0));
    _lblNumRemainingTaxa.setFont(new Font("Tahoma", Font.PLAIN, 15));
    _lblNumRemainingTaxa.setText(MessageFormat.format(remainingTaxaCaption, 0));
    _pnlRemainingTaxaHeader.add(_lblNumRemainingTaxa, BorderLayout.WEST);

    _pnlRemainingTaxaButtons = new JPanel();
    FlowLayout fl_pnlRemainingTaxaButtons = (FlowLayout) _pnlRemainingTaxaButtons.getLayout();
    fl_pnlRemainingTaxaButtons.setVgap(2);
    fl_pnlRemainingTaxaButtons.setHgap(2);
    _pnlRemainingTaxaHeader.add(_pnlRemainingTaxaButtons, BorderLayout.EAST);

    // All toolbar buttons should be disabled until a dataset is loaded.
    _btnTaxonInfo = new JButton();
    _btnTaxonInfo.setAction(actionMap.get("btnTaxonInfo"));
    _btnTaxonInfo.setPreferredSize(new Dimension(30, 30));
    _btnTaxonInfo.setEnabled(false);
    _pnlRemainingTaxaButtons.add(_btnTaxonInfo);

    _btnDiffTaxa = new JButton();
    _btnDiffTaxa.setAction(actionMap.get("btnDiffTaxa"));
    _btnDiffTaxa.setPreferredSize(new Dimension(30, 30));
    _btnDiffTaxa.setEnabled(false);
    _pnlRemainingTaxaButtons.add(_btnDiffTaxa);

    _btnSubsetTaxa = new JButton();
    _btnSubsetTaxa.setAction(actionMap.get("btnSubsetTaxa"));
    _btnSubsetTaxa.setPreferredSize(new Dimension(30, 30));
    _btnSubsetTaxa.setEnabled(false);
    _pnlRemainingTaxaButtons.add(_btnSubsetTaxa);

    _btnFindTaxon = new JButton();
    _btnFindTaxon.setAction(actionMap.get("btnFindTaxon"));
    _btnFindTaxon.setPreferredSize(new Dimension(30, 30));
    _btnFindTaxon.setEnabled(false);
    _pnlRemainingTaxaButtons.add(_btnFindTaxon);

    _pnlEliminatedTaxa = new JPanel();
    _innerSplitPaneRight.setRightComponent(_pnlEliminatedTaxa);
    _pnlEliminatedTaxa.setLayout(new BorderLayout(0, 0));

    _sclPnEliminatedTaxa = new JScrollPane();
    _pnlEliminatedTaxa.add(_sclPnEliminatedTaxa, BorderLayout.CENTER);

    _listEliminatedTaxa = new JList();

    _listEliminatedTaxa.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                displayInfoForSelectedTaxa();
            }
        }
    });

    _sclPnEliminatedTaxa.setViewportView(_listEliminatedTaxa);

    _pnlEliminatedTaxaHeader = new JPanel();
    _pnlEliminatedTaxa.add(_pnlEliminatedTaxaHeader, BorderLayout.NORTH);
    _pnlEliminatedTaxaHeader.setLayout(new BorderLayout(0, 0));

    _lblEliminatedTaxa = new JLabel();
    _lblEliminatedTaxa.setBorder(new EmptyBorder(7, 5, 7, 0));
    _lblEliminatedTaxa.setFont(new Font("Tahoma", Font.PLAIN, 15));
    _lblEliminatedTaxa.setText(MessageFormat.format(eliminatedTaxaCaption, 0));
    _pnlEliminatedTaxaHeader.add(_lblEliminatedTaxa, BorderLayout.WEST);

    JMenuBar menuBar = buildMenus(_advancedMode);
    getMainView().setMenuBar(menuBar);

    _txtFldCmdBar = new JTextField();
    _txtFldCmdBar.setCaretColor(Color.WHITE);
    _txtFldCmdBar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            String cmdStr = _txtFldCmdBar.getText();

            cmdStr = cmdStr.trim();
            if (_cmdMenus.containsKey(cmdStr)) {
                JMenu cmdMenu = _cmdMenus.get(cmdStr);
                cmdMenu.doClick();
            } else {
                _context.parseAndExecuteDirective(cmdStr);
            }
            _txtFldCmdBar.setText(null);
        }
    });

    _txtFldCmdBar.setFont(new Font("Courier New", Font.BOLD, 13));
    _txtFldCmdBar.setForeground(SystemColor.text);
    _txtFldCmdBar.setBackground(Color.BLACK);
    _txtFldCmdBar.setOpaque(true);
    _txtFldCmdBar.setVisible(_advancedMode);
    _rootPanel.add(_txtFldCmdBar, BorderLayout.SOUTH);
    _txtFldCmdBar.setColumns(10);

    _logDialog = new RtfReportDisplayDialog(getMainFrame(), new SimpleRtfEditorKit(null), null, logDialogTitle);

    // Set context-sensitive help keys for toolbar buttons
    _helpController.setHelpKeyForComponent(_btnRestart, HELP_ID_CHARACTERS_TOOLBAR_RESTART);
    _helpController.setHelpKeyForComponent(_btnBestOrder, HELP_ID_CHARACTERS_TOOLBAR_BEST);
    _helpController.setHelpKeyForComponent(_btnSeparate, HELP_ID_CHARACTERS_TOOLBAR_SEPARATE);
    _helpController.setHelpKeyForComponent(_btnNaturalOrder, HELP_ID_CHARACTERS_TOOLBAR_NATURAL);
    _helpController.setHelpKeyForComponent(_btnDiffSpecimenTaxa,
            HELP_ID_CHARACTERS_TOOLBAR_DIFF_SPECIMEN_REMAINING);
    _helpController.setHelpKeyForComponent(_btnSetTolerance, HELP_ID_CHARACTERS_TOOLBAR_TOLERANCE);
    _helpController.setHelpKeyForComponent(_btnSetMatch, HELP_ID_CHARACTERS_TOOLBAR_SET_MATCH);
    _helpController.setHelpKeyForComponent(_btnSubsetCharacters, HELP_ID_CHARACTERS_TOOLBAR_SUBSET_CHARACTERS);
    _helpController.setHelpKeyForComponent(_btnFindCharacter, HELP_ID_CHARACTERS_TOOLBAR_FIND_CHARACTERS);

    _helpController.setHelpKeyForComponent(_btnTaxonInfo, HELP_ID_TAXA_TOOLBAR_INFO);
    _helpController.setHelpKeyForComponent(_btnDiffTaxa, HELP_ID_TAXA_TOOLBAR_DIFF_TAXA);
    _helpController.setHelpKeyForComponent(_btnSubsetTaxa, HELP_ID_TAXA_TOOLBAR_SUBSET_TAXA);
    _helpController.setHelpKeyForComponent(_btnFindTaxon, HELP_ID_TAXA_TOOLBAR_FIND_TAXA);

    // This mouse listener on the default glasspane is to assist with
    // context senstive help. It intercepts the mouse events,
    // determines what component was being clicked on, then takes the
    // appropriate action to provide help for the component
    _defaultGlassPane.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            // Determine what point has been clicked on
            Point glassPanePoint = e.getPoint();
            Point containerPoint = SwingUtilities.convertPoint(getMainFrame().getGlassPane(), glassPanePoint,
                    getMainFrame().getContentPane());
            Component component = SwingUtilities.getDeepestComponentAt(getMainFrame().getContentPane(),
                    containerPoint.x, containerPoint.y);

            // Get the java help ID for this component. If none has been
            // defined, this will be null
            String helpID = _helpController.getHelpKeyForComponent(component);

            // change the cursor back to the normal one and take down the
            // classpane
            mainFrame.setCursor(Cursor.getDefaultCursor());
            mainFrame.getGlassPane().setVisible(false);

            // If a help ID was found, display the related help page in the
            // help viewer
            if (_helpController.getHelpKeyForComponent(component) != null) {
                _helpController.helpAction().actionPerformed(new ActionEvent(component, 0, null));
                _helpController.displayHelpTopic(mainFrame, helpID);
            } else {
                // If a dynamically-defined toolbar button was clicked, show
                // the help for this button in the ToolbarHelpDialog.
                if (component instanceof JButton) {
                    JButton button = (JButton) component;
                    if (_dynamicButtonsFullHelp.containsKey(button)) {
                        String fullHelpText = _dynamicButtonsFullHelp.get(button);
                        if (fullHelpText == null) {
                            fullHelpText = noHelpAvailableCaption;
                        }
                        RTFBuilder builder = new RTFBuilder();
                        builder.startDocument();
                        builder.appendText(fullHelpText);
                        builder.endDocument();
                        ToolbarHelpDialog dlg = new ToolbarHelpDialog(mainFrame, builder.toString(),
                                button.getIcon());
                        show(dlg);
                    }
                }
            }
        }
    });

    show(_rootPanel);
}

From source file:org.isatools.isacreator.filechooser.FileChooserUI.java

/**
 * Create the Navigation Tree panel/*from w  w  w. ja v a 2 s .co  m*/
 *
 * @return @see JPanel containing the navigation tree to browse a file system.
 */
private JPanel createNavTree() {
    JPanel treeContainer = new JPanel(new BorderLayout());
    treeContainer.setBackground(UIHelper.BG_COLOR);
    treeContainer
            .setBorder(new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "", TitledBorder.DEFAULT_JUSTIFICATION,
                    TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR));

    JPanel navigationControls = new JPanel();
    navigationControls.setLayout(new BoxLayout(navigationControls, BoxLayout.LINE_AXIS));
    navigationControls.setOpaque(false);

    final JLabel navToParentDir = new JLabel(upIcon);
    navToParentDir.setOpaque(false);
    navToParentDir.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            navToParentDir.setIcon(upIcon);
            try {
                updateTree(fileBrowser.getParentDirectory());
            } catch (IOException e) {
                errorAction("problem occurred!");
            }
        }

        public void mouseEntered(MouseEvent event) {
            super.mouseEntered(event);
            navToParentDir.setIcon(upIconOver);
        }

        public void mouseExited(MouseEvent event) {
            super.mouseExited(event);
            navToParentDir.setIcon(upIcon);
        }
    });

    navigationControls.add(navToParentDir);
    navigationControls.add(Box.createHorizontalStrut(5));

    final JLabel navToHomeDir = new JLabel(homeIcon);
    navToHomeDir.setOpaque(false);
    navToHomeDir.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            navToHomeDir.setIcon(homeIcon);
            try {
                updateTree(fileBrowser.getHomeDirectory());

            } catch (IOException e) {
                if (e instanceof ConnectionException) {
                    status.setText("<html>status: not connected!</html>");
                }
                FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false,
                        FileBrowserTreeNode.DIRECTORY);
                updateTree(defaultFTPNode);
            }
        }

        public void mouseEntered(MouseEvent event) {
            super.mouseEntered(event);
            navToHomeDir.setIcon(homeIconOver);
        }

        public void mouseExited(MouseEvent event) {
            super.mouseExited(event);
            navToHomeDir.setIcon(homeIcon);
        }
    });

    navigationControls.add(navToHomeDir);
    navigationControls.add(Box.createGlue());

    treeContainer.add(navigationControls, BorderLayout.NORTH);

    try {
        treeModel = new DefaultTreeModel(fileBrowser.getHomeDirectory());
        directoryTree = new JTree(treeModel);
        directoryTree.setFont(UIHelper.VER_11_PLAIN);
        directoryTree.setCellRenderer(new FileSystemTreeCellRenderer());
    } catch (IOException e) {
        FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false,
                FileBrowserTreeNode.DIRECTORY);
        updateTree(defaultFTPNode);
    }

    directoryTree.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            int selRow = directoryTree.getRowForLocation(event.getX(), event.getY());

            TreePath selPath = directoryTree.getPathForLocation(event.getX(), event.getY());

            if (selRow != -1) {
                final FileBrowserTreeNode node = (FileBrowserTreeNode) selPath.getLastPathComponent();

                if (SwingUtilities.isLeftMouseButton(event)) {

                    if (event.getClickCount() == 2) {
                        if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) {

                            String newPath;
                            if (fileBrowser instanceof LocalBrowser) {
                                newPath = ((File) fileBrowser.getDirFiles().get(node.toString())).getPath();
                            } else {
                                newPath = node.toString();
                            }
                            updateTree(fileBrowser.changeDirectory(newPath));
                        }

                        // else, if a leaf node, then add file to to list
                        if (node.isLeaf() && (node.getType() != FileBrowserTreeNode.DIRECTORY)) {
                            String extension = node.toString().substring(node.toString().lastIndexOf(".") + 1)
                                    .trim().toUpperCase();

                            FileChooserFile toAdd = null;

                            for (Object o : fileBrowser.getFileMap().get(extension)) {
                                String fileName;
                                String filePath;
                                if (fileBrowser instanceof LocalBrowser) {
                                    File file = (File) o;
                                    fileName = file.getName();
                                    filePath = file.getPath();

                                    if (fileName.equals(node.toString())) {
                                        toAdd = new CustomFile(filePath);
                                        break;
                                    }
                                } else {
                                    FTPFile ftpFile = (FTPFile) o;
                                    fileName = ftpFile.getName();
                                    filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator
                                            + ftpFile.getName();

                                    if (fileName.equals(node.toString())) {
                                        toAdd = new CustomFTPFile(ftpFile, filePath);
                                        break;
                                    }
                                }

                            }

                            if (toAdd != null && !checkIfInList(toAdd)) {
                                selectedFiles.addFileItem(toAdd);
                            }
                        }
                    }
                } else {
                    if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) {

                        // show popup to add the directory to the selected files
                        JPopupMenu popup = new JPopupMenu();

                        JMenuItem addDirectory = new JMenuItem("add directory");
                        addDirectory.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent ae) {

                                Object fileToAdd = fileBrowser.getDirFiles().get(node.toString());
                                FileChooserFile toAdd;

                                if (fileToAdd instanceof File) {
                                    toAdd = new CustomFile(((File) fileToAdd).getPath());
                                } else {
                                    FTPFile ftpFile = (FTPFile) fileToAdd;
                                    String filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator
                                            + ftpFile.getName();

                                    toAdd = new CustomFTPFile(ftpFile, filePath);
                                }

                                if (!checkIfInList(toAdd)) {
                                    selectedFiles.addDirectoryItem(toAdd);
                                }
                            }
                        });

                        popup.add(addDirectory);
                        popup.show(directoryTree, event.getX(), event.getY());
                    }
                }
            }
        }

    });

    BasicTreeUI ui = new BasicTreeUI() {
        public Icon getCollapsedIcon() {
            return null;
        }

        public Icon getExpandedIcon() {
            return null;
        }
    };

    directoryTree.setUI(ui);
    directoryTree.setFont(UIHelper.VER_12_PLAIN);

    JScrollPane treeScroll = new JScrollPane(directoryTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    treeScroll.setPreferredSize(new Dimension(300, 200));
    treeScroll.setBorder(new EmptyBorder(0, 0, 0, 0));
    treeContainer.add(treeScroll, BorderLayout.CENTER);

    IAppWidgetFactory.makeIAppScrollPane(treeScroll);

    return treeContainer;
}

From source file:org.nuclos.client.ui.collect.SubForm.java

/**
 * @Deprecated Never use this directly, instead use {@link #addToolbarMenuItems(List)}.
 *//*  w w w.j  a  va 2 s .  c  o m*/
private MouseListener newToolbarContextMenuListener(final JComponent parent, final JTable table) {
    MouseListener res = new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent mev) {
            if (SwingUtilities.isRightMouseButton(mev)) {
                List<JComponent> items = new ArrayList<JComponent>();
                addToolbarMenuItems(items);
                if (items.isEmpty())
                    return;

                JPopupMenu popup = new JPopupMenu();
                for (JComponent c : items)
                    popup.add(c);
                popup.show(parent, mev.getX(), mev.getY());
            }
            if (SwingUtilities.isLeftMouseButton(mev) && mev.getClickCount() == 2) {
                int row = table.rowAtPoint(mev.getPoint());
                int column = table.columnAtPoint(mev.getPoint());
                LOG.info(StringUtils.concat("Doubleclick on subform: column=", column, ",row=", row));
                if (row == -1 || column == -1) {
                    if (toolbarMenuItems.get(ToolbarFunction.NEW.name()).isEnabled()) {
                        actionPerformed(ToolbarFunction.NEW.name());
                    }
                }
            }
        }

    };
    return res;
}

From source file:org.signserver.admin.gui.MainView.java

private void auditLogTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_auditLogTableMouseClicked
    if (evt.getClickCount() > 1) {
        displayLogEntryAction();//www.  j  a  v a  2s  . c  om
    }
}

From source file:org.signserver.admin.gui.MainView.java

private void tokenEntriesTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tokenEntriesTableMouseClicked
    if (evt.getClickCount() > 1) {
        tokenEntriesDetailsButton.doClick();
    }//from  ww w.j av  a 2s.  co  m
}

From source file:com.xilinx.ultrascale.gui.MainScreen_video.java

private void initVideoPlayer() {
    //        jSlider1.setValue(0);
    //NativeLibrary.addSearchPath("libvlc", "/usr/local/lib/");
    //        sysout("initializing video player");
    System.setProperty("jna.library.path", "/usr/local/lib/");
    //JDesktopPane desktopPane;

    //desktopPane = new JDesktopPane();
    videoFrame = new JFrame("Video Panel");
    videoFrame.setSize(975, 300);/*  www  .j  a  v  a  2  s.co  m*/
    videoFrame.setBounds(0, 0, 975, 350);
    videoFrame.setResizable(false);
    videoFrame.setLocationRelativeTo(this);
    //        videoFrame.getContentPane().setBackground(Color.BLACK);
    videoFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    //videoFrame.setContentPane(desktopPane);
    //videoFrame.add(desktopPane);
    videoFrame.setVisible(false);
    //videoFrame.setUndecorated(true);
    //videoFrame.setFocusableWindowState(false);
    //videoFrame.setEnabled(false);

    frame1 = new Window(videoFrame);
    frame1.setSize(480, 270);
    frame1.setBounds(videoFrame.getBounds().x + 5, videoFrame.getBounds().y + 50, 480, 270);
    //frame1.setUndecorated(true);
    //frame1.setAlwaysOnTop(true);

    //frame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame2 = new Window(videoFrame);

    frame2.setBounds(videoFrame.getBounds().x + 490, videoFrame.getBounds().y + 50, 480, 270);
    //frame2.setUndecorated(true);
    //frame2.setAlwaysOnTop(true);
    //frame2.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    //JInternalFrame jf1 = new JInternalFrame();
    //jf1.setContentPane(frame1.getContentPane());
    //JInternalFrame jf2 = new JInternalFrame();
    //jf2.setContentPane(frame2.getContentPane());
    //desktopPane.add(jf1);
    //desktopPane.add(jf2);
    screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    txMediaPlayer = create(frame1, 1);
    rxMediaPlayer = create(frame2, 0);
    txMediaPlayer.getVideoSurface().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent event) {
            if (event.getClickCount() == 2) {
                if (screen.getFullScreenWindow() == null) {
                    //                        System.out.println("TX fullscreen");
                    screen.setFullScreenWindow(frame1);
                    txMediaPlayer.getMediaPlayer().setAspectRatio("16:10");
                    //                        System.out.println("aspect ratio: "+txMediaPlayer.getMediaPlayer().getAspectRatio() );
                } else {
                    //                        System.out.println("TX normalscreen");
                    screen.setFullScreenWindow(null);
                    txMediaPlayer.getMediaPlayer().setAspectRatio(aspectRatio);
                    //                        System.out.println("aspect ratio: "+txMediaPlayer.getMediaPlayer().getAspectRatio() );
                }
            }
        }
    });

    rxMediaPlayer.getVideoSurface().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent event) {
            if (event.getClickCount() == 2) {
                if (screen.getFullScreenWindow() == null) {
                    //                        System.out.println("RX fullscreen");
                    screen.setFullScreenWindow(frame2);
                    rxMediaPlayer.getMediaPlayer().setAspectRatio("16:10");
                    //                        System.out.println("aspect ratio: "+rxMediaPlayer.getMediaPlayer().getAspectRatio() );

                } else {
                    //                        System.out.println("rX normalscreen");
                    screen.setFullScreenWindow(null);
                    rxMediaPlayer.getMediaPlayer().setAspectRatio(aspectRatio);
                    //                        System.out.println("aspect ratio: "+rxMediaPlayer.getMediaPlayer().getAspectRatio() );
                }
            }
        }
    });
    videoFrame.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentMoved(ComponentEvent e) {
            super.componentMoved(e); //To change body of generated methods, choose Tools | Templates.
            frame1.setBounds(videoFrame.getBounds().x + 5, videoFrame.getBounds().y + 50, 480, 270);

            frame2.setBounds(videoFrame.getBounds().x + 490, videoFrame.getBounds().y + 50, 480, 270);
            //frame1.setBounds(videoFrame.getBounds().x + 50, videoFrame.getBounds().y + 50, 400, 400);
            //frame2.setBounds(videoFrame.getBounds().x + 500, videoFrame.getBounds().y + 50, 400, 400);
        }

    });
    /*txCanvas = new Canvas();
     txCanvas.setSize(videoWidth, VideoHeight);//(txVidPanel.getWidth(), txVidPanel.getHeight());
     txVidPanel.add(txCanvas);
     txVidPanel.revalidate();
     txVidPanel.repaint();
     //Creation a media player :
     txMediaPlayerFactory = new MediaPlayerFactory(VLC_ARGS);
     txMediaPlayer = txMediaPlayerFactory.newEmbeddedMediaPlayer();
     CanvasVideoSurface videoSurface = txMediaPlayerFactory.newVideoSurface(txCanvas);
     txMediaPlayer.setVideoSurface(videoSurface);
            
            
     // rx video
     rxCanvas = new Canvas();
     rxCanvas.setSize(videoWidth, VideoHeight);//(rxVidPanel.getWidth(), rxVidPanel.getHeight());
     rxVidPanel.add(rxCanvas);
     rxVidPanel.revalidate();
     rxVidPanel.repaint();
     //Creation a media player :
     rxMediaPlayerFactory = new MediaPlayerFactory();
     rxMediaPlayer = rxMediaPlayerFactory.newEmbeddedMediaPlayer();
     CanvasVideoSurface videorxSurface = rxMediaPlayerFactory.newVideoSurface(rxCanvas);
     rxMediaPlayer.setVideoSurface(videorxSurface);
            
     //frame to display video
     videoFrame = new JFrame("Video Panel");
     videoFrame.addWindowListener(new WindowAdapter() {
     @Override
     public void windowClosing(WindowEvent we) {
     //                rxMediaPlayer.stop();
     //                txMediaPlayer.stop();
     //                videoFrame.hide();
     }
     });
            
     videoFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
     //        videoFrame.add(videosPanel);
            
     videoFrame.setSize(videoWidth * 2, VideoHeight);
     videoFrame.setPreferredSize(new Dimension(videoWidth * 2, VideoHeight + 20));
            
     videosPanel.setLocation(0, 0);
     videoFrame.setLayout(new BorderLayout());
     videoFrame.add(videosPanel, BorderLayout.CENTER);
     //videoFrame.show();\
     videoFrame.setResizable(false);
     videoFrame.pack();
            
     sysout("video player initialized");*/
}

From source file:org.nuclos.client.customcomp.resplan.ResPlanPanel.java

private void initJResPlan() {
    resPlan = new JResPlanComponent<Collectable, Date, Collectable, Collectable>(resPlanModel, timeModel);
    resPlan.getTimelineHeader().setCategoryModel(timeGranularityModel.getSelectedItem());
    resPlan.addMouseListener(new AbstractJPopupMenuListener() {
        @Override//from ww  w. jav a2  s  .co m
        protected JPopupMenu getJPopupMenu(MouseEvent evt) {
            JPopupMenu popupMenu = new JPopupMenu();
            Point pt = evt.getPoint();

            Area<Collectable, Date> blankSelection = resPlan.getSelectedBlankArea();
            if (blankSelection != null) {
                popupMenu.add(new AddAction(blankSelection.getResource(), blankSelection.getInterval()));
            } else {
                popupMenu.add(new AddAction(resPlan.getResourceAt(pt), resPlan.getTimeIntervalAt(pt)));
            }

            List<Collectable> selectedEntries = selectEntriesForEvent(pt);
            List<Collectable> selectedRelations = selectRelationsForEvent(pt);
            if (resPlan.isEditable() && (!selectedEntries.isEmpty() || !selectedRelations.isEmpty())) {
                JMenuItem menuItem = popupMenu.add(removeAction);
                boolean enabled = true;
                for (Collectable clct : selectedEntries) {
                    if (!resPlanModel.isRemoveEntryAllowed(clct)) {
                        enabled = false;
                        break;
                    }
                }
                for (Collectable clct : selectedRelations) {
                    if (!resPlanModel.isRemoveRelationAllowed(clct)) {
                        enabled = false;
                        break;
                    }
                }
                // Note: just change the state of the menu item (and leave the action as is)
                menuItem.setEnabled(enabled);
            }
            if (!selectedEntries.isEmpty() || !selectedRelations.isEmpty()) {
                popupMenu.add(detailsAction);
            }

            if (selectedEntries.size() == 1 && resPlanModel.getRelationEntity() != null
                    && resPlanModel.isCreateRelationAllowed()) {
                popupMenu.addSeparator();
                if (resPlan.getRelateBegin() != null) {
                    Collectable to = selectedEntries.get(0);
                    if (to != resPlan.getRelateBegin()) {
                        popupMenu.add(relateFinishAction);
                    }
                }
                popupMenu.add(relateBeginAction);
            }

            return popupMenu;
        }

        private List<Collectable> selectEntriesForEvent(Point pt) {
            List<Collectable> selection = resPlan.getSelectedEntries();
            Collectable entryAt = resPlan.getEntryAt(pt);
            if (entryAt != null && (selection.isEmpty() || !selection.contains(entryAt))) {
                selection = Collections.singletonList(entryAt);
                resPlan.setSelectedEntries(selection);
            }
            return selection;
        }

        private List<Collectable> selectRelationsForEvent(Point pt) {
            List<Collectable> selection = resPlan.getSelectedRelations();
            Collectable relAt = resPlan.getRelationAt(pt);
            if (relAt != null && (selection.isEmpty() || !selection.contains(relAt))) {
                selection = Collections.singletonList(relAt);
                resPlan.setSelectedRelations(selection);
            }
            return selection;
        }

        @Override
        public void mouseClicked(MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                Collectable clct = resPlan.getEntryAt(evt.getPoint());
                if (clct == null) {
                    clct = resPlan.getRelationAt(evt.getPoint());
                    if (clct != null) {
                        runDetailsCollectable(resPlanModel.getRelationEntity().getEntityName(), clct);
                    }
                } else {
                    runDetailsCollectable(resPlanModel.getEntryEntity().getEntityName(), clct);
                }
                evt.consume();
            }
        }
    });
    resPlan.getResourceHeader().addMouseListener(new AbstractJPopupMenuListener() {
        @Override
        public void mouseClicked(MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint());
                runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct);
                evt.consume();
            }
        }

        @Override
        protected JPopupMenu getJPopupMenu(MouseEvent evt) {
            final Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint());
            if (clct != null) {
                JPopupMenu popupMenu = new JPopupMenu();
                popupMenu.add(new AbstractAction(
                        SpringLocaleDelegate.getInstance().getText("nuclos.resplan.action.showDetails")) {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct);
                    }
                });
                return popupMenu;
            }
            return null;
        }
    });
    Date start = DateUtils.addDays(DateUtils.getPureDate(new Date()), -5);
    Date end = DateUtils.addDays(start, 30);
    resPlan.setTimeHorizon(new Interval<Date>(start, end));
}