List of usage examples for javax.swing.event DocumentListener DocumentListener
DocumentListener
From source file:com.openbravo.pos.imports.JPanelCSVImport.java
/** * Constructs a new JPanelCSVImport object * * @param props AppProperties/*from www. j av a2 s . com*/ */ @SuppressWarnings("empty-statement") public JPanelCSVImport(AppProperties props) { initComponents(); // Open Database session try { s = AppViewConnection.createSession(props); con = s.getConnection(); } catch (BasicException | SQLException e) { ; } /* * Create new datalogocsales & DataLogicSystem instances to allow access to sql routines. */ m_dlSales = new DataLogicSales(); m_dlSales.init(s); m_dlSystem = new DataLogicSystem(); m_dlSystem.init(s); spr = new SaveProvider(m_dlSales.getProductCatUpdate(), m_dlSales.getProductCatInsert(), m_dlSales.getProductCatDelete()); // Save Last file for later use. last_folder = props.getProperty("CSV.last_folder"); config_file = props.getConfigFile(); jFileName.getDocument().addDocumentListener(documentListener); documentListener = new DocumentListener() { @Override public void changedUpdate(DocumentEvent documentEvent) { jHeaderRead.setEnabled(true); } @Override public void insertUpdate(DocumentEvent documentEvent) { if (!"".equals(jFileName.getText().trim())) { jHeaderRead.setEnabled(true); } } @Override public void removeUpdate(DocumentEvent documentEvent) { if (jFileName.getText().trim().equals("")) { jHeaderRead.setEnabled(false); } } }; jFileName.getDocument().addDocumentListener(documentListener); }
From source file:com.github.benchdoos.weblocopener.weblocOpener.gui.EditDialog.java
private void initTextField(String pathToEditingFile) { textField.addMouseListener(new ClickListener() { @Override/*from w ww. jav a 2 s. c om*/ public void doubleClick(MouseEvent e) { textField.selectAll(); } }); textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { } @Override public void insertUpdate(DocumentEvent e) { updateTextFont(); } @Override public void removeUpdate(DocumentEvent e) { updateTextFont(); } private void updateTextFont() { UrlValidator urlValidator = new UrlValidator(); if (urlValidator.isValid(textField.getText())) { if (textField != null) { setTextFieldFont(textField.getFont(), TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); textField.setForeground(Color.BLUE); } } else { if (textField != null) { setTextFieldFont(textField.getFont(), TextAttribute.UNDERLINE, -1); textField.setForeground(Color.BLACK); } } } }); UndoManager undoManager = new UndoManager(); textField.getDocument().addUndoableEditListener(new UndoableEditListener() { public void undoableEditHappened(UndoableEditEvent evt) { undoManager.addEdit(evt.getEdit()); } }); textField.getActionMap().put("Undo", new AbstractAction("Undo") { public void actionPerformed(ActionEvent evt) { try { if (undoManager.canUndo()) { undoManager.undo(); } } catch (CannotUndoException e) { } } }); textField.getInputMap().put(KeyStroke.getKeyStroke("control Z"), "Undo"); textField.getActionMap().put("Redo", new AbstractAction("Redo") { public void actionPerformed(ActionEvent evt) { try { if (undoManager.canRedo()) { undoManager.redo(); } } catch (CannotRedoException e) { } } }); textField.getInputMap().put(KeyStroke.getKeyStroke("control shift Z"), "Redo"); fillTextField(pathToEditingFile); }
From source file:net.sf.jabref.gui.FileListEntryEditor.java
public FileListEntryEditor(JabRefFrame frame, FileListEntry entry, boolean showProgressBar, boolean showOpenButton, BibDatabaseContext databaseContext) { this.entry = entry; this.databaseContext = databaseContext; ActionListener okAction = e -> { // If OK button is disabled, ignore this event: if (!ok.isEnabled()) { return; }/*from w ww. j a va2 s. co m*/ // If necessary, ask the external confirm object whether we are ready to close. if (externalConfirm != null) { // Construct an updated FileListEntry: storeSettings(entry); if (!externalConfirm.confirmClose(entry)) { return; } } diag.dispose(); storeSettings(FileListEntryEditor.this.entry); okPressed = true; }; types = new JComboBox<>(); types.addItemListener(itemEvent -> { if (!okDisabledExternally) { ok.setEnabled(types.getSelectedItem() != null); } }); FormBuilder builder = FormBuilder.create().layout(new FormLayout( "left:pref, 4dlu, fill:150dlu, 4dlu, fill:pref, 4dlu, fill:pref", "p, 2dlu, p, 2dlu, p")); builder.add(Localization.lang("Link")).xy(1, 1); builder.add(link).xy(3, 1); final BrowseListener browse = new BrowseListener(frame, link); final JButton browseBut = new JButton(Localization.lang("Browse")); browseBut.addActionListener(browse); builder.add(browseBut).xy(5, 1); JButton open = new JButton(Localization.lang("Open")); if (showOpenButton) { builder.add(open).xy(7, 1); } builder.add(Localization.lang("Description")).xy(1, 3); builder.add(description).xyw(3, 3, 3); builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); builder.add(Localization.lang("File type")).xy(1, 5); builder.add(types).xyw(3, 5, 3); if (showProgressBar) { builder.appendRows("2dlu, p"); builder.add(downloadLabel).xy(1, 7); builder.add(prog).xyw(3, 7, 3); } ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addRelatedGap(); bb.addButton(ok); JButton cancel = new JButton(Localization.lang("Cancel")); bb.addButton(cancel); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); ok.addActionListener(okAction); // Add OK action to the two text fields to simplify entering: link.addActionListener(okAction); description.addActionListener(okAction); open.addActionListener(e -> openFile()); AbstractAction cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { diag.dispose(); } }; cancel.addActionListener(cancelAction); // Key bindings: ActionMap am = builder.getPanel().getActionMap(); InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", cancelAction); link.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { checkExtension(); } @Override public void removeUpdate(DocumentEvent documentEvent) { // Do nothing } @Override public void changedUpdate(DocumentEvent documentEvent) { checkExtension(); } }); diag = new JDialog(frame, Localization.lang("Save file"), true); diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER); diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); diag.pack(); diag.setLocationRelativeTo(frame); diag.addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent event) { if (openBrowseWhenShown && !dontOpenBrowseUntilDisposed) { dontOpenBrowseUntilDisposed = true; SwingUtilities.invokeLater(() -> browse.actionPerformed(new ActionEvent(browseBut, 0, ""))); } } @Override public void windowClosed(WindowEvent event) { dontOpenBrowseUntilDisposed = false; } }); setValues(entry); }
From source file:eu.europeana.sip.gui.SipCreatorGUI.java
private Component createFilterPanel() { JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createTitledBorder("Filter")); filterTimer = new Timer(300, new ActionListener() { @Override/*from www . j a va 2 s . com*/ public void actionPerformed(ActionEvent actionEvent) { dataSetList.clearSelection(); dataSetListModel.setPattern(filter.getText()); } }); filterTimer.setRepeats(false); filter.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { filterTimer.restart(); } @Override public void removeUpdate(DocumentEvent documentEvent) { filterTimer.restart(); } @Override public void changedUpdate(DocumentEvent documentEvent) { filterTimer.restart(); } }); p.add(filter, BorderLayout.CENTER); return p; }
From source file:me.philnate.textmanager.windows.MainWindow.java
/** * Initialize the contents of the frame. *///from ww w . j a va 2 s. co m private void initialize() { changeListener = new ChangeListener(); frame = new JFrame(); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { Starter.shutdown(); } }); frame.setBounds(100, 100, 1197, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new MigLayout("", "[grow]", "[][grow][::16px]")); customers = new CustomerComboBox(); customers.addItemListener(changeListener); frame.getContentPane().add(customers, "flowx,cell 0 0,growx"); jScrollPane = new JScrollPane(); billLines = new BillingItemTable(frame, true); jScrollPane.setViewportView(billLines); frame.getContentPane().add(jScrollPane, "cell 0 1,grow"); // for each file added through drag&drop create a new lineItem new FileDrop(jScrollPane, new FileDrop.Listener() { @Override public void filesDropped(File[] files) { for (File file : files) { addNewBillingItem(Document.loadAndSave(file)); } } }); monthChooser = new JMonthChooser(); monthChooser.addPropertyChangeListener(changeListener); frame.getContentPane().add(monthChooser, "cell 0 0"); yearChooser = new JYearChooser(); yearChooser.addPropertyChangeListener(changeListener); frame.getContentPane().add(yearChooser, "cell 0 0"); JButton btnAddLine = new JButton(); btnAddLine.setIcon(ImageRegistry.getImage("load.gif")); btnAddLine.setToolTipText(getCaption("mw.tooltip.add")); btnAddLine.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addNewBillingItem(); } }); frame.getContentPane().add(btnAddLine, "cell 0 0"); JButton btnMassAdd = new JButton(); btnMassAdd.setIcon(ImageRegistry.getImage("load_all.gif")); btnMassAdd.setToolTipText(getCaption("mw.tooltip.massAdd")); btnMassAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JFileChooser file = new DocXFileChooser(); switch (file.showOpenDialog(frame)) { case JFileChooser.APPROVE_OPTION: File[] files = file.getSelectedFiles(); if (null != files) { for (File fl : files) { addNewBillingItem(Document.loadAndSave(fl)); } } break; default: return; } } }); frame.getContentPane().add(btnMassAdd, "cell 0 0"); billNo = new JTextField(); // enable/disable build button based upon text in billNo billNo.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { setButtonStates(); } @Override public void insertUpdate(DocumentEvent arg0) { setButtonStates(); } @Override public void changedUpdate(DocumentEvent arg0) { setButtonStates(); } private void setButtonStates() { boolean notBlank = StringUtils.isNotBlank(billNo.getText()); build.setEnabled(notBlank); view.setEnabled(pdf.find(billNo.getText() + ".pdf").size() == 1); } }); frame.getContentPane().add(billNo, "cell 0 0"); billNo.setColumns(10); build = new JButton(); build.setEnabled(false);// disable build Button until there's some // billNo entered build.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (runningThread == null) { try { // check that billNo isn't empty or already used within // another Bill if (billNo.getText().trim().equals("")) { JOptionPane.showMessageDialog(frame, getCaption("mw.dialog.error.billNoBlank.msg"), getCaption("mw.dialog.error.billNoBlank.title"), JOptionPane.ERROR_MESSAGE); return; } try { bill.setBillNo(billNo.getText()).save(); } catch (DuplicateKey e) { // unset the internal value as this is already used bill.setBillNo(""); JOptionPane.showMessageDialog(frame, format(getCaption("mw.error.billNoUsed.msg"), billNo.getText()), getCaption("mw.dialog.error.billNoBlank.title"), JOptionPane.ERROR_MESSAGE); return; } PDFCreator pdf = new PDFCreator(bill); pdf.addListener(new ThreadCompleteListener() { @Override public void threadCompleted(NotifyingThread notifyingThread) { build.setToolTipText(getCaption("mw.tooltip.build")); build.setIcon(ImageRegistry.getImage("build.png")); runningThread = null; view.setEnabled(DB.pdf.find(billNo.getText() + ".pdf").size() == 1); } }); runningThread = new Thread(pdf); runningThread.start(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } build.setToolTipText(getCaption("mw.tooltip.build.cancel")); build.setIcon(ImageRegistry.getImage("cancel.gif")); } else { runningThread.interrupt(); runningThread = null; build.setToolTipText(getCaption("mw.tooltip.build")); build.setIcon(ImageRegistry.getImage("build.png")); } } }); build.setToolTipText(getCaption("mw.tooltip.build")); build.setIcon(ImageRegistry.getImage("build.png")); frame.getContentPane().add(build, "cell 0 0"); view = new JButton(); view.setToolTipText(getCaption("mw.tooltip.view")); view.setIcon(ImageRegistry.getImage("view.gif")); view.setEnabled(false); view.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { File file = new File(System.getProperty("user.dir"), format("template/%s.tmp.pdf", billNo.getText())); try { pdf.findOne(billNo.getText() + ".pdf").writeTo(file); new ProcessBuilder(Setting.find("pdfViewer").getValue(), file.getAbsolutePath()).start() .waitFor(); file.delete(); } catch (IOException | InterruptedException e1) { // TODO Auto-generated catch block LOG.warn("Error while building PDF", e1); } } }); frame.getContentPane().add(view, "cell 0 0"); statusBar = new JPanel(); statusBar.setBorder(new BevelBorder(BevelBorder.LOWERED)); statusBar.setLayout(new BoxLayout(statusBar, BoxLayout.X_AXIS)); GitRepositoryState state = DB.state; JLabel statusLabel = new JLabel(String.format("textManager Version v%s build %s", state.getCommitIdDescribe(), state.getBuildTime())); statusLabel.setHorizontalAlignment(SwingConstants.LEFT); statusBar.add(statusLabel); frame.add(statusBar, "cell 0 2,growx"); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu menu = new JMenu(getCaption("mw.menu.edit")); JMenuItem itemCust = new JMenuItem(getCaption("mw.menu.edit.customer")); itemCust.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { new CustomerWindow(customers); } }); menu.add(itemCust); JMenuItem itemSetting = new JMenuItem(getCaption("mw.menu.edit.settings")); itemSetting.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { new SettingWindow(); } }); menu.add(itemSetting); JMenuItem itemImport = new JMenuItem(getCaption("mw.menu.edit.import")); itemImport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { new ImportWindow(new ImportListener() { @Override public void entriesImported(List<BillingItem> items) { for (BillingItem item : items) { item.setCustomerId(customers.getSelectedCustomer().getId()) .setMonth(monthChooser.getMonth()).setYear(yearChooser.getYear()); item.save(); billLines.addRow(item); } } }, frame); } }); menu.add(itemImport); menuBar.add(menu); customers.loadCustomer(); fillTableModel(); }
From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectAdd.java
/** * This method initializes jTextFieldFilter * /*from ww w . ja v a2s. co m*/ * @return javax.swing.JTextField */ private JTextField getJTextFieldFilter() { if (jTextFieldFilter == null) { jTextFieldFilter = new JTextField(); jTextFieldFilter.setPreferredSize(new Dimension(300, 22)); jTextFieldFilter.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { newFilter(); } public void insertUpdate(DocumentEvent e) { newFilter(); } public void removeUpdate(DocumentEvent e) { newFilter(); } }); } return jTextFieldFilter; }
From source file:hermes.renderers.DefaultMessageRenderer.java
/** * Show the TextMessage in a JTextArea.//from www .j av a2s .c o m * * @param textMessage * @return * @throws JMSException */ protected JComponent handleTextMessage(final TextMessage textMessage) throws JMSException { // // Show the text in a JTextArea, you can edit the message in place and // then drop it onto another queue/topic. final String text = textMessage.getText(); final JTextArea textPane = new JTextArea(); // final CharBuffer bytes = CharBuffer.wrap(text.subSequence(0, // text.length())) ; // final JTextArea textPane = new MyTextArea(new PlainDocument(new // MappedStringContent(bytes))) ; textPane.setEditable(false); textPane.setFont(Font.decode("Monospaced-PLAIN-12")); textPane.setLineWrap(true); textPane.setWrapStyleWord(true); textPane.append(text); textPane.getDocument().addDocumentListener(new DocumentListener() { public void doChange() { try { textMessage.setText(textPane.getText()); } catch (JMSException e) { JOptionPane.showMessageDialog(textPane, "Unable to update the TextMessage: " + e.getMessage(), "Error modifying message content", JOptionPane.ERROR_MESSAGE); try { textPane.setText(textMessage.getText()); } catch (JMSException e1) { log.error(e1.getMessage(), e1); } textPane.setEditable(false); textPane.getDocument().removeDocumentListener(this); } } @Override public void changedUpdate(DocumentEvent arg0) { doChange(); } @Override public void insertUpdate(DocumentEvent arg0) { doChange(); } @Override public void removeUpdate(DocumentEvent arg0) { doChange(); } }); textPane.setCaretPosition(0); return textPane; }
From source file:com.petersoft.advancedswing.enhancedtextarea.EnhancedTextArea.java
private void initGUI() { try {/*from w w w .j av a2s . c om*/ BorderLayout thisLayout = new BorderLayout(); this.setLayout(thisLayout); this.setPreferredSize(new java.awt.Dimension(725, 290)); { jToolBar = new JToolBar(); this.add(jToolBar, BorderLayout.NORTH); { jSaveButton = new JButton(); jToolBar.add(jSaveButton); jSaveButton.setText("Save"); jSaveButton.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("com/petersoft/advancedswing/enhancedtextarea/disk.png"))); jSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jSaveButtonActionPerformed(evt); } }); } { jLineWrapButton = new JToggleButton(); jToolBar.add(jLineWrapButton); jLineWrapButton.setText("Wrap"); jLineWrapButton.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("com/petersoft/advancedswing/enhancedtextarea/linewrap.png"))); jLineWrapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jLineWrapButtonActionPerformed(evt); } }); } { jFontBiggerButton = new JButton(); jToolBar.add(jFontBiggerButton); jFontBiggerButton.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("com/petersoft/advancedswing/enhancedtextarea/font_add.png"))); jFontBiggerButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jFontBiggerButtonActionPerformed(evt); } }); } { jFontSmallerButton = new JButton(); jToolBar.add(jFontSmallerButton); jFontSmallerButton.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("com/petersoft/advancedswing/enhancedtextarea/font_delete.png"))); jFontSmallerButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jFontSmallerButtonActionPerformed(evt); } }); } { jLabel1 = new JLabel(); jToolBar.add(jLabel1); jLabel1.setText(" "); } { jSearchTextField = new JSearchTextField(); jToolBar.add(jSearchTextField); jSearchTextField.setMaximumSize(new java.awt.Dimension(100, 22)); jSearchTextField.setPreferredSize(new java.awt.Dimension(100, 22)); jSearchTextField.setSize(new java.awt.Dimension(100, 22)); jSearchTextField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent evt) { jSearchTextFieldKeyReleased(evt); } }); } { jSeparatorLabel = new JLabel(); jToolBar.add(jSeparatorLabel); jSeparatorLabel.setText(" "); } { GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts(); String fontNames[] = new String[fonts.length]; int x = 0; for (Font f : fonts) { fontNames[x++] = f.getFontName(); } ComboBoxModel jFontComboBoxModel = new DefaultComboBoxModel(fontNames); jFontComboBox = new JComboBox(); jToolBar.add(jFontComboBox); jFontComboBox.setModel(jFontComboBoxModel); jFontComboBox.setMaximumSize(new java.awt.Dimension(180, 22)); jFontComboBox.setPreferredSize(new java.awt.Dimension(180, 22)); jFontComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jFontComboBoxActionPerformed(evt); } }); } { pager = new Pager(); jToolBar.add(pager); pager.setVisible(false); } } { jScrollPane1 = new JScrollPane(); this.add(jScrollPane1, BorderLayout.CENTER); { jTextArea = new JTextArea(); jTextArea.getDocument().addDocumentListener(this); lines = new JTextArea(" 1 "); lines.setBackground(new Color(200, 230, 245)); lines.setEditable(false); jScrollPane1.setRowHeaderView(lines); jTextArea.getDocument().addDocumentListener(new DocumentListener() { public String getText() { int caretPosition = jTextArea.getDocument().getLength(); Element root = jTextArea.getDocument().getDefaultRootElement(); int base = 0; if (separateByLine == false) { if (str != null) { base = StringUtils.countMatches( str.substring(0, (pager.getPage() - 1) * pageSize), System.getProperty("line.separator")); if (base == 1) { base = 0; } } } else { base = (pager.getPage() - 1) * pageSize; } base += lineNoBase; String text = " " + (base + 1) + " " + System.getProperty("line.separator"); for (int i = 2; i < root.getElementIndex(caretPosition) + 2; i++) { text += " " + (base + i) + " " + System.getProperty("line.separator"); } return text; } @Override public void changedUpdate(DocumentEvent de) { lines.setText(getText()); } @Override public void insertUpdate(DocumentEvent de) { lines.setText(getText()); } @Override public void removeUpdate(DocumentEvent de) { lines.setText(getText()); } }); jScrollPane1.setViewportView(jTextArea); } } { jStatusPanel = new JPanel(); FlowLayout jStatusPanelLayout = new FlowLayout(); jStatusPanelLayout.setAlignment(FlowLayout.LEFT); jStatusPanel.setLayout(jStatusPanelLayout); this.add(jStatusPanel, BorderLayout.SOUTH); { jStatusLabel = new JLabel(); jStatusPanel.add(jStatusLabel); } { jSearchLabel = new JLabel(); jStatusPanel.add(jSearchLabel); } } this.jFontComboBox.setSelectedItem(jTextArea.getFont().getFamily() + ".plain"); } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.ku.brc.af.ui.weblink.WebLinkEditorDlg.java
@Override public void createUI() { super.createUI(); nameTF = UIHelper.createTextField(); baseUrlTF = UIHelper.createTextField(25); descTA = UIHelper.createTextArea();/*w w w . j a v a 2 s . c om*/ descTA.setLineWrap(true); descTA.setWrapStyleWord(true); txtFGColor = nameTF.getForeground(); txtBGColor = nameTF.getBackground(); if (isEdit) { ViewFactory.changeTextFieldUIForDisplay(nameTF, true); } descTA.setRows(5); model = new WebLinkArgsTableModel(); table = new JTable(model); table.setDefaultRenderer(String.class, new BiColorTableCellRenderer(true)); CellConstraints cc = new CellConstraints(); PanelBuilder rightPB = new PanelBuilder(new FormLayout("p,2px,f:p:g", //$NON-NLS-1$ "p,2px,p, 4px,p,2px,200px" + (tableInfo != null ? ",2px,200px" : ""))); //$NON-NLS-1$ rightPB.add(createI18NFormLabel("WebLinkArgDlg.NAME"), cc.xy(1, 1)); //$NON-NLS-1$ //$NON-NLS-2$ rightPB.add(nameTF, cc.xy(3, 1)); rightPB.add(createI18NFormLabel("WebLinkArgDlg.URL"), cc.xy(1, 3)); //$NON-NLS-1$ //$NON-NLS-2$ rightPB.add(baseUrlTF, cc.xy(3, 3)); rightPB.add(createI18NFormLabel("WebLinkArgDlg.DESC"), cc.xy(1, 5)); //$NON-NLS-1$ //$NON-NLS-2$ rightPB.add(UIHelper.createScrollPane(descTA), cc.xy(3, 5)); rightPB.add(createI18NFormLabel("WebLinkArgDlg.FIELDS"), cc.xy(1, 7)); //$NON-NLS-1$ //$NON-NLS-2$ rightPB.add(UIHelper.createScrollPane(table), cc.xy(3, 7)); if (tableInfo != null) { rightPB.add(UIHelper.createScrollPane(availableFields), cc.xy(3, 9)); } rightPB.setDefaultDialogBorder(); TableColumn promptCol = table.getColumnModel().getColumn(2); promptCol.setCellEditor(new DefaultCellEditor(new JCheckBox())); //promptCol.setCellRenderer(cellRenderer) UIHelper.makeTableHeadersCentered(table, false); contentPanel = rightPB.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); pack(); setDataIntoUI(); DocumentListener docLis = new DocumentListener() { protected void changed() { hasChanged = true; parseForFields(); enableUI(); } public void changedUpdate(DocumentEvent e) { changed(); } public void insertUpdate(DocumentEvent e) { changed(); } public void removeUpdate(DocumentEvent e) { changed(); } }; nameTF.getDocument().addDocumentListener(docLis); baseUrlTF.getDocument().addDocumentListener(docLis); adjustAvailableJList(); enableUI(); pack(); }
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjFieldFormatSinglePanel.java
/** * /*w w w. ja v a2 s . co m*/ */ public void addFormatTextListeners() { formatEditor.getDocument().addDocumentListener(new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { if (!ignoreFmtChange) { formatChanged(); } } }); sepText.getDocument().addDocumentListener(new DocumentListener() { public void removeUpdate(DocumentEvent e) { changed(e); } public void insertUpdate(DocumentEvent e) { changed(e); } public void changedUpdate(DocumentEvent e) { changed(e); } private void changed(@SuppressWarnings("unused") DocumentEvent e) { if (AppPreferences.hasRemotePrefs()) { AppPreferences.getRemote().put("DOF_SEP", sepText.getText()); } } }); }