private void btnAddActionPerformed(ActionEvent e) { final JidePopup popup = new JidePopup(); DlgACME dlg = new DlgACME( new Closure() { @Override public void execute(Object o) { if (o != null) { cmbAcme.setModel(new DefaultComboBoxModel(new ACME[] {(ACME) o})); cmbAcme.setSelectedIndex(0); popup.hidePopup(); } } }); popup.setMovable(false); popup.setResizable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.getContentPane().add(dlg); popup.setOwner(btnAdd); popup.removeExcludedComponent(btnAdd); popup.setTransient(true); popup.setDefaultFocusComponent(dlg); popup.showPopup(new Insets(-5, 0, -5, 0), btnAdd); }
private void showPopup(MouseEvent evt, JComponent component) { hidePopup(); popup = new JidePopup(); popup.setOwner(this); popup.setDefaultFocusComponent(component); popup.getContentPane().add(component); popup.setAttachable(true); popup.setMovable(false); popup.showPopup(evt.getXOnScreen(), evt.getYOnScreen()); }
private void initPanel() { mapButtons = new HashMap<>(); for (Commontags commontags : CommontagsTools.getAll()) { mapAllTags.put(commontags.getText(), commontags); } int tagnum = 1; for (Commontags selectedTags : listSelectedTags) { if (tagnum % MAXLINE == 0) { add(createButton(selectedTags), RiverLayout.LINE_BREAK); } else { add(createButton(selectedTags), RiverLayout.LEFT); } tagnum++; } if (editmode) { txtTags = new JTextField(10); SelectAllUtils.install(txtTags); ac = new AutoCompletion(txtTags, mapAllTags.keySet().toArray(new String[] {})); ac.setStrict(false); ac.setStrictCompletion(false); txtTags.addActionListener(e -> cmbTagsActionPerformed(e)); txtTags.addFocusListener( new FocusAdapter() { @Override public void focusLost(FocusEvent e) { cmbTagsActionPerformed(null); } }); txtTags.addKeyListener( new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (Character.isAlphabetic(c) || Character.isDigit(c)) { super.keyTyped(e); } else { e.consume(); } } }); add(txtTags); btnPickTags = GUITools.getTinyButton("opde.tags.pnlcommontags.allTags", SYSConst.icon22checkbox); btnPickTags.setPressedIcon(SYSConst.icon22Pressed); btnPickTags.addActionListener( e -> { final JidePopup popup = new JidePopup(); JPanel pnl = new JPanel(new BorderLayout()); pnl.add(new JScrollPane(getClickableTagsPanel()), BorderLayout.CENTER); // JButton btnApply = new JButton(SYSConst.icon22apply); // pnl.add(btnApply, BorderLayout.SOUTH); // // btnApply.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent ae) { // popup.hidePopup(); // } // }); popup.setMovable(false); popup .getContentPane() .setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnPickTags); popup.removeExcludedComponent(btnPickTags); pnl.setPreferredSize(new Dimension(400, 200)); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); popup.addPopupMenuListener( new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { OPDE.debug("popupMenuWillBecomeVisible"); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { SwingUtilities.invokeLater( () -> { removeAll(); add(txtTags); if (btnPickTags != null) { add(btnPickTags); } int tagnum1 = 1; for (JButton btn : mapButtons.values()) { if (tagnum1 % MAXLINE == 0) { add(btn, RiverLayout.LINE_BREAK); } else { add(btn, RiverLayout.LEFT); } tagnum1++; } revalidate(); repaint(); }); } @Override public void popupMenuCanceled(PopupMenuEvent e) { OPDE.debug("popupMenuCanceled"); } }); GUITools.showPopup(popup, SwingConstants.WEST); }); add(btnPickTags); } }
private void hidePopup() { if (popup != null && popup.isVisible()) { popup.hidePopupImmediately(); popup = null; } }