List of usage examples for java.awt.event MouseEvent isPopupTrigger
public boolean isPopupTrigger()
From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java
/** * Creates a new {@link AttributeStatisticsPanel} instance. Before displaying the panel, an * {@link AbstractAttributeStatisticsModel} should be set via * {@link #setModel(AbstractAttributeStatisticsModel, boolean)}. * *///from www . jav a2 s . c o m public AttributeStatisticsPanel() { listOfChartPanels = new LinkedList<>(); // create listener which listens for hovering/enlarge mouse events on this panel enlargeAndHoverAndPopupMouseAdapter = new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { // only popup trigger for popup menu if (e.isPopupTrigger()) { handlePopup(e); } // only left mouse button to enlarge if (!SwingUtilities.isLeftMouseButton(e)) { return; } // little hack so hovering over the details button does not remove the hover effect // (because MouseExited is called) // but clicking the button is still possible and does not enlarge the panel if (e.getSource() instanceof JButton) { ((JButton) e.getSource()).doClick(); return; } // change enlarged status if (getModel() != null) { getModel().setEnlarged(!getModel().isEnlarged()); } } @Override public void mouseExited(final MouseEvent e) { if (SwingTools.isMouseEventExitedToChildComponents(AttributeStatisticsPanel.this, e)) { // we are still hovering over the ASP, just a child component return; } hovered = false; repaint(); } @Override public void mouseEntered(final MouseEvent e) { hovered = true; repaint(); } @Override public void mouseReleased(final MouseEvent e) { if (e.isPopupTrigger()) { handlePopup(e); } } /** * Handles the popup click event. * * @param e */ private void handlePopup(final MouseEvent e) { if (model.getAttribute().isNumerical()) { popupAttributeNumericalStatPanel.show(e.getComponent(), e.getX(), e.getY()); } else if (model.getAttribute().isNominal()) { popupAttributeNominalStatPanel.show(e.getComponent(), e.getX(), e.getY()); } else if (model.getAttribute().isDateTime()) { popupAttributeDateTimeStatPanel.show(e.getComponent(), e.getX(), e.getY()); } } }; // create listener which listens for AttributeStatisticsEvents on the model listener = new AttributeStatisticsEventListener() { @Override public void modelChanged(final AttributeStatisticsEvent e) { switch (e.getEventType()) { case ALTERNATING_CHANGED: repaint(); break; case ENLARGED_CHANGED: updateCharts(); updateVisibilityOfChartPanels(); if (AttributeStatisticsPanel.this.model.getAttribute().isNominal()) { displayNominalValues(); } break; case SHOW_CONSTRUCTION_CHANGED: panelStatsConstruction.setVisible(model.isShowConstruction()); break; case STATISTICS_CHANGED: SwingUtilities.invokeLater(new Runnable() { @Override public void run() { AbstractAttributeStatisticsModel model = AttributeStatisticsPanel.this.model; if (model.getAttribute().isNumerical()) { updateNumericalElements(model); } else if (model.getAttribute().isNominal()) { updateNominalElements(model); } else { updateDateTimeElements(model); } } }); break; default: } } }; initGUI(); }
From source file:com.intuit.tank.proxy.ProxyApp.java
private JPanel getTransactionTable() { JPanel frame = new JPanel(new BorderLayout()); model = new TransactionTableModel(); final JTable table = new TransactionTable(model); final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter);/* w w w . j av a 2 s .c om*/ final JPopupMenu pm = new JPopupMenu(); JMenuItem item = new JMenuItem("Delete Selected"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int[] selectedRows = table.getSelectedRows(); if (selectedRows.length != 0) { int response = JOptionPane.showConfirmDialog(ProxyApp.this, "Are you sure you want to delete " + selectedRows.length + " Transactions?", "Confirm Delete", JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { int[] correctedRows = new int[selectedRows.length]; for (int i = selectedRows.length; --i >= 0;) { int row = selectedRows[i]; int index = (Integer) table.getValueAt(row, 0) - 1; correctedRows[i] = index; } Arrays.sort(correctedRows); for (int i = correctedRows.length; --i >= 0;) { int row = correctedRows[i]; Transaction transaction = model.getTransactionForIndex(row); if (transaction != null) { model.removeTransaction(transaction, row); isDirty = true; saveAction.setEnabled(isDirty && !stopAction.isEnabled()); } } } } } }); pm.add(item); table.add(pm); table.addMouseListener(new MouseAdapter() { boolean pressed = false; public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { Point p = e.getPoint(); int row = table.rowAtPoint(p); int index = (Integer) table.getValueAt(row, 0) - 1; Transaction transaction = model.getTransactionForIndex(index); if (transaction != null) { detailsTF.setText(transaction.toString()); detailsTF.setCaretPosition(0); detailsDialog.setVisible(true); } } } /** * @{inheritDoc */ @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { pressed = true; int[] selectedRows = table.getSelectedRows(); if (selectedRows.length != 0) { pm.show(e.getComponent(), e.getX(), e.getY()); } } } /** * @{inheritDoc */ @Override public void mouseReleased(MouseEvent e) { if (!pressed && e.isPopupTrigger()) { int[] selectedRows = table.getSelectedRows(); if (selectedRows.length != 0) { pm.show(e.getComponent(), e.getX(), e.getY()); } } } }); JScrollPane pane = new JScrollPane(table); frame.add(pane, BorderLayout.CENTER); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Filter: "); panel.add(label, BorderLayout.WEST); final JLabel countLabel = new JLabel(" Count: 0 "); panel.add(countLabel, BorderLayout.EAST); final JTextField filterText = new JTextField(""); filterText.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { String text = filterText.getText(); if (text.length() == 0) { sorter.setRowFilter(null); } else { try { sorter.setRowFilter(RowFilter.regexFilter(text)); countLabel.setText(" Count: " + sorter.getViewRowCount() + " "); } catch (PatternSyntaxException pse) { System.err.println("Bad regex pattern"); } } } }); panel.add(filterText, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); return frame; }
From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.java
public void initComponentsManual() { this.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { parent.eventPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); }//w ww . j a v a 2s . co m } public void mouseReleased(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { parent.eventPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } } }); pageSizeField.setDocument(new MirthFieldConstraints(3, false, false, true)); pageNumberField.setDocument(new MirthFieldConstraints(7, false, false, true)); LineBorder lineBorder = new LineBorder(new Color(0, 0, 0)); TitledBorder titledBorder = new TitledBorder("Current Search"); titledBorder.setBorder(lineBorder); lastSearchCriteriaPane.setBorder(titledBorder); lastSearchCriteriaPane.setBackground(Color.white); lastSearchCriteria.setBackground(Color.white); startDatePicker.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent arg0) { allDayCheckBox.setEnabled(startDatePicker.getDate() != null || endDatePicker.getDate() != null); startTimePicker.setEnabled(startDatePicker.getDate() != null && !allDayCheckBox.isSelected()); } }); endDatePicker.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent arg0) { allDayCheckBox.setEnabled(startDatePicker.getDate() != null || endDatePicker.getDate() != null); endTimePicker.setEnabled(endDatePicker.getDate() != null && !allDayCheckBox.isSelected()); } }); pageNumberField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_ENTER && pageGoButton.isEnabled()) { jumpToPageNumber(); } } }); updateCachedUserMap(); advancedSearchPopup = new EventBrowserAdvancedFilter(parent, "Advanced Search Filter", true, userMapById); advancedSearchPopup.setVisible(false); eventSplitPane.setDividerLocation(0.8); this.addAncestorListener(new AncestorListener() { @Override public void ancestorAdded(AncestorEvent event) { } @Override public void ancestorMoved(AncestorEvent event) { } @Override public void ancestorRemoved(AncestorEvent event) { // Stop waiting for event browser requests when the event browser // is no longer being displayed parent.mirthClient.getServerConnection().abort(getAbortOperations()); // Clear the event cache when leaving the event browser. parent.eventBrowser.clearCache(); } }); }
From source file:brainflow.app.toplevel.BrainFlow.java
private void initializeToolBar() { CommandGroup mainToolbarGroup = new CommandGroup("main-toolbar"); mainToolbarGroup.bind(getApplicationFrame()); ToggleGroup interpToggleGroup = new ToggleGroup("toggle-interp-group"); interpToggleGroup.bind(getApplicationFrame()); bindCommand(new OpenImageCommand(), true); bindCommand(new SnapshotCommand(), true); bindCommand(new NewCanvasCommand(), true); bindCommand(new CreateAxialViewCommand(), true); bindCommand(new CreateSagittalViewCommand(), true); bindCommand(new CreateCoronalViewCommand(), true); bindCommand(new CreateMontageViewCommand(), true); bindCommand(new CreateVerticalOrthogonalCommand(), true); bindCommand(new CreateHorizontalOrthogonalCommand(), true); bindCommand(new CreateTriangularOrthogonalCommand(), true); CommandGroup orthoGroup = new CommandGroup("ortho-view-group"); orthoGroup.bind(getApplicationFrame()); final NextSliceCommand nextSliceCommand = new NextSliceCommand(); bindCommand(nextSliceCommand, false); final PreviousSliceCommand previousSliceCommand = new PreviousSliceCommand(); bindCommand(previousSliceCommand, false); bindCommand(new PageBackSliceCommand(), true); bindCommand(new PageForwardSliceCommand(), true); bindCommand(new IncreaseContrastCommand(), true); bindCommand(new DecreaseContrastCommand(), true); bindCommand(new NearestInterpolationToggleCommand(), true); bindCommand(new LinearInterpolationToggleCommand(), true); bindCommand(new CubicInterpolationToggleCommand(), true); bindCommand(new ToggleAxisLabelCommand(), true); bindCommand(new ToggleCrossCommand(), true); //JToolBar mainToolbar = mainToolbarGroup.createToolBar(); final CommandBar mainToolbar = new CommandBar(); // for nimbus look and feel mainToolbar.setPaintBackground(false); // for nimbus look and feel mainToolbar.setBorder(new EmptyBorder(0, 0, 0, 0)); final ButtonFactory buttonFactory = createToolBarButtonFactory(); mainToolbarGroup.visitMembers(new GroupVisitor() { @Override/* www .j a v a 2 s. com*/ public void visit(ActionCommand actionCommand) { JideButton jb = new JideButton(actionCommand.getActionAdapter()); jb.setButtonStyle(JideButton.TOOLBAR_STYLE); jb.setText(""); mainToolbar.add(jb); } @Override public void visit(CommandGroup commandGroup) { JComponent jc = commandGroup.createButton(buttonFactory); mainToolbar.add(jc); } }); mainToolbar.setKey("toolbar"); brainFrame.getDockableBarManager().addDockableBar(mainToolbar); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent event) { if (event.getID() == KeyEvent.KEY_PRESSED) { KeyEvent ke = (KeyEvent) event; Component comp = ke.getComponent(); if (ke.getKeyCode() == KeyEvent.VK_LEFT) { ImageView view = BrainFlow.get().getSelectedView(); if (/*view.hasFocus() || */ parentIsImageView(comp)) { previousSliceCommand.execute(); } } else if (ke.getKeyCode() == KeyEvent.VK_RIGHT) { ImageView view = BrainFlow.get().getSelectedView(); if ( /*view.hasFocus() */ parentIsImageView(comp)) { nextSliceCommand.execute(); } else { System.out.println("no focus"); } } } } }, AWTEvent.KEY_EVENT_MASK); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent event) { if (event.getID() == MouseEvent.MOUSE_RELEASED) { MouseEvent me = (MouseEvent) event; if (me.isPopupTrigger()) { showActionMenu(me); } } } }, AWTEvent.MOUSE_EVENT_MASK); }
From source file:com.mirth.connect.client.ui.editors.filter.FilterPane.java
/** * Shows the popup menu when the trigger button (right-click) has been pushed. *///from w ww . ja v a 2s . c o m private void checkSelectionAndPopupMenu(java.awt.event.MouseEvent evt) { int row = filterTable.rowAtPoint(new Point(evt.getX(), evt.getY())); if (evt.isPopupTrigger()) { if (row != -1) { filterTable.setRowSelectionInterval(row, row); } filterPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.java
/** * Shows the popup menu when the trigger button (right-click) has been pushed. Deselects the * rows if no row was selected./*from w ww . ja v a 2 s .com*/ */ private void checkSelectionAndPopupMenu(java.awt.event.MouseEvent evt) { int row = eventTable.rowAtPoint(new Point(evt.getX(), evt.getY())); if (row == -1) { deselectRows(); } if (evt.isPopupTrigger()) { if (row != -1) { eventTable.setRowSelectionInterval(row, row); } parent.eventPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:ca.phon.app.project.ProjectWindow.java
private void init() { /* Layout *///from www. j a v a 2 s . co m 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:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java
/** * Shows the popup menu when the trigger button (right-click) has been pushed. *///from ww w .ja va2s.c o m private void checkSelectionAndPopupMenu(java.awt.event.MouseEvent evt) { int row = transformerTable.rowAtPoint(new Point(evt.getX(), evt.getY())); if (evt.isPopupTrigger()) { if (row != -1) { transformerTable.setRowSelectionInterval(row, row); } transformerPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:edu.ku.brc.af.ui.forms.IconViewObj.java
/** * //from w w w.ja v a 2 s . com */ protected void initMainComp() { if (isEditing) { String delTTStr = ResultSetController.createTooltip("DeleteRecordTT", view.getObjTitle()); String edtTTStr = ResultSetController.createTooltip("EditRecordTT", view.getObjTitle()); String newTTStr = ResultSetController.createTooltip("NewRecordTT", view.getObjTitle()); editBtn = UIHelper.createIconBtnTT("EditForm", IconManager.IconSize.Std16, edtTTStr, false, null); newBtn = UIHelper.createIconBtnTT("CreateObj", IconManager.IconSize.Std16, newTTStr, false, null); delBtn = UIHelper.createIconBtnTT("DeleteRecord", IconManager.IconSize.Std16, delTTStr, false, null); validationInfoBtn = FormViewObj.createValidationIndicator(mainComp, getValidator()); editBtn.setEnabled(false); delBtn.setEnabled(false); newBtn.setEnabled(true); } else { String srchTTStr = ResultSetController.createTooltip("ShowRecordInfoTT", view.getObjTitle()); viewBtn = UIHelper.createIconBtnTT("InfoIcon", IconManager.IconSize.Std16, srchTTStr, false, null); viewBtn.setEnabled(false); } altViewsList = new Vector<AltViewIFace>(); switcherUI = FormViewObj.createMenuSwitcherPanel(mvParent, view, altView, altViewsList, mainComp, cellName, dataClass); Dimension maxSize = Thumbnailer.getInstance().getMaxSize(); iconTray = new OrderedIconTray(IconTray.SINGLE_ROW, maxSize.width, maxSize.height); iconTray.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equalsIgnoreCase("item order")) { rootHasChanged(); } } }); iconTray.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 1) { updateEnableUI(); } else if (e.getClickCount() > 1) { doDoubleClick(); } } @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showContextMenu(e); } } }); iconTray.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateEnableUI(); } } }); if (isEditing) { addActionListenerToEditButton(); addActionListenerToNewButton(); addActionListenerToDeleteButton(); IconViewTransferHandler ivth = new IconViewTransferHandler(this); iconTray.setTransferHandler(ivth); } else { addActionListenerToViewButton(); } mainComp = new RestrictablePanel(); mainComp.setLayout(new BorderLayout()); if (mvParent == null) { mainComp.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); } boolean isAbove = mvParent.getSeparator() != null; int defCnt = (isEditing ? 3 : 1) + (switcherUI != null ? 1 : 0) + (validationInfoBtn != null ? 1 : 0); String colDef = (isAbove ? "1px," : "f:1px:g,") + UIHelper.createDuplicateJGoodiesDef("p", "1px", defCnt); PanelBuilder builder = new PanelBuilder(new FormLayout(colDef, "p")); CellConstraints cc = new CellConstraints(); int x = 2; if (isEditing) { builder.add(editBtn, cc.xy(x, 1)); x += 2; builder.add(newBtn, cc.xy(x, 1)); x += 2; builder.add(delBtn, cc.xy(x, 1)); x += 2; if (validationInfoBtn != null) // is null when genrating form images { builder.add(validationInfoBtn, cc.xy(x, 1)); x += 2; } } else { builder.add(viewBtn, cc.xy(x, 1)); x += 2; } if (switcherUI != null) { builder.add(switcherUI, cc.xy(x, 1)); x += 2; } if (isAbove) { sepController = builder.getPanel(); } else { southPanel = builder.getPanel(); mainComp.add(southPanel, BorderLayout.SOUTH); } mainComp.add(iconTray, BorderLayout.CENTER); }
From source file:components.GlassPaneDemo.java
private void redispatchMouseEvent(MouseEvent e, boolean repaint) { Point glassPanePoint = e.getPoint(); Container container = contentPane; Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane); if (containerPoint.y < 0) { //we're not in the content pane if (containerPoint.y + menuBar.getHeight() >= 0) { //The mouse event is over the menu bar. //Could handle specially. } else {// w ww. j a v a 2 s . c om //The mouse event is over non-system window //decorations, such as the ones provided by //the Java look and feel. //Could handle specially. } } else { //The mouse event is probably over the content pane. //Find out exactly which component it's over. Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y); if ((component != null) && (component.equals(liveButton))) { //Forward events over the check box. Point componentPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, component); component.dispatchEvent(new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger())); } } //Update the glass pane if requested. if (repaint) { glassPane.setPoint(glassPanePoint); glassPane.repaint(); } }