List of usage examples for javax.swing JComboBox getBounds
public Rectangle getBounds()
From source file:org.eclipse.jubula.rc.swing.tester.adapter.JComboBoxAdapter.java
/** * @return a rectangle, where the arrow icon is expected. *///from w ww .j ava 2 s . c o m private Rectangle findArrowIconArea() { JComboBox comboBox = m_comboBox; Component editor = getComboBoxEditorComponent(comboBox); Rectangle r = null; if (editor == null) { throw new StepExecutionException("could not find editor", //$NON-NLS-1$ EventFactory.createActionError(TestErrorEvent.COMP_NOT_FOUND)); } Rectangle ra[] = SwingUtilities.computeDifference(comboBox.getBounds(), editor.getBounds()); if ((ra == null) || (ra.length < 1)) { throw new StepExecutionException("could not arrow icon", //$NON-NLS-1$ EventFactory.createActionError(TestErrorEvent.COMP_NOT_FOUND)); } r = ra[0]; // find the largest area of the returned rectangles. double bestAreaIndex = Double.MAX_VALUE; for (int i = 0; i < ra.length; i++) { if ((ra[i].height > 0) && (ra[i].width > 0)) { double areaIndex = ((double) ra[i].width) / ra[i].height - 1.0; if (areaIndex < 0) { areaIndex *= (-1); } if (areaIndex < bestAreaIndex) { bestAreaIndex = areaIndex; r = ra[i]; } } } return r; }