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

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

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

JPopupMenu.getPreferredSize介绍

暂无

代码示例

代码示例来源:origin: igniterealtime/Openfire

Dimension sizeMenu = popup.getPreferredSize();
Point bottomRightMenu = new Point(x + sizeMenu.width, y + sizeMenu.height);

代码示例来源:origin: org.netbeans.api/org-openide-awt

static Point getPopupMenuOrigin(JPopupMenu popup, Point p) {
  Point newPt = new Point(p);
  Dimension popupSize = popup.getPreferredSize();
  Rectangle screenRect = getScreenRect();
  int popupRight = newPt.x + popupSize.width;
  int popupBottom = newPt.y + popupSize.height;
  int screenRight = screenRect.x + screenRect.width;
  int screenBottom = screenRect.y + screenRect.height;
  if (popupRight > screenRight) { // Are we off the right edge?
    newPt.x = screenRight - popupSize.width;
  }
  if (newPt.x < screenRect.x) { // Are we off the left edge?
    newPt.x = screenRect.x;
  }
  if (popupBottom > screenBottom) { // Are we off the bottom edge?
    newPt.y = screenBottom - popupSize.height;
  }
  if (newPt.y < screenRect.y) { // Are we off the top edge?
    newPt.y = screenRect.y;
  }
  return newPt;
}

代码示例来源:origin: org.netbeans.api/org-openide-awt

Dimension popupSize = popup.getPreferredSize();
Rectangle popupRect = new Rectangle(p, popupSize);
Rectangle screenRect = getScreenRect();

代码示例来源:origin: org.gephi/appearance-plugin-ui

@Override
  public void actionPerformed(ActionEvent ae) {
    JPopupMenu popupMenu = getPalettePopupMenu();
    popupMenu.show(colorSwatchToolbar, -popupMenu.getPreferredSize().width, 0);
  }
});

代码示例来源:origin: com.fifesoft.rtext/fife.common

/**
 * {@inheritDoc}
 */
@Override
public Dimension getPreferredSize() {
  refresh();
  return super.getPreferredSize();
}

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

/**
 * getMonthOrYearMenuLocation, This calculates the position should be used to set the location
 * of the month or the year popup menus, relative to their source labels. These menus are used
 * to change the current month or current year from within the calendar panel.
 */
private Point getMonthOrYearMenuLocation(JLabel sourceLabel, JPopupMenu filledPopupMenu) {
  Rectangle labelBounds = sourceLabel.getBounds();
  int menuHeight = filledPopupMenu.getPreferredSize().height;
  int popupX = labelBounds.x + labelBounds.width + 1;
  int popupY = labelBounds.y + (labelBounds.height / 2) - (menuHeight / 2);
  return new Point(popupX, popupY);
}

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

/**
 * {@inheritDoc}
 */
public Dimension getPreferredSize() {
  refresh();
  return super.getPreferredSize();
}

代码示例来源:origin: net.sf.ingenias/editor

/**
 * {@inheritDoc}
 */
public Dimension getPreferredSize() {
  refresh();
  return super.getPreferredSize();
}

代码示例来源:origin: org.jvnet.hudson.plugins.hudsontrayapp/client-jdk16

private void showJPopupMenu(MouseEvent e) {
  if (e.isPopupTrigger() && menu != null) {
    Dimension size = menu.getPreferredSize();
    dialog.setLocation(e.getX(), e.getY() - size.height);
    dialog.setVisible(true);
    menu.show(dialog.getContentPane(), 0, 0);
    // popup works only for focused windows
    dialog.toFront();
  }
}

代码示例来源:origin: xyz.cofe/docking-frames-common

@Override
public void action( Dockable dockable ) {
  titleField.setText( "" );
  menu.setSize( menu.getPreferredSize() );
  titleField.setText( dockable.getTitleText() );
  
  Component component = DockUtilities.getShowingComponent( dockable );
  
  if( component != null ){
    current = dockable;
    menu.show( component, 0, 0 );
    titleField.requestFocus();
  }   
}

