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