/** * @inheritDoc * * Overridden to take into account any popup insets specified in * SynthComboBoxUI */ @Override protected Rectangle computePopupBounds(int px, int py, int pw, int ph) { ComboBoxUI ui = comboBox.getUI(); if (ui instanceof SynthComboBoxUI) { SynthComboBoxUI sui = (SynthComboBoxUI) ui; if (sui.popupInsets != null) { Insets i = sui.popupInsets; return super.computePopupBounds( px + i.left, py + i.top, pw - i.left - i.right, ph - i.top - i.bottom); } } return super.computePopupBounds(px, py, pw, ph); }
/** Overridden to set a flag used to block the UI from adding a focus * listener, and to use an alternate renderer class on GTK look and feel * to work around a painting bug in SynthComboUI (colors not set correctly)*/ @Override public void setUI(ComboBoxUI ui) { inSetUI = true; try { super.setUI(ui); } finally { inSetUI = false; } }
/** * Invokes the <code>isFocusTraversable</code> method on each UI handled by this object. * * @return the value obtained from the first UI, which is * the UI obtained from the default <code>LookAndFeel</code> */ public boolean isFocusTraversable(JComboBox a) { boolean returnValue = ((ComboBoxUI) (uis.elementAt(0))).isFocusTraversable(a); for (int i = 1; i < uis.size(); i++) { ((ComboBoxUI) (uis.elementAt(i))).isFocusTraversable(a); } return returnValue; }
/** * Invokes the <code>isPopupVisible</code> method on each UI handled by this object. * * @return the value obtained from the first UI, which is * the UI obtained from the default <code>LookAndFeel</code> */ public boolean isPopupVisible(JComboBox a) { boolean returnValue = ((ComboBoxUI) (uis.elementAt(0))).isPopupVisible(a); for (int i = 1; i < uis.size(); i++) { ((ComboBoxUI) (uis.elementAt(i))).isPopupVisible(a); } return returnValue; }
/** * Invokes the <code>isFocusTraversable</code> method on each UI handled by this object. * * @return the value obtained from the first UI, which is * the UI obtained from the default <code>LookAndFeel</code> */ public boolean isFocusTraversable(JComboBox<?> a) { boolean returnValue = ((ComboBoxUI) (uis.elementAt(0))).isFocusTraversable(a); for (int i = 1; i < uis.size(); i++) { ((ComboBoxUI) (uis.elementAt(i))).isFocusTraversable(a); } return returnValue; }
/** * Invokes the <code>isPopupVisible</code> method on each UI handled by this object. * * @return the value obtained from the first UI, which is * the UI obtained from the default <code>LookAndFeel</code> */ public boolean isPopupVisible(JComboBox<?> a) { boolean returnValue = ((ComboBoxUI) (uis.elementAt(0))).isPopupVisible(a); for (int i = 1; i < uis.size(); i++) { ((ComboBoxUI) (uis.elementAt(i))).isPopupVisible(a); } return returnValue; }
/** * Maps {@code JComboBox.getUI()} through queue */ public ComboBoxUI getUI() { return (runMapping(new MapAction<ComboBoxUI>("getUI") { @Override public ComboBoxUI map() { return ((JComboBox) getSource()).getUI(); } })); }
/** * Maps {@code JComboBox.setUI(ComboBoxUI)} through queue */ public void setUI(final ComboBoxUI comboBoxUI) { runMapping(new MapVoidAction("setUI") { @Override public void map() { ((JComboBox) getSource()).setUI(comboBoxUI); } }); }
@Override public void updateUI() { ComboBoxUI cui = (ComboBoxUI) UIManager.getUI(this); if (cui instanceof MetalComboBoxUI) { cui = new MetalTreeComboBoxUI(); } else if (cui instanceof MotifComboBoxUI) { cui = new MotifTreeComboBoxUI(); } else if (cui instanceof WindowsComboBoxUI) { cui = new WindowsTreeComboBoxUI(); } setUI(cui); }
/** * Calls the {@link ComboBoxUI#setPopupVisible(JComboBox, boolean)} method * for all the UI delegates managed by this <code>MultiComboBoxUI</code>. * * @param c the component. * @param visible the visible state. */ public void setPopupVisible(JComboBox c, boolean visible) { Iterator iterator = uis.iterator(); while (iterator.hasNext()) { ComboBoxUI ui = (ComboBoxUI) iterator.next(); ui.setPopupVisible(c, visible); } }
@Nullable private static ComboPopup getComboboxPopup(final JComboBox comboBox) { final ComboBoxUI ui = comboBox.getUI(); ComboPopup popup = null; if (ui instanceof BasicComboBoxUI) { popup = ReflectionUtil.getField(BasicComboBoxUI.class, ui, ComboPopup.class, "popup"); } return popup; }
@Nullable public static ComboPopup getComboBoxPopup(@NotNull JComboBox comboBox) { final ComboBoxUI ui = comboBox.getUI(); if (ui instanceof BasicComboBoxUI) { return ReflectionUtil.getField(BasicComboBoxUI.class, ui, ComboPopup.class, "popup"); } return null; }
@Override public void setUI(ComboBoxUI ui) { if (ui instanceof CustomComboBoxUI) { super.setUI(ui); } else { super.setUI(new CustomComboBoxUI()); } }
public static final ComboPopup getComboPopup(final JComboBox<?> comboBox) { final ComboBoxUI comboBoxUI = comboBox.getUI(); if (comboBoxUI instanceof AdempiereComboBoxUI) { return ((AdempiereComboBoxUI)comboBoxUI).getComboPopup(); } // // Fallback: // Back door our way to finding the inner JList. // // it is unknown whether this functionality will work outside of Sun's // implementation, but the code is safe and will "fail gracefully" on // other systems // // see javax.swing.plaf.basic.BasicComboBoxUI.getAccessibleChild(JComponent, int) final Accessible a = comboBoxUI.getAccessibleChild(comboBox, 0); if (a instanceof ComboPopup) { return (ComboPopup)a; } else { return null; } }
private final JButton getArrowButton() { final ComboBoxUI ui = getUI(); if (ui instanceof org.adempiere.plaf.AdempiereComboBoxUI) { final JButton b = ((org.adempiere.plaf.AdempiereComboBoxUI)ui).getArrowButton(); return b; } return null; }