javax.swing.JComboBox.getSize()方法的使用及代码示例

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

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

JComboBox.getSize介绍

暂无

代码示例

代码示例来源:origin: com.google.code.findbugs/findbugs

@Override
  public Dimension getSize() {
    Dimension dim = super.getSize();
    if (!layingOut) {
      dim.width = Math.max(dim.width, 300);
      dim.height = Math.max(dim.height, 500);
    }
    return dim;
  }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

@Override
 public Dimension getSize() {
  Dimension dim = super.getSize();
  if (!m_layingOut) {
   dim.width = Math.max(dim.width, getPreferredSize().width);
  }
  return dim;
 }
}

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

public Dimension getSize() {
    Dimension dim = super.getSize();
    if (!layingOut)
      dim.width = Math.max(dim.width, getPreferredSize().width);
    return dim;
  }
}

代码示例来源:origin: eu.mihosoft.vrl/vrl

@Override
public Dimension getSize() {
  Dimension dim = super.getSize();
  if (!layingOut && isWide()) {
    dim.width = Math.max(widestLengh, dim.width);
  }
  return dim;
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

@Override
 public Dimension getSize() {
  Dimension dim = super.getSize();
  if (!m_layingOut) {
   dim.width = Math.max(dim.width, getPreferredSize().width);
  }
  return dim;
 }
}

代码示例来源:origin: org.appdapter/org.appdapter.lib.gui

public Dimension getSize() {
  Dimension dim = super.getSize();
  if (!layingOut)
    dim.width = Math.max(dim.width, getPreferredSize().width);
  return dim;
}

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

@Override
public Dimension getSize() {
  Dimension dim = super.getSize();
  if (!layingOut) {
    dim.width = Math.max(dim.width, getPreferredSize().width);
  }
  return dim;
}

代码示例来源:origin: Waikato/weka-trunk

@Override
 public Dimension getSize() {
  Dimension dim = super.getSize();
  if (!m_layingOut) {
   dim.width = Math.max(dim.width, getPreferredSize().width);
  }
  return dim;
 }
}

代码示例来源:origin: Waikato/weka-trunk

@Override
 public Dimension getSize() {
  Dimension dim = super.getSize();
  if (!m_layingOut) {
   dim.width = Math.max(dim.width, getPreferredSize().width);
  }
  return dim;
 }
}

代码示例来源:origin: sing-group/GC4S

@Override
public Dimension getSize() {
  Dimension dim = super.getSize();
  if (!layingOut && isAutoAdjustWidth()) {
    dim.width = Math.max(maxItemWidth, dim.width);
  }
  return dim;
}

代码示例来源:origin: girtel/Net2Plan

@Override
public Dimension getSize() {
  Dimension dim = super.getSize();
  if (!layingOut) dim.width = Math.max(dim.width, getPreferredSize().width);
  return dim;
}

代码示例来源:origin: com.numdata/numdata-swing

/**
 * The combo box popup width is determined by the combo box editor size,
 * which is retrieved using this {@link #getSize} method. It seems that this
 * method is normally only called when the popup is going to be displayed,
 * so we carelessly override it here to determine the popup size ourselves.
 *
 * Tested against Java 1.6 and Java 1.7. All bets are off!
 *
 * @inheritdoc
 */
@NotNull
@Override
public Dimension getSize()
{
  final Dimension result = super.getSize();
  if ( !_layingOut )
  {
    result.width = Math.max( result.width, getPopupWidth() );
  }
  return result;
}

代码示例来源:origin: org.appdapter/org.appdapter.lib.gui

@Override public void run() {
    JComboBox combo = (JComboBox) e.getSource();
    Accessible a = combo.getAccessibleContext().getAccessibleChild(0);
    //Or Accessible a = combo.getUI().getAccessibleChild(combo, 0);
    if (a instanceof BasicComboPopup) {
      BasicComboPopup pop = (BasicComboPopup) a;
      Point p = new Point(combo.getSize().width, 0);
      SwingUtilities.convertPointToScreen(p, combo);
      pop.setLocation(p);
    }
  }
});

代码示例来源:origin: org.appdapter/org.appdapter.lib.gui

void initGUI() {
  removeAll();
  classBrowserButton = new JButton("Examine...");
  classBrowserButton.setToolTipText("Opens a new window that lets you examine classes and create new object instances");
  classBrowserButton.addActionListener(this);
  classBrowserButton.setEnabled(false);
  //classBrowserButton.setActionCommand(COMMAND_CREATE_BEAN);
  DefaultComboBoxModel dcm = new SortedComboBoxModel();
  classField = new JComboBox(dcm);
  classField.setSize(400, (int) classField.getSize().getHeight());
  classField.addActionListener(this);
  classField.setEnabled(true);
  final JTextComponent tc = (JTextComponent) classField.getEditor().getEditorComponent();
  tc.getDocument().addDocumentListener(this);
  setBorder(new TitledBorder("Class browser"));
  setLayout(new BorderLayout());
  add("North", new JLabel("Full class name:"));
  add("Center", classField);
  add("East", classBrowserButton);
  adjustSize();
  updatedClassFilter();
  installSearchable();
}

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

