List of usage examples for javax.swing JTextField setText
@BeanProperty(bound = false, description = "the text of this component") public void setText(String t)
TextComponent
to the specified text. From source file:com.igormaznitsa.zxpspritecorrector.files.FileNameDialog.java
private void processFileName(final JTextField field, final String[] array, final int index) { if (array == null || array[index] == null) { field.setEnabled(false);/*from w w w. j a v a 2 s.com*/ } else { field.setText(array[index]); } }
From source file:com.igormaznitsa.zxpspritecorrector.files.FileNameDialog.java
private void processZxFileName(final JTextField field, final String[] array, final int index) { if (array == null || array[index] == null) { field.setEnabled(false);/*from w ww. ja va 2 s .co m*/ } else { field.setText(array[index]); } }
From source file:de.codesourcery.jasm16.ide.ui.views.HexDumpView.java
protected JPanel createPanel() { textArea.setEditable(false);//from w w w .j a v a2s . co m setColors(textArea); textArea.setFont(getMonospacedFont()); textArea.setEditable(false); // dump panel final JPanel dumpPanel = new JPanel(); setColors(dumpPanel); dumpPanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH); dumpPanel.add(textArea, cnstrs); // toolbar panel final JPanel toolbarPanel = new JPanel(); setColors(toolbarPanel); toolbarPanel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); toolbarPanel.add(new JLabel("Goto"), cnstrs); final JTextField gotoTextfield = new JTextField(); gotoTextfield.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String val = gotoTextfield.getText(); Address adr; if (StringUtils.isBlank(val)) { gotoTextfield.setText("0000"); adr = Address.wordAddress(0); } else { try { adr = Address.wordAddress(Misc.parseHexString(val)); } catch (NumberFormatException e1) { gotoTextfield.setText("0000"); adr = Address.wordAddress(0); } } dumpStartAddress = adr; refreshDisplay(); } }); cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL); toolbarPanel.add(gotoTextfield, cnstrs); // create result panel final JPanel result = new JPanel(); setColors(result); result.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, true, GridBagConstraints.BOTH); result.add(dumpPanel, cnstrs); cnstrs = constraints(1, 0, true, true, GridBagConstraints.VERTICAL); result.add(toolbarPanel, cnstrs); textArea.addKeyListener(new PagingKeyAdapter() { @Override protected void onePageUp() { HexDumpView.this.onePageUp(); } @Override protected void onePageDown() { HexDumpView.this.onePageDown(); } @Override protected void oneLineUp() { HexDumpView.this.oneLineUp(); } @Override protected void oneLineDown() { HexDumpView.this.oneLineDown(); } }); result.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { refreshDisplay(); } }); return result; }
From source file:edu.ku.brc.specify.plugins.ipadexporter.ManageDataSetsDlg.java
/** * /* ww w. ja v a2 s .c om*/ */ private void addUserToDS() { final Vector<String> wsList = new Vector<String>(); final Vector<String> instItems = new Vector<String>(); String addStr = getResourceString("ADD"); instItems.add(addStr); wsList.add(addStr); for (String fullName : cloudHelper.getInstList()) { String[] toks = StringUtils.split(fullName, '\t'); instItems.add(toks[0]); wsList.add(toks[1]); } final JTextField userNameTF = createTextField(20); final JTextField passwordTF = createTextField(20); final JLabel pwdLbl = createI18NFormLabel("Password"); final JLabel statusLbl = createLabel(""); final JCheckBox isNewUser = UIHelper.createCheckBox("Is New User"); final JLabel instLbl = createI18NFormLabel("Insitution"); final JComboBox instCmbx = UIHelper.createComboBox(instItems.toArray()); if (instItems.size() == 2) { instCmbx.setSelectedIndex(1); } CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,4px,p,4px,p,4px,p,4px,p,8px,p")); pb.add(createI18NLabel("Add New or Existing User to DataSet"), cc.xyw(1, 1, 3)); pb.add(createI18NFormLabel("Username"), cc.xy(1, 3)); pb.add(userNameTF, cc.xy(3, 3)); pb.add(pwdLbl, cc.xy(1, 5)); pb.add(passwordTF, cc.xy(3, 5)); pb.add(instLbl, cc.xy(1, 7)); pb.add(instCmbx, cc.xy(3, 7)); pb.add(isNewUser, cc.xy(3, 9)); pb.add(statusLbl, cc.xyw(1, 11, 3)); pb.setDefaultDialogBorder(); pwdLbl.setVisible(false); passwordTF.setVisible(false); instLbl.setVisible(false); instCmbx.setVisible(false); final CustomDialog dlg = new CustomDialog(this, "Add User", true, OKCANCEL, pb.getPanel()) { @Override protected void okButtonPressed() { String usrName = userNameTF.getText(); if (cloudHelper.isUserNameOK(usrName)) { String collGuid = datasetGUIDList.get(dataSetList.getSelectedIndex()); if (cloudHelper.addUserAccessToDataSet(usrName, collGuid)) { super.okButtonPressed(); } else { iPadDBExporterPlugin.setErrorMsg(statusLbl, String.format("Unable to add usr: %s to the DataSet guid: %s", usrName, collGuid)); } } else if (isNewUser.isSelected()) { String pwdStr = passwordTF.getText(); String guid = null; if (instCmbx.getSelectedIndex() == 0) { // InstDlg instDlg = new InstDlg(cloudHelper); // if (!instDlg.isInstOK()) // { // instDlg.createUI(); // instDlg.pack(); // centerAndShow(instDlg, 600, null); // if (instDlg.isCancelled()) // { // return; // } // //guid = instDlg.getGuid()(); // } } else { //webSite = wsList.get(instCmbx.getSelectedIndex()); } if (guid != null) { String collGuid = datasetGUIDList.get(dataSetList.getSelectedIndex()); if (cloudHelper.addNewUser(usrName, pwdStr, guid)) { if (cloudHelper.addUserAccessToDataSet(usrName, collGuid)) { ManageDataSetsDlg.this.loadUsersForDataSetsIntoJList(); super.okButtonPressed(); } else { iPadDBExporterPlugin.setErrorMsg(statusLbl, String.format("Unable to add%s to the DataSet %s", usrName, collGuid)); } } else { iPadDBExporterPlugin.setErrorMsg(statusLbl, String.format("Unable to add%s to the DataSet %s", usrName, collGuid)); } } else { // error } } else { iPadDBExporterPlugin.setErrorMsg(statusLbl, String.format("'%s' doesn't exist.", usrName)); } } }; KeyAdapter ka = new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { statusLbl.setText(""); String usrNmStr = userNameTF.getText(); boolean hasData = StringUtils.isNotEmpty(usrNmStr) && (!isNewUser.isSelected() || StringUtils.isNotEmpty(passwordTF.getText())) && UIHelper.isValidEmailAddress(usrNmStr); dlg.getOkBtn().setEnabled(hasData); } }; userNameTF.addKeyListener(ka); passwordTF.addKeyListener(ka); final Color textColor = userNameTF.getForeground(); FocusAdapter fa = new FocusAdapter() { @Override public void focusGained(FocusEvent e) { JTextField tf = (JTextField) e.getSource(); if (!tf.getForeground().equals(textColor)) { tf.setText(""); tf.setForeground(textColor); } } @Override public void focusLost(FocusEvent e) { JTextField tf = (JTextField) e.getSource(); if (tf.getText().length() == 0) { tf.setText("Enter email address"); tf.setForeground(Color.LIGHT_GRAY); } } }; userNameTF.addFocusListener(fa); userNameTF.setText("Enter email address"); userNameTF.setForeground(Color.LIGHT_GRAY); isNewUser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean isSel = isNewUser.isSelected(); pwdLbl.setVisible(isSel); passwordTF.setVisible(isSel); instLbl.setVisible(isSel); instCmbx.setVisible(isSel); Dimension s = dlg.getSize(); int hgt = isNewUser.getSize().height + 4 + instCmbx.getSize().height; s.height += isSel ? hgt : -hgt; dlg.setSize(s); } }); dlg.createUI(); dlg.getOkBtn().setEnabled(false); centerAndShow(dlg); if (!dlg.isCancelled()) { loadUsersForDataSetsIntoJList(); } }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.EditorPropPanelBase.java
/** * @param fc//from w w w .j a va2 s. com * @param rows * @param rowInx * @param cols * @param colInx */ public void setDataIntoUI(final FormCell fc, final int rows, final int rowDefs, final int rowInx, final int cols, final int colDefs, final int colInx) { if (formViewObj == null) { return; } currentData = fc; setDataIntoBase(fc, rows, rowDefs, rowInx, cols, colDefs, colInx, false); JTextField typeLabel = (JTextField) formViewObj.getControlByName("type"); //$NON-NLS-1$ typeLabel.setText(fc.getType().toString()); if (fc instanceof FormCellLabel) { FormCellLabel fcl = (FormCellLabel) fc; getIdCombobox(fcl.getLabelFor()); processImageNameCBX(fcl.getIconName()); ValCheckBox chkbx = (ValCheckBox) formViewObj.getControlByName("isRecordObj"); //$NON-NLS-1$ chkbx.setSelected(fcl.isRecordObj()); ((ValTextField) formViewObj.getControlByName("label")).setText(((FormCellLabel) fc).getLabel()); //$NON-NLS-1$ } multiView.validateAll(); }
From source file:com.biosis.biosislite.vistas.Configuracion.java
private void guardar(Properties fichero, String urlFichero, JComboBox combo, JTextField txtConexion, JTextField txtUsuario, JTextField txtPassword) { int tipoBD = combo.getSelectedIndex() + 1; // String driver = ParametrosUtil.obtenerDriver(tipoBD); String url = txtConexion.getText(); String usuario = txtUsuario.getText(); String password = txtPassword.getText(); // combo.setSelectedIndex(tipoBD - 1); txtConexion.setText(url); txtUsuario.setText(usuario);//from w w w.j a v a 2 s .c o m txtPassword.setText(password); fichero.setProperty("url", url); fichero.setProperty("usuario", usuario); fichero.setProperty("password", Encriptador.encrypt(password)); fichero.setProperty("tipo", tipoBD + ""); PropertiesUtil.guardarProperties(fichero, urlFichero); }
From source file:EditorPaneTest.java
public EditorPaneFrame() { setTitle("EditorPaneTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); final Stack<String> urlStack = new Stack<String>(); final JEditorPane editorPane = new JEditorPane(); final JTextField url = new JTextField(30); // set up hyperlink listener editorPane.setEditable(false);/* w w w . ja v a 2s . c om*/ editorPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { // remember URL for back button urlStack.push(event.getURL().toString()); // show URL in text field url.setText(event.getURL().toString()); editorPane.setPage(event.getURL()); } catch (IOException e) { editorPane.setText("Exception: " + e); } } } }); // set up checkbox for toggling edit mode final JCheckBox editable = new JCheckBox(); editable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { editorPane.setEditable(editable.isSelected()); } }); // set up load button for loading URL ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { try { // remember URL for back button urlStack.push(url.getText()); editorPane.setPage(url.getText()); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }; JButton loadButton = new JButton("Load"); loadButton.addActionListener(listener); url.addActionListener(listener); // set up back button and button action JButton backButton = new JButton("Back"); backButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { if (urlStack.size() <= 1) return; try { // get URL from back button urlStack.pop(); // show URL in text field String urlString = urlStack.peek(); url.setText(urlString); editorPane.setPage(urlString); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }); add(new JScrollPane(editorPane), BorderLayout.CENTER); // put all control components in a panel JPanel panel = new JPanel(); panel.add(new JLabel("URL")); panel.add(url); panel.add(loadButton); panel.add(backButton); panel.add(new JLabel("Editable")); panel.add(editable); add(panel, BorderLayout.SOUTH); }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.EditorPropPanelBase.java
/** * @param fcf//w w w . j a va2s . com * @param rows * @param rowInx * @param cols * @param colInx */ public void setDataIntoUI(final FormCellField fcf, final int rows, final int rowDefs, final int rowInx, final int cols, final int colDefs, final int colInx) { if (formViewObj == null) { return; } currentData = fcf; //viewPanel.getMultiView().setData(fcf); int inx; int cnt; setDataIntoBase(fcf, rows, rowDefs, rowInx, cols, colDefs, colInx, true); setDataIntoBase(fcf); JTextField typeLabel = (JTextField) formViewObj.getControlByName("type"); //$NON-NLS-1$ typeLabel.setText(fcf.getUiType().toString()); /* ValComboBox typeCBX = (ValComboBox)formViewObj.getControlByName("typecbx"); DefaultComboBoxModel model = (DefaultComboBoxModel)typeCBX.getModel(); inx = -1; cnt = 0; for (String type : subcontrolHash.keySet()) { model.addElement(type); if (type.equals(fcf.getUiType().toString())) { inx = cnt; } cnt++; } typeCBX.getComboBox().setSelectedIndex(inx);*/ if (fcf.getUiType() == FormCellFieldIFace.FieldType.combobox) { DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); List<?> pickLists = session.getDataList(PickList.class); ValComboBox pickListCBX = (ValComboBox) formViewObj.getControlByName("picklistcbx"); //$NON-NLS-1$ DefaultComboBoxModel model = (DefaultComboBoxModel) pickListCBX.getModel(); inx = 0; cnt = 1; String dataPickListName = fcf.getPickListName(); pickList.clear(); model.addElement(getResourceString("EditorPropPanelBase.NONE")); //$NON-NLS-1$ for (Iterator<?> iter = pickLists.iterator(); iter.hasNext();) { PickList pl = (PickList) iter.next(); String name = pl.getName(); pickList.put(pl.getName(), pl.getIdentityTitle()); model.addElement(name); if (StringUtils.isNotEmpty(dataPickListName) && dataPickListName.equals(name)) { inx = cnt; } cnt++; } session.close(); pickListCBX.getComboBox().setSelectedIndex(inx); ValTextArea textArea = (ValTextArea) formViewObj.getControlByName("list"); //$NON-NLS-1$ String list = fcf.getProperty("list"); //$NON-NLS-1$ if (list != null) { textArea.setText(list); } } multiView.validateAll(); }
From source file:com.biosis.biosislite.vistas.Configuracion.java
private void guardar(Properties fichero, String urlFichero, JComboBox combo, JTextField txtConexion, JTextField txtUsuario, JTextField txtPassword, boolean selected) { int tipoBD = combo.getSelectedIndex() + 1; // String driver = ParametrosUtil.obtenerDriver(tipoBD); String url = txtConexion.getText(); String usuario = txtUsuario.getText(); String password = txtPassword.getText(); // combo.setSelectedIndex(tipoBD - 1); txtConexion.setText(url); txtUsuario.setText(usuario);//w w w.jav a2 s. c om txtPassword.setText(password); fichero.setProperty("url", url); fichero.setProperty("usuario", usuario); fichero.setProperty("password", Encriptador.encrypt(password)); fichero.setProperty("tipo", tipoBD + ""); if (selected) { fichero.setProperty("action", "create"); } else { fichero.setProperty("action", "none"); } PropertiesUtil.guardarProperties(fichero, urlFichero); }
From source file:com.biosis.biosislite.vistas.Configuracion.java
private void cargar(Properties fichero, JComboBox combo, JTextField txtConexion, JTextField txtUsuario, JTextField txtPassword) { int tipoBD = Integer.parseInt(fichero.getProperty("tipo")); // String driver = ParametrosUtil.obtenerDriver(tipoBD); String url = fichero.getProperty("url"); String usuario = fichero.getProperty("usuario"); String password = fichero.getProperty("password"); combo.setSelectedIndex(tipoBD - 1);/*from ww w . j av a 2 s . com*/ txtConexion.setText(url); txtUsuario.setText(usuario); txtPassword.setText(Encriptador.decrypt(password)); }