()
| 396 | * @see javax.swing.JComponent#getPreferredSize() |
| 397 | */ |
| 398 | @Override |
| 399 | public Dimension getPreferredSize() { |
| 400 | Dimension size = super.getPreferredSize(); |
| 401 | if(getItemCount() <= maximumFastChoices && size.width > maximumWidth) { |
| 402 | setSize(maximumWidth, Integer.MAX_VALUE); |
| 403 | doLayout(); |
| 404 | int compCnt = getComponentCount(); |
| 405 | if(compCnt > 0) { |
| 406 | Component lastComp = getComponent(compCnt - 1); |
| 407 | Point compLoc = lastComp.getLocation(); |
| 408 | Dimension compSize = lastComp.getSize(); |
| 409 | size.width = maximumWidth; |
| 410 | size.height = compLoc.y + compSize.height + getInsets().bottom; |
| 411 | } |
| 412 | } |
| 413 | return size; |
| 414 | } |
| 415 | |
| 416 | |
| 417 | /** |
no test coverage detected