use of javax.swing.text.JTextComponent in project screenbird by adamhub.
the class RecorderPanel method showUploadMessage.
/*
* Upload methods
*/
/**
* Displays a message on the upload form, formatted with a text color.
* @param message
* @param type
*/
public void showUploadMessage(String message, Color type) {
int start = 0;
int end = 0;
Component focusedComponent = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focusedComponent instanceof JTextComponent) {
end = ((JTextComponent) focusedComponent).getSelectionEnd();
start = ((JTextComponent) focusedComponent).getSelectionStart();
}
Dimension size = new Dimension(160, 14);
this.lblUploadMessage.setPreferredSize(size);
this.lblUploadMessage.setMinimumSize(size);
this.lblUploadMessage.setMaximumSize(size);
this.lblUploadMessage.setSize(size);
this.pbEncoding.setVisible(true);
this.pbEncoding.setForeground(type);
this.lblUploadMessage.validate();
this.lblUploadMessage.setText(message);
this.lblUploadMessage.setVisible(true);
this.lblUploadMessage.setForeground(type);
((JFrame) this.getParent().getParent().getParent().getParent()).pack();
this.redrawWindow();
if (focusedComponent instanceof JTextComponent) {
((JTextComponent) focusedComponent).grabFocus();
((JTextComponent) focusedComponent).setSelectionStart(start);
((JTextComponent) focusedComponent).setSelectionEnd(end);
}
}
use of javax.swing.text.JTextComponent in project SKMCLauncher by SKCraft.
the class TextFieldPopupMenu method show.
@Override
public void show(Component invoker, int x, int y) {
JTextComponent textComponent = (JTextComponent) invoker;
boolean editable = textComponent.isEditable() && textComponent.isEnabled();
cutItem.setVisible(editable);
pasteItem.setVisible(editable);
deleteItem.setVisible(editable);
super.show(invoker, x, y);
}
use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.
the class ConfigureProxiesOptionsPanel method setStringProperties.
public void setStringProperties(final Map<String, String> properties) {
for (Map.Entry<String, String> entry : properties.entrySet()) {
final JComponent component = myKey2Component.get(entry.getKey());
if (component != null) {
JTextComponent textComponent = null;
if (component instanceof JTextComponent) {
textComponent = (JTextComponent) component;
} else if (component instanceof TextFieldWithBrowseButton) {
textComponent = ((TextFieldWithBrowseButton) component).getTextField();
}
if (textComponent != null) {
textComponent.setText(entry.getValue());
textComponent.selectAll();
}
component.setToolTipText(entry.getKey());
}
}
myTrustDefaultCAsCheckBox.setSelected(booleanPropertySelected(properties.get(myComponent2Key.get(myTrustDefaultCAsCheckBox))));
repositoryUrlsRecalculation();
}
use of javax.swing.text.JTextComponent 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;
}
use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.
the class DeleteAction method update.
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
if (ActionPlaces.PROJECT_VIEW_POPUP.equals(e.getPlace()) || ActionPlaces.COMMANDER_POPUP.equals(e.getPlace())) {
presentation.setText(IdeBundle.message("action.delete.ellipsis"));
} else {
presentation.setText(IdeBundle.message("action.delete"));
}
if (e.getProject() == null) {
presentation.setEnabled(false);
return;
}
DataContext dataContext = e.getDataContext();
DeleteProvider provider = getDeleteProvider(dataContext);
if (e.getInputEvent() instanceof KeyEvent) {
KeyEvent keyEvent = (KeyEvent) e.getInputEvent();
Object component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
// Do not override text deletion
if (component instanceof JTextComponent)
provider = null;
if (keyEvent.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
// Do not override text deletion in speed search
if (component instanceof JComponent) {
SpeedSearchSupply searchSupply = SpeedSearchSupply.getSupply((JComponent) component);
if (searchSupply != null)
provider = null;
}
String activeSpeedSearchFilter = SpeedSearchSupply.SPEED_SEARCH_CURRENT_QUERY.getData(dataContext);
if (!StringUtil.isEmpty(activeSpeedSearchFilter)) {
provider = null;
}
}
}
if (provider instanceof TitledHandler) {
presentation.setText(((TitledHandler) provider).getActionTitle());
}
boolean canDelete = provider != null && provider.canDeleteElement(dataContext);
if (ActionPlaces.isPopupPlace(e.getPlace())) {
presentation.setVisible(canDelete);
} else {
presentation.setEnabled(canDelete);
}
}
Aggregations