In my swing application I have a dialog box with Combobox. In the I am applying the AffineTransformation . All the components are resizing but except JComponent popupmenu list is not scaling . I am trying with an event to get the Popupmenu object of the ComboBox.
public static void displayComp(JComponent jComponent) {
if (jComponent != null) {
final Container awtContainer = (Container) jComponent;
final Component[] components = awtContainer.getComponents();
for (Component comp : components) {
if (comp instanceof JComboBox) {
JComboBox<JComponent> b = (JComboBox<JComponent>) comp;
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("e::" + e);
JMenuItem mi = (JMenuItem) e.getSource();
JPopupMenu popup = (JPopupMenu) mi.getParent();
System.out.println("popup:::" + popup);
}
});
System.out.print("JComboBox :::");
System.out.println(comp.getPreferredSize() + "***Component**" + comp.getName());
}
if (comp instanceof JComponent) {
displayComp((JComponent) comp);
}
}
}
}
You can get the popup component using following code
JComboBox combo = ...;
BasicComboPopup popup = (BasicComboPopup) combo.getUI().getAccessibleChild(combo, 0);