List of usage examples for javax.swing JTextField setEnabled
@BeanProperty(expert = true, preferred = true, visualUpdate = true, description = "The enabled state of the component.") public void setEnabled(boolean enabled)
From source file:org.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent.java
public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); // Numero du commande c.gridx = 0;//from www. j av a 2 s . co m this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c); this.numeroUniqueCommande = new JUniqueTextField(16); c.fill = GridBagConstraints.NONE; c.gridx++; c.weightx = 1; this.add(this.numeroUniqueCommande, c); // Date JLabel labelDate = new JLabel(getLabelFor("DATE")); labelDate.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 2; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.add(labelDate, c); JDate dateCommande = new JDate(true); c.gridx++; c.fill = GridBagConstraints.NONE; this.add(dateCommande, c); // Champ Module c.gridx = 0; c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; final JPanel addP = ComptaSQLConfElement.createAdditionalPanel(); this.setAdditionalFieldsPanel(new FormLayouter(addP, 2)); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; this.add(addP, c); c.gridy++; c.gridwidth = 1; this.comboDevis = new ElementComboBox(); // Reference c.gridx = 0; c.gridy++; c.gridwidth = 1; c.gridwidth = 1; c.gridheight = 1; c.fill = GridBagConstraints.HORIZONTAL; JLabel labelObjet = new JLabel(getLabelFor("NOM")); labelObjet.setHorizontalAlignment(SwingConstants.RIGHT); c.weightx = 0; this.add(labelObjet, c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.BOTH; this.add(this.textObjet, c); String field; field = "ID_COMMERCIAL"; c.fill = GridBagConstraints.HORIZONTAL; // Commercial JLabel labelCommercial = new JLabel(getLabelFor(field)); labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx++; c.weightx = 0; this.add(labelCommercial, c); this.comboCommercial = new ElementComboBox(false, 25); this.comboCommercial.setListIconVisible(false); c.gridx++; c.fill = GridBagConstraints.NONE; c.weightx = 1; this.add(this.comboCommercial, c); addRequiredSQLObject(this.comboCommercial, field); // Ligne 3: Client c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c); this.comboClient = new ElementComboBox(); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 3; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(this.comboClient, c); final ElementComboBox boxTarif = new ElementComboBox(); this.comboClient.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!isFilling() && comboClient.getValue() != null) { Integer id = comboClient.getValue(); if (id > 1) { SQLRow row = comboClient.getElement().getTable().getRow(id); if (comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) { SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF"); if (!foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID()) && JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) { boxTarif.setValue(foreignRow.getID()); // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow, // true); } else { boxTarif.setValue(foreignRow.getID()); } // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF"); // if (foreignRow.isUndefined() && // !row.getForeignRow("ID_DEVISE").isUndefined()) { // SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable()); // rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE")); // foreignRow = rowValsD; // // } // table.setTarif(foreignRow, true); } } } } }); // tarif if (this.getTable().getFieldsName().contains("ID_TARIF")) { // TARIF c.gridy++; c.gridx = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; this.add(new JLabel("Tarif appliquer"), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; this.add(boxTarif, c); this.addView(boxTarif, "ID_TARIF"); boxTarif.addModelListener("wantedID", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID()); table.setTarif(selectedRow, false); } }); } // Table d'lment this.table = new CommandeClientItemTable(); c.fill = GridBagConstraints.BOTH; c.gridy++; c.gridx = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = GridBagConstraints.REMAINDER; this.add(this.table, c); DeviseField textPortHT = new DeviseField(); DeviseField textRemiseHT = new DeviseField(); // INfos c.gridx = 0; c.gridy++; c.gridheight = 1; c.weighty = 0; c.weightx = 1; c.anchor = GridBagConstraints.WEST; c.gridwidth = 2; this.add(new TitledSeparator(getLabelFor("INFOS")), c); c.gridy++; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.BOTH; final JScrollPane scrollPane = new JScrollPane(this.infos); scrollPane.setBorder(null); this.add(scrollPane, c); // Poids c.gridwidth = 1; DefaultProps props = DefaultNXProps.getInstance(); Boolean b = props.getBooleanValue("ArticleShowPoids"); final JTextField textPoidsTotal = new JTextField(8); if (b) { JPanel panel = new JPanel(); panel.add(new JLabel(getLabelFor("T_POIDS")), c); textPoidsTotal.setEnabled(false); textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT); textPoidsTotal.setDisabledTextColor(Color.BLACK); panel.add(textPoidsTotal, c); panel.setOpaque(false); DefaultGridBagConstraints.lockMinimumSize(panel); c.gridx = 2; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHEAST; this.add(panel, c); } // Total DeviseField fieldHT = new DeviseField(); DeviseField fieldTVA = new DeviseField(); DeviseField fieldTTC = new DeviseField(); DeviseField fieldDevise = new DeviseField(); DeviseField fieldService = new DeviseField(); DeviseField fieldHA = new DeviseField(); fieldHT.setOpaque(false); fieldHA.setOpaque(false); fieldTVA.setOpaque(false); fieldTTC.setOpaque(false); fieldService.setOpaque(false); addSQLObject(fieldDevise, "T_DEVISE"); addRequiredSQLObject(fieldHT, "T_HT"); addRequiredSQLObject(fieldTVA, "T_TVA"); addRequiredSQLObject(fieldTTC, "T_TTC"); addRequiredSQLObject(fieldService, "T_SERVICE"); if (getTable().contains("PREBILAN")) { addSQLObject(fieldHA, "PREBILAN"); } else if (getTable().contains("T_HA")) { addSQLObject(fieldHA, "T_HA"); } JTextField poids = new JTextField(); // addSQLObject(poids, "T_POIDS"); final TotalPanel totalTTC = new TotalPanel(this.table, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, fieldHA, fieldDevise, poids, null); c.gridx = GridBagConstraints.RELATIVE; c.gridy--; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 2; c.anchor = GridBagConstraints.NORTHEAST; c.fill = GridBagConstraints.NONE; c.weighty = 0; this.add(totalTTC, c); this.panelOO = new PanelOOSQLComponent(this); c.gridwidth = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; c.gridx = 0; c.gridy += 3; c.weightx = 0; c.gridwidth = GridBagConstraints.REMAINDER; this.add(this.panelOO, c); textPortHT.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void removeUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void insertUpdate(DocumentEvent e) { totalTTC.updateTotal(); } }); textRemiseHT.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void removeUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void insertUpdate(DocumentEvent e) { totalTTC.updateTotal(); } }); addRequiredSQLObject(this.comboClient, "ID_CLIENT"); addSQLObject(this.textObjet, "NOM"); addSQLObject(textPoidsTotal, "T_POIDS"); addRequiredSQLObject(dateCommande, "DATE"); // addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS"); addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO"); addSQLObject(this.infos, "INFOS"); addSQLObject(this.comboDevis, "ID_DEVIS"); this.numeroUniqueCommande .setText(NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date())); this.table.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { textPoidsTotal.setText(String.valueOf(CommandeClientSQLComponent.this.table.getPoidsTotal())); } }); DefaultGridBagConstraints.lockMinimumSize(comboClient); DefaultGridBagConstraints.lockMinimumSize(comboCommercial); DefaultGridBagConstraints.lockMinimumSize(comboDevis); DefaultGridBagConstraints.lockMinimumSize(totalTTC); DefaultGridBagConstraints.lockMaximumSize(totalTTC); DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande); }
From source file:org.openconcerto.erp.core.sales.shipment.component.BonDeLivraisonSQLComponent.java
private void reconfigure(JTextField field) { field.setEnabled(false); field.setHorizontalAlignment(JTextField.RIGHT); field.setDisabledTextColor(Color.BLACK); field.setBorder(null);// w w w . java 2 s .c om }
From source file:org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent.java
private JPanel getBottomPanel() { final JPanel panel = new JPanel(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); // Colonne 1 : Infos c.gridx = 0;/*from w w w . j a v a 2s. com*/ c.weightx = 1; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; panel.add(new TitledSeparator(getLabelFor("INFOS")), c); c.gridy++; c.weighty = 0; c.weightx = 1; c.fill = GridBagConstraints.BOTH; final JScrollPane scrollPane = new JScrollPane(this.infos); scrollPane.setBorder(null); panel.add(scrollPane, c); // Colonne 2 : Poids & autres DefaultProps props = DefaultNXProps.getInstance(); Boolean b = props.getBooleanValue("ArticleShowPoids"); final JTextField textPoidsTotal = new JTextField(8); JTextField poids = new JTextField(); if (b) { final JPanel panelPoids = new JPanel(); panelPoids.add(new JLabel(getLabelFor("T_POIDS")), c); textPoidsTotal.setEnabled(false); textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT); textPoidsTotal.setDisabledTextColor(Color.BLACK); panelPoids.add(textPoidsTotal, c); c.gridx++; c.gridy = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.gridheight = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHEAST; panel.add(panelPoids, c); DefaultGridBagConstraints.lockMinimumSize(panelPoids); addSQLObject(textPoidsTotal, "T_POIDS"); } else { addSQLObject(poids, "T_POIDS"); } DeviseField textPortHT = new DeviseField(); ElementComboBox comboTaxePort = new ElementComboBox(); if (getTable().contains("PORT_HT")) { addRequiredSQLObject(textPortHT, "PORT_HT"); final JPanel panelPoids = new JPanel(new GridBagLayout()); GridBagConstraints cPort = new DefaultGridBagConstraints(); cPort.gridx = 0; cPort.weightx = 0; panelPoids.add(new JLabel(getLabelFor("PORT_HT")), cPort); textPortHT.setHorizontalAlignment(JTextField.RIGHT); cPort.gridx++; cPort.weightx = 1; panelPoids.add(textPortHT, cPort); cPort.gridy++; cPort.gridx = 0; cPort.weightx = 0; addRequiredSQLObject(comboTaxePort, "ID_TAXE_PORT"); panelPoids.add(new JLabel(getLabelFor("ID_TAXE_PORT")), cPort); cPort.gridx++; cPort.weightx = 0; panelPoids.add(comboTaxePort, cPort); c.gridx++; c.gridy = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.gridheight = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHEAST; panel.add(panelPoids, c); DefaultGridBagConstraints.lockMinimumSize(panelPoids); } // Total DeviseField textRemiseHT = new DeviseField(); DeviseField fieldHT = new DeviseField(); DeviseField fieldTVA = new DeviseField(); DeviseField fieldTTC = new DeviseField(); DeviseField fieldDevise = new DeviseField(); DeviseField fieldService = new DeviseField(); fieldHT.setOpaque(false); fieldTVA.setOpaque(false); fieldTTC.setOpaque(false); fieldService.setOpaque(false); addRequiredSQLObject(fieldDevise, "T_DEVISE"); addRequiredSQLObject(fieldHT, "T_HT"); addRequiredSQLObject(fieldTVA, "T_TVA"); addRequiredSQLObject(fieldTTC, "T_TTC"); addRequiredSQLObject(fieldService, "T_SERVICE"); final TotalPanel totalTTC = new TotalPanel(this.table, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null, (getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null)); c.gridx++; c.gridy--; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 2; c.anchor = GridBagConstraints.NORTHEAST; c.fill = GridBagConstraints.BOTH; c.weighty = 0; DefaultGridBagConstraints.lockMinimumSize(totalTTC); panel.add(totalTTC, c); c.gridy += 3; c.gridheight = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; panel.add(getModuleTotalPanel(), c); table.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { textPoidsTotal.setText(String.valueOf(table.getPoidsTotal())); } }); textPortHT.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void removeUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void insertUpdate(DocumentEvent e) { totalTTC.updateTotal(); } }); comboTaxePort.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { // TODO Raccord de mthode auto-gnr totalTTC.updateTotal(); } }); textRemiseHT.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void removeUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void insertUpdate(DocumentEvent e) { totalTTC.updateTotal(); } }); return panel; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserProfile.java
/** * Builds the panel hosting the user's details. * /*from w ww . j av a 2 s.c om*/ * @return See above. */ private JPanel buildContentPanel() { ExperimenterData user = (ExperimenterData) model.getRefObject(); boolean editable = model.isUserOwner(user); if (!editable) editable = MetadataViewerAgent.isAdministrator(); details = EditorUtil.convertExperimenter(user); JPanel content = new JPanel(); content.setBorder(BorderFactory.createTitledBorder("User")); content.setBackground(UIUtilities.BACKGROUND_COLOR); Entry<String, String> entry; Iterator<Entry<String, String>> i = details.entrySet().iterator(); JComponent label; JTextField area; String key, value; content.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 2, 2, 0); //Add log in name but cannot edit. c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER;//end row c.fill = GridBagConstraints.HORIZONTAL; content.add(buildProfileCanvas(), c); c.gridy++; c.gridx = 0; label = EditorUtil.getLabel(EditorUtil.DISPLAY_NAME, true); label.setBackground(UIUtilities.BACKGROUND_COLOR); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE;//reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER;//end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; loginArea.setText(user.getUserName()); loginArea.setEnabled(false); loginArea.setEditable(false); if (MetadataViewerAgent.isAdministrator() && !model.isSystemUser(user.getId()) && !model.isSelf()) { loginArea.setEnabled(true); loginArea.getDocument().addDocumentListener(this); } content.add(loginArea, c); while (i.hasNext()) { ++c.gridy; c.gridx = 0; entry = i.next(); key = entry.getKey(); value = entry.getValue(); label = EditorUtil.getLabel(key, EditorUtil.FIRST_NAME.equals(key) || EditorUtil.LAST_NAME.equals(key)); area = new JTextField(value); area.setBackground(UIUtilities.BACKGROUND_COLOR); area.setEditable(editable); area.setEnabled(editable); if (editable) area.getDocument().addDocumentListener(this); items.put(key, area); label.setBackground(UIUtilities.BACKGROUND_COLOR); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE;//reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER;//end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(area, c); } c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.DEFAULT_GROUP, false); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE;//reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(groupsBox, c); c.gridy++; content.add(permissionsPane, c); c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.GROUP_OWNER, false); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE; //reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; //end row c.fill = GridBagConstraints.NONE; c.weightx = 1.0; content.add(ownerBox, c); if (activeBox.isVisible()) { c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.ACTIVE, false); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE; c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.NONE; c.weightx = 1.0; content.add(activeBox, c); } if (adminBox.isVisible()) { c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.ADMINISTRATOR, false); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE; c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.NONE; c.weightx = 1.0; content.add(adminBox, c); } c.gridx = 0; c.gridy++; content.add(Box.createHorizontalStrut(10), c); c.gridy++; label = UIUtilities.setTextFont(EditorUtil.MANDATORY_DESCRIPTION, Font.ITALIC); label.setForeground(UIUtilities.REQUIRED_FIELDS_COLOR); c.weightx = 0.0; content.add(label, c); return content; }
From source file:org.pentaho.ui.xul.swing.tags.SwingTree.java
private TableCellEditor getCellEditor(final SwingTreeCol col) { return new DefaultCellEditor(new JComboBox()) { JComponent control;//from w ww .j a v a2s. co m @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, final int row, final int column) { Component comp; ColumnType colType = col.getColumnType(); if (colType == ColumnType.DYNAMIC) { colType = ColumnType.valueOf(extractDynamicColType(elements.toArray()[row], column)); } final XulTreeCell cell = getRootChildren().getItem(row).getRow().getCell(column); switch (colType) { case CHECKBOX: final JCheckBox checkbox = new JCheckBox(); final JTable tbl = table; checkbox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { SwingTree.this.table.setValueAt(checkbox.isSelected(), row, column); tbl.getCellEditor().stopCellEditing(); } }); control = checkbox; if (value instanceof String) { checkbox.setSelected(((String) value).equalsIgnoreCase("true")); //$NON-NLS-1$ } else if (value instanceof Boolean) { checkbox.setSelected((Boolean) value); } else if (value == null) { checkbox.setSelected(false); } if (isSelected) { checkbox.setBackground(Color.LIGHT_GRAY); } comp = checkbox; checkbox.setEnabled(!cell.isDisabled()); break; case EDITABLECOMBOBOX: case COMBOBOX: Vector val = (value != null && value instanceof Vector) ? (Vector) value : new Vector(); final JComboBox comboBox = new JComboBox(val); if (isSelected) { comboBox.setBackground(Color.LIGHT_GRAY); } if (colType == ColumnType.EDITABLECOMBOBOX) { comboBox.setEditable(true); final JTextComponent textComp = (JTextComponent) comboBox.getEditor().getEditorComponent(); textComp.addKeyListener(new KeyListener() { private String oldValue = ""; //$NON-NLS-1$ public void keyPressed(KeyEvent e) { oldValue = textComp.getText(); } public void keyReleased(KeyEvent e) { if (oldValue != null && !oldValue.equals(textComp.getText())) { SwingTree.this.table.setValueAt(textComp.getText(), row, column); oldValue = textComp.getText(); } else if (oldValue == null) { // AWT error where sometimes the keyReleased is fired before keyPressed. oldValue = textComp.getText(); } else { logger.debug("Special key pressed, ignoring"); //$NON-NLS-1$ } } public void keyTyped(KeyEvent e) { } }); comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // if(textComp.hasFocus() == false && comboBox.hasFocus()){ SwingTree.logger.debug("Setting ComboBox value from editor: " //$NON-NLS-1$ + comboBox.getSelectedItem() + ", " + row + ", " + column); //$NON-NLS-1$ //$NON-NLS-2$ SwingTree.this.table.setValueAt(comboBox.getSelectedIndex(), row, column); // } } }); } else { comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { SwingTree.logger.debug("Setting ComboBox value from editor: " //$NON-NLS-1$ + comboBox.getSelectedItem() + ", " + row + ", " + column); //$NON-NLS-1$ //$NON-NLS-2$ SwingTree.this.table.setValueAt(comboBox.getSelectedIndex(), row, column); } }); } control = comboBox; comboBox.setEnabled(!cell.isDisabled()); comp = comboBox; break; case LABEL: JLabel lbl = new JLabel(cell.getLabel()); comp = lbl; control = lbl; break; case CUSTOM: return new CustomCellEditorWrapper(cell, customEditors.get(col.getType())); default: final JTextField label = new JTextField((String) value); label.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent arg0) { SwingTree.this.table.setValueAt(label.getText(), row, column); } public void insertUpdate(DocumentEvent arg0) { SwingTree.this.table.setValueAt(label.getText(), row, column); } public void removeUpdate(DocumentEvent arg0) { SwingTree.this.table.setValueAt(label.getText(), row, column); } }); if (isSelected) { label.setOpaque(true); // label.setBackground(Color.LIGHT_GRAY); } control = label; comp = label; label.setEnabled(!cell.isDisabled()); label.setDisabledTextColor(Color.DARK_GRAY); break; } return comp; } @Override public Object getCellEditorValue() { if (control instanceof JCheckBox) { return ((JCheckBox) control).isSelected(); } else if (control instanceof JComboBox) { JComboBox box = (JComboBox) control; if (box.isEditable()) { return ((JTextComponent) box.getEditor().getEditorComponent()).getText(); } else { return box.getSelectedIndex(); } } else if (control instanceof JTextField) { return ((JTextField) control).getText(); } else { return ((JLabel) control).getText(); } } }; }
From source file:org.scify.talkandplay.gui.users.UserFormPanel.java
private void disableTextField(JTextField textField) { textField.setEnabled(false); textField.setForeground(Color.decode(UIConstants.disabledColor)); textField.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.decode(UIConstants.disabledColor))); textField.setBorder(BorderFactory.createCompoundBorder(textField.getBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5))); }
From source file:org.scify.talkandplay.gui.users.UserFormPanel.java
private void enableTextField(JTextField textField) { textField.setEnabled(true); textField.setForeground(Color.decode(UIConstants.green)); textField.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.decode(UIConstants.green))); textField.setBorder(BorderFactory.createCompoundBorder(textField.getBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5))); }
From source file:org.ut.biolab.medsavant.client.variant.ExportVCFWizard.java
private AbstractDialogPage getFilePage() { final DefaultWizardPage page = new DefaultWizardPage("Choose File") { @Override/*from w w w . j a v a2s. c o m*/ public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); if (variantFile != null) { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } else { fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } } }; page.addText("Choose the file to save to:"); final JTextField outputFileField = new JTextField(); outputFileField.setEnabled(false); JButton chooseFileButton = new JButton("..."); chooseFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { variantFile = DialogUtils.chooseFileForSave("Export Variants", "export.vcf", ExtensionFileFilter.createFilters(new String[] { "vcf" }), null); if (variantFile == null) { page.fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } else { page.fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); outputFileField.setText(variantFile.getAbsolutePath()); } } }); JPanel container = new JPanel(); ViewUtil.clear(container); ViewUtil.applyHorizontalBoxLayout(container); container.add(outputFileField); container.add(chooseFileButton); page.addComponent(container); page.addText("Files will be exported in Variant Call Format (*.vcf)"); return page; }
From source file:org.ut.biolab.medsavant.client.variant.ImportVariantsWizard.java
private JPanel populateOnMyComputerPanel(final DefaultWizardPage page) { JPanel p = ViewUtil.getClearPanel(); ViewUtil.applyVerticalBoxLayout(p);//from w w w . jav a2 s . c om final JTextField outputFileField = new JTextField(); ViewUtil.clear(outputFileField); outputFileField.setEnabled(false); JButton chooseFileButton = new JButton("..."); chooseFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { variantFiles = DialogUtils.chooseFilesForOpen("Import Variants", new ExtensionsFileFilter(new String[] { "vcf", "vcf.gz" }), null); if (variantFiles == null || variantFiles.length == 0) { page.fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } else { page.fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } String path = getPathString(variantFiles); outputFileField.setText(path); if (variantFiles.length > 0) { page.fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } } private String getPathString(File[] files) { if (files.length > 1) { return files.length + " files"; } else if (files.length == 1) { return files[0].getAbsolutePath(); } else { return ""; } } }); JPanel container = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(container); container.add(outputFileField); container.add(chooseFileButton); p.add(ViewUtil.clear(ViewUtil.alignLeft(container))); return p; }
From source file:visolate.Visolate.java
private JPanel getInitialXPanel() { if (myInitialXPanel == null) { myInitialXPanel = new JPanel(); myInitialXPanel.setLayout(new BorderLayout()); myInitialXPanel.add(new JLabel("X"), BorderLayout.WEST); myInitialXPanel.setToolTipText("Left side is at this coordinate (mm or inch)"); myInitialXPanel.setEnabled(gCodeWriter.getIsAbsolute()); final JTextField field = new JTextField(NumberFormat.getInstance().format(gCodeWriter.getXOffset())); myInitialXPanel.add(field, BorderLayout.CENTER); myInitialXPanel.addPropertyChangeListener("enabled", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { field.setEnabled(myInitialXPanel.isEnabled()); }/*from w w w . j a va2 s. c om*/ }); field.setEnabled(myInitialXPanel.isEnabled()); field.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { try { gCodeWriter.setXOffset(NumberFormat.getInstance().parse(field.getText()).doubleValue()); } catch (ParseException e) { } field.setText(NumberFormat.getInstance().format(gCodeWriter.getXOffset())); } }); } return myInitialXPanel; }