Libraryless. Click here for Pure Java version (582L/5K/15K).
!747 !actionListener { !x619 // CenteredLine m { static S input = ""; static S description = "?"; static boolean ok; static JFrame frame; static JTextField textField; static Runnable onOK, onCancel; p { JButton btnOK = new JButton("OK"); btnOK.addActionListener(actionListener { ok(); }); JButton btnCancel = new JButton("Cancel"); btnCancel.addActionListener(actionListener { cancel(); }); JPanel panel = topToBottomPanel(); textField = new JTextField(input); panel.add(new JLabel(description, JLabel.CENTER)); panel.add(textField); textField.addActionListener(actionListener { ok(); }); panel.add(new CenteredLine(btnOK, btnCancel)); frame = new JFrame("Input | " + description); handleEscapeKey(frame); KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); frame.getRootPane().registerKeyboardAction(actionListener { cancel(); }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); frame.add(panel); frame.setBounds(200, 300, 400, 250); frame.setVisible(true); //exitOnFrameClose(frame); // unless _noExit is set } static void ok() { ok = true; input = textField.getText(); print("OK: " + quote(input)); frame.dispose(); if (onOK != null) onOK.run(); } static void cancel() { if (ok) return; input = textField.getText(); print("Cancel with " + quote(input)); frame.dispose(); if (onCancel != null) onCancel.run(); } }
Began life as a copy of #1000834
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, liwcxgsjrgqn, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment