javax.swing.JPopupMenu.setLayout()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中javax.swing.JPopupMenu.setLayout()方法的一些代码示例,展示了JPopupMenu.setLayout()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JPopupMenu.setLayout()方法的具体详情如下:
包路径:javax.swing.JPopupMenu
类名称:JPopupMenu
方法名:setLayout

JPopupMenu.setLayout介绍

暂无

代码示例

代码示例来源:origin: magefree/mage

sortPopup.setLayout(new GridBagLayout());
selectByPopup.setLayout(new GridBagLayout());

代码示例来源:origin: stackoverflow.com

JPopupMenu popup = new JPopupMenu();
popup.setLayout(new FlowLayout(FlowLayout.CENTER));
popup.add(new JLabel("Menu"));

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

private JPopupMenu createPopup() {
 if (menu_ == null) {
  menu_ = new JPopupMenu();
  menu_.setLayout(new BorderLayout());
  menu_.add(createComponent());
 }
 return menu_;
}

代码示例来源:origin: stackoverflow.com

final JTextField textField = ...
JButton button = ...
button.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
    JPopupMenu popup = new JPopupMenu();
    popup.setLayout(new BorderLayout());
    popup.add(new JPanel()); // your component
    popup.setPopupSize(100, 100);
    popup.show(textField, 0, textField.getHeight());
  }
});

代码示例来源:origin: stackoverflow.com

final JPopupMenu menu = new JPopupMenu();
 menu.setLayout(new GridLayout(2,5)); // How do you can, for example, lay out your menu items horizontally in 2 rows?
 for (int i = 0; i < 10; i++) {
   JMenuItem item = new JMenuItem(String.valueOf(i));
   menu.add(item);
 }
 MouseListener mouseListener = new MouseAdapter() {
   @Override
   public void mouseReleased(MouseEvent e) {
     if(e.isPopupTrigger()){
       menu.show(panel, e.getX(), e.getY());
     }
   }
 };
 panel.addMouseListener(mouseListener);

代码示例来源:origin: lbalazscs/Pixelitor

public DropDownSlider(int minValue, int value, int maxValue, boolean limitRange) {
  setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
  textField = new IntTextField(String.valueOf(value), minValue, maxValue, limitRange, 4);
  add(textField);
  initDropDownButton();
  textField.add(dropDownButton);
  slider = new JSlider(JSlider.HORIZONTAL, minValue, maxValue, value);
  popupMenu = new JPopupMenu();
  popupMenu.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 1));
  popupMenu.add(slider);
  connectSlideAndTextField();
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public JPopupMenu getPopupMenu() {
  if (popupMenu == null) {
    popupMenu = new JPopupMenu();
    popupMenu.setLayout(new VerticalGridLayout(0, getColumnCount()));
    popupMenu.addPopupMenuListener(handler);
    popupMenu.setLightWeightPopupEnabled(false);
  }
  return popupMenu;
}

代码示例来源:origin: edu.toronto.cs.savant/savant-core

