void (ActionEvent e) { MyOkCancelDialog<JTextField> dialog = new MyOkCancelDialog<>(frame, "Background Color"); JTextField color = dialog.setComponent(new JTextField("lightgreen")); dialog.setOkAction(() -> myJBCefBrowser.setPageBackgroundColor(color.getText()), "Apply"); dialog.show(); }