List of usage examples for javax.swing.text JTextComponent putClientProperty
public final void putClientProperty(Object key, Object value)
From source file:Main.java
/** * Return the MouseEvent's click count, possibly reduced by the value of * the component's {@code SKIP_CLICK_COUNT} client property. Clears * the {@code SKIP_CLICK_COUNT} property if the mouse event's click count * is 1. In order for clearing of the property to work correctly, there * must be a mousePressed implementation on the caller with this * call as the first line.//from w w w. j ava2s .c o m */ public static int getAdjustedClickCount(JTextComponent comp, MouseEvent e) { int cc = e.getClickCount(); if (cc == 1) { comp.putClientProperty(SKIP_CLICK_COUNT, null); } else { Integer sub = (Integer) comp.getClientProperty(SKIP_CLICK_COUNT); if (sub != null) { return cc - sub; } } return cc; }
From source file:com.aw.swing.mvp.cmp.pick.PickManager.java
/** * @param attrName La caja de texto txt<attrName> debe existir * @param pick/*from www .ja va2 s . c om*/ * @return */ public Pick registerPick(String attrName, final Pick pick) { final String pickName = getPickName(attrName); getPicksInfo().add(new PickInfo(pick, attrName, pickName)); picks.add(pick); if (pick instanceof PickImpl) { ((PickImpl) pick).setPresenter(presenter); pick.setMainAttribute(attrName); final JTextComponent jTextComponent = (JTextComponent) presenter.getIpView() .getComponent(getTxtPick(attrName)); jTextComponent.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { if (e.isTemporary()) { return; } // if the pick action is currently executing Boolean executingPick = (Boolean) jTextComponent .getClientProperty(BindingComponent.ATTR_EXECUTING_PICK_ACTION); if ((executingPick != null) && (executingPick)) { jTextComponent.putClientProperty(BindingComponent.ATTR_EXECUTING_PICK_ACTION, null); // return; } System.out.println("XXX Focus LOST 2"); // if the focus will be directed to the pick Button Component cmp = e.getOppositeComponent(); if (cmp instanceof JComponent) { JComponent jComponent = (JComponent) cmp; String actionName = (String) jComponent.getClientProperty(BindingComponent.ATTR_ACTION); if (pickName.equals(actionName)) { return; } } if (!pick.isPickFilled()) { jTextComponent.setText(""); } } }); jTextComponent.addKeyListener(new PickKeyListener(pick)); jTextComponent.putClientProperty(PICK_NAME, pickName); jTextComponent.putClientProperty(PICK, pick); // JButton jButton = (JButton) presenter.getIpView().getComponent(getBtnPick(attrName)); } return pick; }