List of usage examples for javax.swing JTextField setFocusable
public void setFocusable(boolean focusable)
From source file:edu.ku.brc.specify.datamodel.busrules.DeterminationBusRules.java
@Override public void afterFillForm(final Object dataObj) { isBlockingChange = false;/* ww w.j av a 2 s .c o m*/ determination = null; if (formViewObj != null && formViewObj.getDataObj() instanceof Determination) { determination = (Determination) formViewObj.getDataObj(); // if determination exists and is new (no key) then set current true if CO has no other dets Component currentComp = formViewObj.getControlByName("isCurrent"); if (determination != null && currentComp != null) { if (isNewObject) { // It should never be null, but, currently, it does happen. // Also, now with Batch ReIdentify is will always be NULL if (determination.getCollectionObject() != null) { if (currentComp instanceof ValCheckBox) { if (formViewObj.isCreatingNewObject()) { // Do this instead of setSelected because // this activates the DataChangeListener isBlockingChange = true; ((ValCheckBox) currentComp).doClick(); isBlockingChange = false; // Well, if it is already checked then we just checked it to the 'off' state, // so we need to re-check it so it is in the "checked state" // Note: As stated in the comment above the 'doClick' the easiest way to activate // all the change listeners is by simulating a mouse click. // Also keep in mind that the change listener is listening for ActionEvents for the // checkbox instead of ChangeEvents (ChangeEvents cause to many problems). if (!((ValCheckBox) currentComp).isSelected()) { ((ValCheckBox) currentComp).doClick(); } Set<Determination> detSet = determination.getCollectionObject().getDeterminations(); for (Determination d : detSet) { if (d != determination) { d.setIsCurrent(false); } } } } else { log.error("IsCurrent not set to true because form control is of unexpected type: " + currentComp.getClass().getName()); } } } else { ((ValCheckBox) currentComp).setValue(determination.getIsCurrent(), null); } } Component activeTax = formViewObj.getControlByName("preferredTaxon"); if (activeTax != null) { JTextField activeTaxTF = (JTextField) activeTax; activeTaxTF.setFocusable(false); if (determination != null && determination.getPreferredTaxon() != null) { activeTaxTF.setText(determination.getPreferredTaxon().getFullName()); } else { activeTaxTF.setText(""); } } if (formViewObj.getAltView().getMode() != CreationMode.EDIT) { // when we're not in edit mode, we don't need to setup any listeners since the user can't change anything //log.debug("form is not in edit mode: no special listeners will be attached"); return; } Component nameUsageComp = formViewObj.getControlByName("nameUsage"); if (nameUsageComp instanceof ValComboBox) { // XXX this is probably not necessary anymore... if (!checkedBlankUsageItem) { boolean fnd = false; if (nameUsageComp instanceof ValComboBox) { ValComboBox cbx = (ValComboBox) nameUsageComp; if (cbx.getComboBox().getModel() instanceof PickListDBAdapterIFace) { PickListDBAdapterIFace items = (PickListDBAdapterIFace) cbx.getComboBox().getModel(); for (PickListItemIFace item : items.getPickList().getItems()) { if (StringUtils.isBlank(item.getValue())) { fnd = true; break; } } if (!fnd) { boolean readOnly = items.getPickList().getReadOnly(); if (readOnly) { items.getPickList().setReadOnly(false); } items.addItem("", null); if (readOnly) { items.getPickList().setReadOnly(true); } } } } checkedBlankUsageItem = true; } nameUsageComp.setEnabled(true); } final Component altNameComp = formViewObj.getControlByName("alternateName"); if (altNameComp != null && determination != null) { altNameComp.setEnabled(determination.getTaxon() == null); } if (currentComp != null && chkbxCL == null) { chkbxCL = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { adjustIsCurrentCheckbox(); } }; isCurrentCheckbox = (ValCheckBox) currentComp; isCurrentCheckbox.addChangeListener(chkbxCL); } } isNewObject = false; }
From source file:com.qframework.core.GameonApp.java
private void onTextInput(final String resptype, final String respdata) { Timer t = new javax.swing.Timer(50, new ActionListener() { public void actionPerformed(ActionEvent e) { JTextField area = new JTextField(resptype); area.setFocusable(true); area.requestFocus();//from w w w .j a v a 2 s. com Object options[] = new Object[] { area }; Frame parent = null; if (mAppContext != null) parent = (Frame) SwingUtilities.getAncestorOfClass(java.awt.Frame.class, mAppContext); else parent = (Frame) SwingUtilities.getAncestorOfClass(java.awt.Frame.class, mAppletContext); int option = JOptionPane.showOptionDialog(parent, options, "", JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); if (option == JOptionPane.YES_OPTION) { String truncated = area.getText().replaceAll("[^A-Za-z0-9:.@ ]", ""); String script = respdata + "('" + truncated + "' , 1);"; mScript.execScript(script); } else { String script = respdata + "(undefined, 1);"; mScript.execScript(script); } } }); t.setRepeats(false); t.start(); }
From source file:edu.ku.brc.af.ui.forms.ViewFactory.java
/** * @param textField// w w w. j a v a 2 s . c o m * @param border * @param fgColor * @param bgColor * @param isOpaque */ public static void changeTextFieldUIForEdit(final JTextField textField, final Border border, final Color fgColor, final Color bgColor, final boolean isOpaque) { textField.setBorder(border); textField.setForeground(fgColor); textField.setEditable(true); textField.setFocusable(true); textField.setOpaque(isOpaque); textField.setBackground(bgColor); }