List of usage examples for javax.swing.event DocumentListener DocumentListener
DocumentListener
From source file:com.mirth.connect.client.ui.editors.RuleBuilderPanel.java
/** Creates new form MapperPanel */ public RuleBuilderPanel(MirthEditorPane p, final RuleBuilderPlugin rulePlugin) { parent = p;//from w w w. jav a2 s .c om this.rulePlugin = rulePlugin; initComponents(); fieldTextField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent arg0) { if (documentListenerEnabled) { parent.modified = true; rulePlugin.updateName(); } } public void insertUpdate(DocumentEvent arg0) { if (documentListenerEnabled) { parent.modified = true; rulePlugin.updateName(); } } public void removeUpdate(DocumentEvent arg0) { if (documentListenerEnabled) { parent.modified = true; rulePlugin.updateName(); } } }); doesNotEqual.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { parent.modified = true; rulePlugin.updateName(); } }); doesNotExist.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { parent.modified = true; rulePlugin.updateName(); } }); equals.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { parent.modified = true; rulePlugin.updateName(); } }); exists.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { parent.modified = true; rulePlugin.updateName(); } }); contains.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { parent.modified = true; rulePlugin.updateName(); } }); doesNotContain.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { parent.modified = true; rulePlugin.updateName(); } }); valuesScrollPane.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { deselectRows(); } }); deleteButton.setEnabled(false); }
From source file:Main.java
public TestPane() { setLayout(new BorderLayout()); JPanel searchPane = new JPanel(); searchPane.add(new JLabel("Find: ")); searchPane.add(findText);//from w w w . ja v a2s .com add(searchPane, BorderLayout.NORTH); add(new JScrollPane(ta)); try (BufferedReader reader = new BufferedReader(new FileReader(new File("c:/Java_Dev/run.bat")))) { ta.read(reader, "Text"); } catch (Exception e) { e.printStackTrace(); } ta.setCaretPosition(0); keyTimer = new Timer(250, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String find = findText.getText(); Document document = ta.getDocument(); try { for (int index = 0; index + find.length() < document.getLength(); index++) { String match = document.getText(index, find.length()); if (find.equals(match)) { DefaultHighlighter.DefaultHighlightPainter highlightPainter = new DefaultHighlighter.DefaultHighlightPainter( Color.YELLOW); ta.getHighlighter().addHighlight(index, index + find.length(), highlightPainter); } } } catch (BadLocationException exp) { exp.printStackTrace(); } } }); keyTimer.setRepeats(false); findText.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { keyTimer.restart(); } @Override public void removeUpdate(DocumentEvent e) { keyTimer.restart(); } @Override public void changedUpdate(DocumentEvent e) { keyTimer.restart(); } }); }
From source file:Commander.Main.java
/** * Creates new form Main// w w w. j ava 2 s .com */ public Main(java.awt.Frame parent, boolean modal) { super(parent, modal); //Set tranparant Color transparant = new Color(0, 0, 0, 0); setUndecorated(true); getRootPane().setOpaque(false); getContentPane().setBackground(transparant); setBackground(transparant); initComponents(); //Set components transparant transparant = new Color(0, 0, 0, 1); txtCommand.setBackground(transparant); txtCommand.setForeground(Color.GREEN); txtCommand.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0, 150))); jScrollPane1.getViewport().setBackground(transparant); jScrollPane1.getViewport().setOpaque(false); txtError.setBackground(transparant); txtError.setForeground(Color.RED); txtError.setEditable(false); txtError.setFocusable(false); jScrollPane1.setVisible(false); setAlwaysOnTop(true); pack(); Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); int width = getPreferredSize().width; int height = getPreferredSize().height; setLocation(screen.width - width - 20, screen.height - height - 20); txtCommand.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { if (jScrollPane1.isVisible()) { jScrollPane1.setVisible(false); } } @Override public void removeUpdate(DocumentEvent e) { if (jScrollPane1.isVisible()) { jScrollPane1.setVisible(false); } } @Override public void changedUpdate(DocumentEvent e) { //Not supported } }); String home = System.getProperty("user.home"); defaultLocations[0] = home + "/Documents"; defaultLocations[1] = home + "/Pictures"; defaultLocations[2] = home + "/Downloads"; defaultLocations[3] = home + "/Music"; // run("Casino.jar", new ArrayList<>()); }
From source file:com.mirth.connect.client.ui.editors.MapperPanel.java
/** Creates new form MapperPanel */ public MapperPanel(MirthEditorPane p) { parent = p;/*from w ww . ja v a 2 s. co m*/ initComponents(); variableTypes = new LinkedHashMap<String, String>(); variableTypes.put("connector", "Connector Map"); variableTypes.put("channel", "Channel Map"); variableTypes.put("globalChannel", "Global Channel Map"); variableTypes.put("global", "Global Map"); variableTypes.put("response", "Response Map"); addTo.setModel(new DefaultComboBoxModel(variableTypes.values().toArray())); variableTextField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent arg0) { } public void insertUpdate(DocumentEvent arg0) { if (documentListenerEnabled) { updateTable(); parent.modified = true; } } public void removeUpdate(DocumentEvent arg0) { if (documentListenerEnabled) { updateTable(); parent.modified = true; } } }); mappingTextField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent arg0) { } public void insertUpdate(DocumentEvent arg0) { parent.modified = true; } public void removeUpdate(DocumentEvent arg0) { parent.modified = true; } }); defaultValueTextField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent arg0) { } public void insertUpdate(DocumentEvent arg0) { parent.modified = true; } public void removeUpdate(DocumentEvent arg0) { parent.modified = true; } }); regularExpressionsScrollPane.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { deselectRows(); } }); deleteButton.setEnabled(false); }
From source file:com.ansorgit.plugins.bash.editor.inspections.inspections.FixShebangInspection.java
@Override public JComponent createOptionsPanel() { FixShebangSettings settings = new FixShebangSettings(); JTextArea textArea = settings.getValidCommandsTextArea(); textArea.setText(Joiner.on('\n').join(validShebangCommands)); textArea.getDocument().addDocumentListener(new DocumentListener() { @Override/*from w ww .jav a 2s .com*/ public void insertUpdate(DocumentEvent documentEvent) { updateShebangLines(documentEvent); } @Override public void removeUpdate(DocumentEvent documentEvent) { updateShebangLines(documentEvent); } @Override public void changedUpdate(DocumentEvent documentEvent) { updateShebangLines(documentEvent); } }); return settings.getSettingsPanel(); }
From source file:com.opendoorlogistics.speedregions.excelshp.app.FileBrowserPanel.java
public static JTextField createTextField(String initialValue, final Consumer<String> filenameChangeListener) { final JTextField textField = new JTextField(); if (initialValue != null) { textField.setText(initialValue); }/*w w w . ja v a2 s .co m*/ if (filenameChangeListener != null) { textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { fire(); } @Override public void insertUpdate(DocumentEvent e) { fire(); } @Override public void changedUpdate(DocumentEvent e) { fire(); } private void fire() { filenameChangeListener.accept(textField.getText()); } }); } return textField; }
From source file:de.codesourcery.eve.skills.ui.components.impl.ByLabelFilterComponent.java
@Override protected JPanel createPanel() { final JPanel result = new JPanel(); result.setLayout(new GridBagLayout()); result.setBorder(BorderFactory.createTitledBorder(title)); // textfield/* ww w . ja va 2s. com*/ this.nameField.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { labelProvider.viewFilterChanged(getViewFilter()); } @Override public void insertUpdate(DocumentEvent e) { labelProvider.viewFilterChanged(getViewFilter()); } @Override public void removeUpdate(DocumentEvent e) { labelProvider.viewFilterChanged(getViewFilter()); } }); nameField.setColumns(20); result.add(nameField, constraints(0, 0).resizeHorizontally().useRelativeWidth().end()); // button clearButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { nameField.setText(""); } }); result.add(clearButton, constraints(1, 0).noResizing().useRemainingWidth().end()); return result; }
From source file:com.mirth.connect.client.ui.TemplatePanel.java
public TemplatePanel(MirthEditorPane m) { this.parent = m; initComponents();/*from w w w. ja va2s .c om*/ openFileButton.setIcon(UIConstants.ICON_FILE_PICKER); if (PlatformUI.MIRTH_FRAME != null) { dataTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel( PlatformUI.MIRTH_FRAME.dataTypeToDisplayName.values().toArray())); } hl7Document = new SyntaxDocument(); hl7Document.setTokenMarker(new HL7TokenMarker()); pasteBox.setDocument(hl7Document); // handles updating the tree pasteBox.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { updateText(); } public void insertUpdate(DocumentEvent e) { updateText(); } public void removeUpdate(DocumentEvent e) { updateText(); } }); pasteBox.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON2) { if (pasteBox.getText().equals(DEFAULT_TEXT)) { pasteBox.setText(""); } } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON2) { if (pasteBox.getText().length() == 0) { pasteBox.setText(DEFAULT_TEXT); } } } }); new DropTarget(pasteBox, this); }
From source file:au.org.ala.delta.editor.ui.DirectiveFileEditor.java
private void addEventHandlers() { javax.swing.Action applyChanges = _actions.get("applyChanges"); directivesEditor.addToolbarButton(applyChanges, "saveDirectiveFile"); directivesEditor.getTextArea().getDocument().addDocumentListener(new DocumentListener() { @Override/*from w ww. j a v a2 s . c o m*/ public void removeUpdate(DocumentEvent e) { enableSave(); } @Override public void insertUpdate(DocumentEvent e) { enableSave(); } @Override public void changedUpdate(DocumentEvent e) { enableSave(); } }); }
From source file:de.codesourcery.eve.skills.ui.utils.LabelViewFilterPanel.java
public LabelViewFilterPanel(String label, int columns) { super();// www . java2 s. c om clearButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textField.setText(null); } }); textField.setColumns(columns); textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { searchFieldChanged(LabelViewFilterPanel.this, textField.getText()); } @Override public void insertUpdate(DocumentEvent e) { searchFieldChanged(LabelViewFilterPanel.this, textField.getText()); } @Override public void removeUpdate(DocumentEvent e) { searchFieldChanged(LabelViewFilterPanel.this, textField.getText()); } }); setLayout(new GridBagLayout()); new GridLayoutBuilder() .add(new GridLayoutBuilder.HorizontalGroup(new GridLayoutBuilder.FixedCell(new JLabel(label)), new GridLayoutBuilder.FixedCell(textField), new GridLayoutBuilder.FixedCell(clearButton))) .addTo(this); }