代码示例来源:origin: org.opentcs.thirdparty.dockingframes/docking-frames-common

@Override
public void action( Dockable dockable ) {
  titleField.setText( "" );
  menu.setSize( menu.getPreferredSize() );
  titleField.setText( dockable.getTitleText() );
  
  Component component = DockUtilities.getShowingComponent( dockable );
  
  if( component != null ){
    current = dockable;
    menu.show( component, 0, 0 );
    titleField.requestFocus();
  }   
}

代码示例来源:origin: org.nuiton.jaxx/jaxx-widgets

@Override
public void run() {
  updatePopup();
  Dimension dim = getPopup().getPreferredSize();
  JComponent invoker = getInvoker();
  getPopup().show(
      invoker,
      (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()),
      invoker.getHeight()
  );
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

private void showColumnSelectionPopup(final JPopupMenu headerPopup, final JButton cornerButton) {
    initColumnSelectorItems();
    headerPopup.show(cornerButton, cornerButton.getWidth() - headerPopup.getPreferredSize().width, cornerButton.getHeight());
  }
}

代码示例来源:origin: com.synaptix/SynaptixSwing

protected void inversePopupMenu() {
  createPopupMenu();
  int w = popupMenu.getSize().width;
  if (w == 0) {
    w = popupMenu.getPreferredSize().width;
  }
  popupMenu.show(this, -w + this.getWidth(), this.getHeight());
}

代码示例来源:origin: org.nuiton.jaxx/jaxx-widgets

@Override
    public void run() {
      ui.getPopup().pack();
      JToggleButton invoker = ui.getButton();
      Dimension dim = ui.getPopup().getPreferredSize();
      Dimension invokerDim = invoker.getSize();
      ui.getPopup().show(invoker, (int) (invokerDim.getWidth() - dim.getWidth()), invoker.getHeight());
//        getPopup().setVisible(true);
    }
  };

代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime-swing-widget

@Override
  public void run() {
    getPopup().pack();
    Dimension dim = getPopup().getPreferredSize();
    JToggleButton invoker = getButton();
    getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight());
//        getPopup().setVisible(true);
  }
};

代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime-swing-widget

@Override
  public void run() {
    getPopup().pack();
    Dimension dim = getPopup().getPreferredSize();
    JToggleButton invoker = getButton();
    getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight());
  }
};

代码示例来源:origin: org.japura/japura-gui

public void showList() {
 if (model == null) {
  rebuildModel();
 }
 if (model.getSize() > 0) {
  getPopup().setPreferredSize(null);
  Dimension dim = getPopup().getPreferredSize();
  dim.width = this.invoker.getWidth();
  getPopup().setPreferredSize(dim);
  getPopup().show(invoker, 0, invoker.getHeight());
 }
}

代码示例来源:origin: net.java.openjdk.cacio/cacio-shared

public void show(Event e) {
  JMenu m = (JMenu) getSwingMenu();
  JPopupMenu pm = m.getPopupMenu();
  Dimension d = pm.getPreferredSize();
  // TODO: Fix location relative to target.
  pm.setLocation(e.x, e.y);
  pm.setSize(d.width, d.height);
  pm.setVisible(true);
  // TODO: Add listener for closing the popup menu.
}

代码示例来源:origin: com.synaptix/SynaptixWidget

private void showPopupCalendar() {
  if (popupMenu.isVisible()) {
    popupMenu.setVisible(false);
  } else {
    LocalDateTime localDate = (LocalDateTime) formattedTextField.getValue();
    monthView.setSelectionDate(localDate != null ? localDate.toDate() : null);
    formattedTextField.requestFocus();
    popupMenu.pack();
    popupMenu.show(this, this.getWidth() - popupMenu.getPreferredSize().width, this.getHeight());
  }
}

相关文章

JPopupMenu类方法