public static void showPopup(PopupHostingAdapter parent, Point globalPt, Track t, Record overRecord) {
  JPopupMenu jp = new JPopupMenu();
  PopupPanel pp = create(parent, t.getDrawingMode(), t.getDataSource(), overRecord);
  parent.firePopupEvent(pp);
  if (pp != null) {
    jp.setLayout(new BorderLayout());
    jp.add(pp, BorderLayout.CENTER);
    jp.setLocation(globalPt.x - 2, globalPt.y - 2);
    activePopup = jp;
    activeHost = parent;
    jp.setVisible(true);
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

addMouseMotionListener(mil);
_popupMenu = new JPopupMenu();
_popupMenu.setLayout(new BorderLayout());
_popupMenu.add(this, BorderLayout.CENTER);

代码示例来源:origin: pentaho/pentaho-reporting

/**
  * Invoked when an action occurs.
  */
 public void actionPerformed( final ActionEvent e ) {
  if ( dateWindow != null && dateWindow.isVisible() ) {
   return;
  }
  if ( dateWindow == null ) {
   dateChooserPanel.setBorder( BorderFactory.createEmptyBorder( 5, 5, 5, 5 ) );
   dateWindow = new DateChooserPopupMenu( dateChooserPanel );
   dateWindow.setLayout( new BorderLayout() );
   dateWindow.add( dateChooserPanel, BorderLayout.CENTER );
   dateWindow.pack();
  }
  dateChooserPanel.setDateSelected( false );
  dateWindow.show( DatePickerParameterComponent.this, 0, pickDateButton.getHeight() );
 }
}

代码示例来源:origin: freeplane/freeplane

private void showTipWindow() {
  Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  if (insideComponent == null || !insideComponent.isShowing() || focusOwner == null)
    return;
  tip = insideComponent.createToolTip();
  tip.setTipText(toolTipText);
  final JComponent nearComponent = insideComponent;
  focusOwnerRef = new WeakReference<Component>(focusOwner);
  tipPopup = new JPopupMenu();
  tipPopup.setLayout(new GridLayout(1, 1));
  tipPopup.add(tip);
  mouseInsideTooltipListener = new MouseInsideListener(tipPopup);
  final Component placedComponent = tipPopup;
  Point location = UITools.findBestLocation(placedComponent, nearComponent);
  SwingUtilities.convertPointFromScreen(location, nearComponent);
   tipPopup.show(nearComponent, location.x, location.y);
  focusOwner.requestFocusInWindow();
  exitTimer.start();
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/** Sets the number of columns of the popup menu. */
public void setColumnCount(int newValue, boolean isVertical) {
  int oldValue = columnCount;
  columnCount = newValue;
  getPopupMenu().setLayout(new VerticalGridLayout(0, getColumnCount(), isVertical));
  firePropertyChange(COLUMN_COUNT_PROPERTY, oldValue, newValue);
}

代码示例来源:origin: khuxtable/seaglass

protected void uninstallDefaults() {
  SeaGlassContext context = getContext(popupMenu, ENABLED);
  style.uninstallDefaults(context);
  context.dispose();
  style = null;
  if (popupMenu.getLayout() instanceof UIResource) {
    popupMenu.setLayout(null);
  }
}

代码示例来源:origin: org.fudaa.framework.ebli/ebli-common

protected JPopupMenu buildPopup(final JPopupMenu _popup) {
  _popup.setLayout(new BuBorderLayout(0, 0));
  final CtuluPopupColorChooser ctuluPopupColorChooser = new CtuluPopupColorChooser(useInvisible_);
  ctuluPopupColorChooser.setParentPopup(_popup);
  ctuluPopupColorChooser.setIdxSelectedColor((Color) getTargetValue());
  ctuluPopupColorChooser.addPropertyChangeListenerForSelectedColor(new PropertyChangeListener() {
   public void propertyChange(final PropertyChangeEvent _evt) {
    BSelecteurColorChooserBt.this.changeColor((Color) _evt.getNewValue());
   }
  });
  _popup.add(ctuluPopupColorChooser);
  return _popup;
 }
}

代码示例来源:origin: cytoscape.coreplugins/quickfind

/**
 * PopupMenu Will Become Visible:  Resize.
 *
 * @param e PopupMenuEvent.
 */
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
  JComboBox box = (JComboBox) e.getSource();
  Object comp = box.getUI().getAccessibleChild(box, 0);
  if (!(comp instanceof JPopupMenu)) {
    return;
  }
  JPopupMenu popUpMenu = (JPopupMenu) comp;
  //  Set to Flow Layout, fixes bug in Mac OS X, Java 1.5
  popUpMenu.setLayout(new FlowLayout(FlowLayout.LEFT));
  //  Set size of ScrollPane
  JScrollPane scrollPane = (JScrollPane) popUpMenu.getComponent(0);
  scrollPane.setOpaque(true);
  Dimension size = scrollPane.getPreferredSize();
  size.width = (int) (size.width * popupWindowSizeMultiple);
  scrollPane.setPreferredSize(size);
}

