// runnable = Runnable or voidfunc(MouseEvent) static void onTitleRightClick(final JFrame frame, final O runnable) { awt { if (!isSubstanceLAF()) print("Can't add title right click!"); else { JComponent titleBar = getTitlePaneComponent(frame); //print("titleBar: " + titleBar); titleBar.addMouseListener(new MouseAdapter { public void mousePressed(MouseEvent e) { //print("titleBar mousePressed " + e.getButton()); if (isNotLeftMouseButton(e)) { //print("Calling " + runnable); callF(runnable, e); } } }); } } }