java - JComboBox containing Icon is too small on Mac -
i developing swing application shall execute on every platform. general application not problem, works fine on windows, linux , mac.
but have jcombobox
displays in addition text icon
(size 50x50). understand, mac has strict layout rules , oversized jcomboboxes
not wanted. problem is, using mac look-and-feel
, jcomboboxes
have correct width height way small (same height if there not icon). therefore top , bottom part of icon
cut off not nice.
displaying jcombobox
without icon
not make sense, have not found solution far display jcombobox
correct height (even setting minimumsize
, preferredsize
, maximumsize
icon.geticonheight()+2
not help). using windows or linux jcomboboxes
displayed correctly.
is there property use or have live cut off icons?
using customcomboboxdemo
shown in how use combo boxes, custom renderer works expected; ui delegate, com.apple.laf.aquacomboboxui
, ignores request such this:
petlist.setpreferredsize(new dimension(200, 130));
as alternative, javax.swing.plaf.metal.metalcomboboxui
produces result shown below. note arrow , scrollbar (not shown) remain unchanged. aside, arrow may changed, shown here.
addendum: can alter ui defaults ad lib, depicted below.
//create combo box. jcombobox petlist = new jcombobox(intarray); color bg = (color) uimanager.get("combobox.background"); color fg = (color) uimanager.get("combobox.foreground"); uimanager.put("combobox.selectionbackground", bg); uimanager.put("combobox.selectionforeground", fg); petlist.setui(new metalcomboboxui()); comboboxrenderer renderer = new comboboxrenderer(); ....
Comments
Post a Comment