sclass JPopDownButton > JButton { S menuPosition = "left"; // or "center" or "right" *() { super(unicode_downPointingTriangle()); main addActionListener(this, r openMenu); } *(IVF1 *fillMenu) { this(); } event fillingMenu(JPopupMenu menu); swappable void fillMenu(JPopupMenu menu) { fillingMenu(menu); } void openMenu { new JPopupMenu menu; int emptyCount = menu.getComponentCount(); fillMenu(menu); if (menu.getComponentCount() == emptyCount) ret; int x = 0; if (eq(menuPosition, "center")) x = (getWidth()-getPreferredWidth(menu))/2; else if (eq(menuPosition, "right")) x = getWidth()-getPreferredWidth(menu); menu.show(this, x, getHeight()); } }