代码示例来源:origin: khuxtable/seaglass

public void installDefaults() {
  if (popupMenu.getLayout() == null || popupMenu.getLayout() instanceof UIResource) {
    popupMenu.setLayout(new DefaultMenuLayout(popupMenu, BoxLayout.Y_AXIS));
    popupMenu.setOpaque(false);
  }
  updateStyle(popupMenu);
}

代码示例来源:origin: stackoverflow.com

jTextField2.addKeyListener(new java.awt.event.KeyAdapter() {
   public void keyReleased(java.awt.event.KeyEvent evt) {
     showPopup(evt);
   }
 });
void showPopup(java.awt.event.KeyEvent evt) {
   JPopupMenu popup = new JPopupMenu();
   popup.setLightWeightPopupEnabled(false);
   popup.setBorder(BorderFactory.createLineBorder(Color.black));
   popup.setLayout(new BorderLayout());
   popup.setSize(this.getPreferredSize());
   popup.setPreferredSize(this.getPreferredSize());
   popup.pack();
   popup.setOpaque(false);
   // create panel that contains the search result 
   popup.add(BorderLayout.CENTER, <YOUR PANEL WITH THE RESULT>);
   popup.setPreferredSize(new Dimension(jTextField2.getWidth(),250));
   <SEARCH PANEL>.setPreferredSize(new Dimension(jTextField2.getWidth(),250));
   popup.show(jTextField2, 0, jTextField2.getHeight());
  }

代码示例来源:origin: omegat-org/omegat

public AutoCompleter(EditorTextArea3 editor) {
  this.editor = editor;
  scroll = new JScrollPane();
  scroll.setBorder(new EmptyBorder(0, 0, 0, 0));
  scroll.setPreferredSize(new Dimension(200, 200));
  scroll.setColumnHeaderView(null);
  scroll.setFocusable(false);
  scroll.getVerticalScrollBar().setFocusable(false);
  scroll.getHorizontalScrollBar().setFocusable(false);
  // add any views here
  addView(new GlossaryAutoCompleterView());
  addView(new AutotextAutoCompleterView());
  addView(new TagAutoCompleterView());
  addView(new CharTableAutoCompleterView());
  addView(new HistoryCompleter());
  addView(new HistoryPredictor());
  viewLabel = new JLabel();
  viewLabel.setBorder(new CompoundBorder(
      new MatteBorder(1, 0, 0, 0, UIManager.getColor("OmegaTBorder.color")),
      new EmptyBorder(5, 5, 5, 5)));
  viewLabel.setOpaque(true);
  popup.setBorder(new MatteBorder(1, 1, 1, 1, UIManager.getColor("OmegaTBorder.color")));
  popup.setLayout(new BorderLayout());
  popup.add(scroll, BorderLayout.CENTER);
  popup.add(viewLabel, BorderLayout.SOUTH);
  resetKeys();
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

JPopupMenu popup = new TabPopup();
_selectionListener = new TabPaneSelectionHandler( popup );
popup.setLayout( new BorderLayout() );
popup.setBackground( Scheme.active().getControl() );
Point pt = _tabContainer.getLocation();

代码示例来源:origin: com.jidesoft/jide-oss

if (popupMenu instanceof JidePopupMenu && popupMenu.getPreferredSize().height != ((JidePopupMenu) popupMenu).getPreferredScrollableViewportSize().height) {
  if (popupMenu.getLayout() instanceof DefaultMenuLayout && SystemInfo.isJdk6Above()) {
    popupMenu.setLayout(new BoxLayout(popupMenu, ((DefaultMenuLayout) popupMenu.getLayout()).getAxis()));

相关文章

JPopupMenu类方法