if (box.isPopupVisible()) {
  int widthOfPopUpWindow = (int) (box.getSize().width * this.popupSizeMultiple);

代码示例来源:origin: com.github.insubstantial/substance

/**
 * Calculates the upper left location of the popup.
 * 
 * @return The upper left location of the popup.
 */
private Point getPopupLocation() {
  Dimension popupSize = this.comboBox.getSize();
  Insets insets = this.getInsets();
  // reduce the width of the scrollpane by the insets so that the popup
  // is the same width as the combo box.
  popupSize.setSize(popupSize.width - (insets.right + insets.left), this
      .getPopupHeightForRowCount(this.comboBox.getMaximumRowCount()));
  Rectangle popupBounds = this.computePopupBounds(0, this.comboBox
      .getBounds().height, popupSize.width, popupSize.height);
  Dimension scrollSize = popupBounds.getSize();
  Point popupLocation = popupBounds.getLocation();
  this.scroller.setMaximumSize(scrollSize);
  this.scroller.setPreferredSize(scrollSize);
  this.scroller.setMinimumSize(scrollSize);
  this.list.revalidate();
  return new Point(popupLocation.x, popupLocation.y);
}

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

/**
 * Calculates the upper left location of the Popup.
 */
private Point getPopupLocation() {
  int h = getPopupHeightForRowCount(comboBox.getMaximumRowCount());
  Dimension pl = list.getPreferredSize();
  Dimension popupSize = comboBox.getSize();
  // TODO Modif de Gaby pour agrandir la combo box
  popupSize.width = Math
      .max(
          popupSize.width,
          (pl.getHeight() > h ? pl.width
              + scroller.getVerticalScrollBar()
                  .getPreferredSize().width : pl.width) + 2);
  Insets insets = getInsets();
  // reduce the width of the scrollpane by the insets so that the popup
  // is the same width as the combo box.
  popupSize.setSize(popupSize.width - (insets.right + insets.left), h);
  Rectangle popupBounds = computePopupBounds(0,
      comboBox.getBounds().height, popupSize.width, popupSize.height);
  Dimension scrollSize = popupBounds.getSize();
  Point popupLocation = popupBounds.getLocation();
  scroller.setMaximumSize(scrollSize);
  scroller.setPreferredSize(scrollSize);
  scroller.setMinimumSize(scrollSize);
  list.revalidate();
  return popupLocation;
}

代码示例来源:origin: org.java.net.substance/substance

/**
 * Calculates the upper left location of the popup.
 * 
 * @return The upper left location of the popup.
 */
private Point getPopupLocation() {
  Dimension popupSize = this.comboBox.getSize();
  Insets insets = this.getInsets();
  // reduce the width of the scrollpane by the insets so that the popup
  // is the same width as the combo box.
  popupSize.setSize(popupSize.width - (insets.right + insets.left), this
      .getPopupHeightForRowCount(this.comboBox.getMaximumRowCount()));
  Rectangle popupBounds = this.computePopupBounds(0, this.comboBox
      .getBounds().height, popupSize.width, popupSize.height);
  Dimension scrollSize = popupBounds.getSize();
  Point popupLocation = popupBounds.getLocation();
  this.scroller.setMaximumSize(scrollSize);
  this.scroller.setPreferredSize(scrollSize);
  this.scroller.setMinimumSize(scrollSize);
  this.list.revalidate();
  return new Point(popupLocation.x, popupLocation.y);
}

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

/**
   * Calculates the upper left location of the Popup.
   *
   * @return the Point representing the upper-left coordinate of the Popup.
   */
  private Point getPopupLocation() {
    Dimension popupSize = comboBox.getSize();
    Insets    insets    = getInsets();

    // reduce the width of the scrollpane by the insets so that the popup
    // is the same width as the combo box.
    popupSize.setSize(popupSize.width - (insets.right + insets.left), getPopupHeightForRowCount(getMaximumRowCount()));
    Rectangle popupBounds   = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, popupSize.height);
    Dimension scrollSize    = popupBounds.getSize();
    Point     popupLocation = popupBounds.getLocation();

    scroller.setMaximumSize(scrollSize);
    scroller.setPreferredSize(scrollSize);
    scroller.setMinimumSize(scrollSize);

    list.revalidate();

    return popupLocation;
  }
}

代码示例来源:origin: org.ihtsdo/wb-api

public void show() {
    int widestWidth = getWidestItemWidth();
    if (widestWidth < comboBox.getPreferredSize().width) {
      widestWidth = comboBox.getPreferredSize().width;
    }
    Dimension popupSize = comboBox.getSize();
    popupSize.setSize(widestWidth + (2 * padding),
      getPopupHeightForRowCount(comboBox.getMaximumRowCount()));
    Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width,
      popupSize.height);
    scroller.setMaximumSize(popupBounds.getSize());
    scroller.setPreferredSize(popupBounds.getSize());
    scroller.setMinimumSize(popupBounds.getSize());
    list.invalidate();
    int selectedIndex = comboBox.getSelectedIndex();
    if (selectedIndex == -1) {
      list.clearSelection();
    } else {
      list.setSelectedIndex(selectedIndex);
    }
    list.ensureIndexIsVisible(list.getSelectedIndex());
    setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());
    show(comboBox, popupBounds.x, popupBounds.y);
  }
};

相关文章

JComboBox类方法