getSource()源码实例Demo

javax.swing.event.PopupMenuEvent#getSource()源码实例Demo

下面列出了javax.swing.event.PopupMenuEvent#getSource() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: OutputTab.java
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
    JPopupMenu popup = (JPopupMenu) e.getSource();
    popup.removeAll();
    popup.setInvoker(null);
    // hack
    KeyStroke esc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JComponent c = getOutputPane().getTextView();
    c.getInputMap().put(esc, handle);
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(esc, handle);

    //hack end
    popup.removePopupMenuListener(this);
    for (TabAction action : popupItems) {
        action.clearListeners();
    }
}
 
源代码2 项目: Juicebox   文件: BoundsPopupMenuListener.java
/**
 * Alter the bounds of the popup just before it is made visible.
 */
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    @SuppressWarnings("unchecked")
    JComboBox<E> comboBox = (JComboBox<E>) e.getSource();

    if (comboBox.getItemCount() == 0) return;

    final Object child = comboBox.getAccessibleContext().getAccessibleChild(0);

    if (child instanceof BasicComboPopup) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                customizePopup((BasicComboPopup) child);
            }
        });
    }
}
 
源代码3 项目: snap-desktop   文件: SourceProductSelector.java
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    JComboBox box = (JComboBox) e.getSource();
    Object comp = box.getUI().getAccessibleChild(box, 0);
    if (!(comp instanceof JPopupMenu)) {
        return;
    }
    JComponent scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(0);
    Dimension size = new Dimension();
    size.width = scrollPane.getPreferredSize().width;
    final int boxItemCount = box.getModel().getSize();
    for (int i = 0; i < boxItemCount; i++) {
        final JLabel label = new JLabel();
        Object elementAt = box.getModel().getElementAt(i);
        if (elementAt != null && elementAt instanceof Product) {
            label.setText(((Product) elementAt).getDisplayName());
        }
        size.width = Math.max(label.getPreferredSize().width, size.width);
    }
    size.height = scrollPane.getPreferredSize().height;
    scrollPane.setPreferredSize(size);
    scrollPane.setMaximumSize(size);
}
 
源代码4 项目: openAGV   文件: BoundsPopupMenuListener.java
/**
 * Alter the bounds of the popup just before it is made visible.
 *
 * @param e The event.
 */
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
  JComboBox<?> comboBox = (JComboBox) e.getSource();
  if (comboBox.getItemCount() == 0) {
    return;
  }
  final Object child = comboBox.getAccessibleContext().getAccessibleChild(0);

  if (child instanceof BasicComboPopup) {
    SwingUtilities.invokeLater(() -> customizePopup((BasicComboPopup) child));
  }
}
 
源代码5 项目: netbeans   文件: DebugMainProjectAction.java
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    if (!menuInitialized) {
        JPopupMenu menu = (JPopupMenu)e.getSource();
        debugHistorySupport.init(menu);
        attachHistorySupport.init(menu);
        menuInitialized = true;
    } else {
        debugHistorySupport.refreshItems();
    }
}
 
源代码6 项目: cuba   文件: SearchAutoCompleteSupport.java
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    // if the combo box does not contain a prototype display value, skip our sizing logic
    final Object prototypeValue = comboBox.getPrototypeDisplayValue();
    if (prototypeValue == null) return;

    final JComponent popupComponent = (JComponent) e.getSource();

    // attempt to extract the JScrollPane that scrolls the popup
    if (popupComponent.getComponent(0) instanceof JScrollPane) {
        final JScrollPane scroller = (JScrollPane) popupComponent.getComponent(0);

        // fetch the existing preferred size of the scroller, and we'll check if it is large enough
        final Dimension scrollerSize = scroller.getPreferredSize();

        // calculates the preferred size of the renderer's component for the prototype value
        final Dimension prototypeSize = getPrototypeSize(prototypeValue);

        // add to the preferred width, the width of the vertical scrollbar, when it is visible
        prototypeSize.width += scroller.getVerticalScrollBar().getPreferredSize().width;

        // adjust the preferred width of the scroller, if necessary
        if (prototypeSize.width > scrollerSize.width) {
            scrollerSize.width = prototypeSize.width;

            // set the new size of the scroller
            scroller.setMaximumSize(scrollerSize);
            scroller.setPreferredSize(scrollerSize);
            scroller.setMinimumSize(scrollerSize);
        }
    }
}
 
源代码7 项目: rapidminer-studio   文件: DropDownPopupButton.java
@Override
public void popupMenuWillBecomeInvisible(final PopupMenuEvent e) {
	lastPopupCloseTime = System.currentTimeMillis();
	JPopupMenu jPopupMenu = (JPopupMenu) e.getSource();
	jPopupMenu.removePopupMenuListener(this);

	for (PopupMenuListener otherListener : otherListeners) {
		jPopupMenu.removePopupMenuListener(otherListener);
	}

}
 
源代码8 项目: java-swing-tips   文件: MainPanel.java
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
  JComboBox<?> combo = (JComboBox<?>) e.getSource();
  Dimension size = combo.getSize();
  if (size.width >= POPUP_MIN_WIDTH) {
    return;
  }
  if (!adjusting) {
    adjusting = true;
    combo.setSize(POPUP_MIN_WIDTH, size.height);
    combo.showPopup();
  }
  combo.setSize(size);
  adjusting = false;
}
 
源代码9 项目: netbeans   文件: ConfigurationsComboModel.java
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    JComboBox combo = (JComboBox) e.getSource();
    confirm(new EventObject(combo.getEditor().getEditorComponent()));
    combo.removePopupMenuListener(this);
}
 
源代码10 项目: netbeans   文件: ConfigurationsComboModel.java
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    JComboBox combo = (JComboBox) e.getSource();
    confirm(new EventObject(combo.getEditor().getEditorComponent()));
    combo.removePopupMenuListener(this);
}
 
源代码11 项目: netbeans   文件: ConfigurationsComboModel.java
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    JComboBox combo = (JComboBox) e.getSource();
    confirm(new EventObject(combo.getEditor().getEditorComponent()));
    combo.removePopupMenuListener(this);
}
 
源代码12 项目: netbeans   文件: ConfigurationsComboModel.java
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    JComboBox combo = (JComboBox) e.getSource();
    confirm(new EventObject(combo.getEditor().getEditorComponent()));
    combo.removePopupMenuListener(this);
}
 
源代码13 项目: java-swing-tips   文件: MainPanel.java
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
  JComboBox<?> c = (JComboBox<?>) e.getSource();
  c.setSelectedItem(c.getEditor().getItem());
}
 
源代码14 项目: java-swing-tips   文件: MainPanel.java
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
  JComboBox<?> c = (JComboBox<?>) e.getSource();
  c.setSelectedItem(c.getEditor().getItem());
}
 
源代码15 项目: cropplanning   文件: AquaLnFPopupLocationFix.java
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    final JComponent popupComponent = (JComponent) e.getSource();
    fixPopupLocation(popupComponent);
}
 
源代码评论
动弹
沙发等你来抢
 同类方法