use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class MavenEnvironmentForm method createComponent.
public JComponent createComponent() {
// all listeners will be removed when dialog is closed
mavenHomeComponent.getComponent().addBrowseFolderListener(ProjectBundle.message("maven.select.maven.home.directory"), "", null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);
mavenHomeField.addDocumentListener(new DocumentAdapter() {
protected void textChanged(DocumentEvent e) {
updateMavenVersionLabel();
}
});
settingsFileComponent.getComponent().addBrowseFolderListener(ProjectBundle.message("maven.select.maven.settings.file"), "", null, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
localRepositoryComponent.getComponent().addBrowseFolderListener(ProjectBundle.message("maven.select.local.repository"), "", null, FileChooserDescriptorFactory.createSingleFolderDescriptor());
return panel;
}
use of javax.swing.event.DocumentEvent in project zaproxy by zaproxy.
the class DialogAddUser method getNameTextField.
protected ZapTextField getNameTextField() {
if (nameTextField == null) {
nameTextField = new ZapTextField(25);
nameTextField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
checkValidAndEnableConfirmButton();
}
@Override
public void insertUpdate(DocumentEvent e) {
checkValidAndEnableConfirmButton();
}
@Override
public void changedUpdate(DocumentEvent e) {
checkValidAndEnableConfirmButton();
}
});
}
return nameTextField;
}
use of javax.swing.event.DocumentEvent in project zaproxy by zaproxy.
the class OptionsLangPanel method getFileTextField.
private ZapTextField getFileTextField() {
if (fileTextField == null) {
fileTextField = new ZapTextField();
fileTextFieldDoc = fileTextField.getDocument();
fileTextFieldDoc.addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent e) {
updated(e);
}
@Override
public void insertUpdate(DocumentEvent e) {
updated(e);
}
@Override
public void removeUpdate(DocumentEvent e) {
updated(e);
}
private void updated(DocumentEvent e) {
try {
String inputString = e.getDocument().getText(0, e.getDocument().getLength());
importButton.setEnabled(inputString.endsWith(".zaplang"));
} catch (BadLocationException e1) {
//logger.error(e1.getMessage());
}
}
});
}
return fileTextField;
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class ArrayRendererConfigurable method createComponent.
public JComponent createComponent() {
myPanel = new JPanel(new GridBagLayout());
myStartIndex = new JTextField(5);
myEndIndex = new JTextField(5);
myEntriesLimit = new JTextField(5);
final FontMetrics fontMetrics = myStartIndex.getFontMetrics(myStartIndex.getFont());
final Dimension minSize = new Dimension(myStartIndex.getPreferredSize());
//noinspection HardCodedStringLiteral
minSize.width = fontMetrics.stringWidth("AAAAA");
myStartIndex.setMinimumSize(minSize);
myEndIndex.setMinimumSize(minSize);
myEntriesLimit.setMinimumSize(minSize);
JLabel startIndexLabel = new JLabel(DebuggerBundle.message("label.array.renderer.configurable.start.index"));
startIndexLabel.setLabelFor(myStartIndex);
JLabel endIndexLabel = new JLabel(DebuggerBundle.message("label.array.renderer.configurable.end.index"));
endIndexLabel.setLabelFor(myEndIndex);
JLabel entriesLimitLabel = new JLabel(DebuggerBundle.message("label.array.renderer.configurable.max.count1"));
entriesLimitLabel.setLabelFor(myEntriesLimit);
myPanel.add(startIndexLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insetsRight(8), 0, 0));
myPanel.add(myStartIndex, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insetsRight(8), 0, 0));
myPanel.add(endIndexLabel, new GridBagConstraints(2, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insetsRight(8), 0, 0));
myPanel.add(myEndIndex, new GridBagConstraints(3, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
myPanel.add(entriesLimitLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(4, 0, 0, 8), 0, 0));
myPanel.add(myEntriesLimit, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(4, 0, 0, 8), 0, 0));
myPanel.add(new JLabel(DebuggerBundle.message("label.array.renderer.configurable.max.count2")), new GridBagConstraints(2, GridBagConstraints.RELATIVE, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insetsTop(4), 0, 0));
// push other components up
myPanel.add(new JLabel(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
final DocumentListener listener = new DocumentListener() {
private void updateEntriesLimit() {
final boolean state = myIndexUpdateEnabled;
myIndexUpdateEnabled = false;
try {
if (myEntriesLimitUpdateEnabled) {
myEntriesLimit.setText(String.valueOf(getInt(myEndIndex) - getInt(myStartIndex) + 1));
}
} finally {
myIndexUpdateEnabled = state;
}
}
public void changedUpdate(DocumentEvent e) {
updateEntriesLimit();
}
public void insertUpdate(DocumentEvent e) {
updateEntriesLimit();
}
public void removeUpdate(DocumentEvent e) {
updateEntriesLimit();
}
};
myStartIndex.getDocument().addDocumentListener(listener);
myEndIndex.getDocument().addDocumentListener(listener);
myEntriesLimit.getDocument().addDocumentListener(new DocumentListener() {
private void updateEndIndex() {
final boolean state = myEntriesLimitUpdateEnabled;
myEntriesLimitUpdateEnabled = false;
try {
if (myIndexUpdateEnabled) {
myEndIndex.setText(String.valueOf(getInt(myEntriesLimit) + getInt(myStartIndex) - 1));
}
} finally {
myEntriesLimitUpdateEnabled = state;
}
}
public void insertUpdate(DocumentEvent e) {
updateEndIndex();
}
public void removeUpdate(DocumentEvent e) {
updateEndIndex();
}
public void changedUpdate(DocumentEvent e) {
updateEndIndex();
}
});
return myPanel;
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class SetBackgroundImageDialog method setupComponents.
private void setupComponents() {
myAdjusting = true;
myPreviewPanel.setLayout(new CardLayout());
myPreviewPanel.add(myEditorPreview.getPanel(), "editor");
myPreviewPanel.add(myIdePreview, "ide");
((CardLayout) myPreviewPanel.getLayout()).show(myPreviewPanel, "editor");
myPathField.getComboBox().setEditable(true);
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, true, false).withFileFilter(file -> ImageFileTypeManager.getInstance().isImage(file));
myPathField.addBrowseFolderListener(null, null, null, descriptor, TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
JTextComponent textComponent = getComboEditor();
textComponent.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
if (myAdjusting)
return;
imagePathChanged();
}
});
for (Enumeration<AbstractButton> e = getTargetRbGroup().getElements(); e.hasMoreElements(); ) {
AbstractButton button = e.nextElement();
button.setActionCommand(button.getText());
button.addItemListener(this::targetChanged);
}
for (Enumeration<AbstractButton> e = getFillRbGroup().getElements(); e.hasMoreElements(); ) {
AbstractButton button = e.nextElement();
button.setActionCommand(button.getText());
button.addItemListener(this::fillOrPlaceChanged);
}
for (Enumeration<AbstractButton> e = getPlaceRbGroup().getElements(); e.hasMoreElements(); ) {
AbstractButton button = e.nextElement();
button.setActionCommand(button.getText());
button.addItemListener(this::fillOrPlaceChanged);
}
ChangeListener opacitySync = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (myAdjusting)
return;
myAdjusting = true;
boolean b = e.getSource() == myOpacitySpinner;
if (b) {
int value = (Integer) myOpacitySpinner.getValue();
myOpacitySpinner.setValue(Math.min(Math.max(0, value), 100));
myOpacitySlider.setValue(value);
} else {
myOpacitySpinner.setValue(myOpacitySlider.getValue());
}
myAdjusting = false;
opacityChanged();
}
};
myOpacitySpinner.addChangeListener(opacitySync);
myOpacitySlider.addChangeListener(opacitySync);
myOpacitySlider.setValue(15);
myOpacitySpinner.setValue(15);
myScaleRb.setSelected(true);
myCenterRb.setSelected(true);
myEditorRb.setSelected(true);
boolean perProject = !Comparing.equal(getBackgroundSpec(myProject, getSystemProp(true)), getBackgroundSpec(null, getSystemProp(true)));
myThisProjectOnlyCb.setSelected(perProject);
myAdjusting = false;
}
Aggregations