use of java.awt.event.FocusListener in project Spark by igniterealtime.
the class SearchService method setActiveSearchService.
public void setActiveSearchService(final Searchable searchable) {
this.activeSearchable = searchable;
newSearch = true;
findField.requestFocus();
findField.getTextComponent().setForeground((Color) UIManager.get("TextField.lightforeground"));
findField.setIcon(searchable.getIcon());
findField.setText(searchable.getDefaultText());
findField.setToolTipText(searchable.getToolTip());
findField.getTextComponent().addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
findField.setText("");
}
public void focusLost(FocusEvent e) {
findField.getTextComponent().setForeground((Color) UIManager.get("TextField.lightforeground"));
findField.setText(searchable.getDefaultText());
}
});
}
use of java.awt.event.FocusListener in project freeplane by freeplane.
the class MMapController method startEditingAfterSelect.
private void startEditingAfterSelect(final NodeModel newNode) {
final Component component = Controller.getCurrentController().getMapViewManager().getComponent(newNode);
if (component == null)
return;
component.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
}
public void focusGained(FocusEvent e) {
e.getComponent().removeFocusListener(this);
final TextController textController = TextController.getController();
((MTextController) textController).edit(newNode, newNode.getParentNode(), true, false, false);
}
});
}
use of java.awt.event.FocusListener in project sirix by sirixdb.
the class TreeView method dispose.
@Override
public void dispose() {
mTree.clearSelection();
mTree.setModel(null);
mTree.setCellRenderer(null);
for (final FocusListener listener : mTree.getFocusListeners()) {
mTree.removeFocusListener(listener);
}
for (final ComponentListener listener : mTree.getComponentListeners()) {
mTree.removeComponentListener(listener);
}
for (final TreeSelectionListener listener : mTree.getTreeSelectionListeners()) {
mTree.removeTreeSelectionListener(listener);
}
for (final ContainerListener listener : mTree.getContainerListeners()) {
mTree.removeContainerListener(listener);
}
}
use of java.awt.event.FocusListener in project blue by kunstmusik.
the class Knob method createKnob.
private void createKnob(int preferredWidth) {
DRAG_SPEED = 0.01F;
CLICK_SPEED = 0.01F;
SHADOWX = 1;
SHADOWY = 1;
focusColor = DEFAULT_FOCUS_COLOR;
Dimension prefSize = new Dimension(preferredWidth, preferredWidth);
setPreferredSize(prefSize);
// Degrees ??? Radians???
hitArc.setAngleStart(235);
addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent me) {
dragpos = me.getX() + me.getY();
startVal = val;
// Fix last angle
int xpos = middle - me.getX();
int ypos = middle - me.getY();
lastAng = Math.atan2(xpos, ypos);
requestFocus();
}
@Override
public void mouseClicked(MouseEvent me) {
hitArc.setAngleExtent(-(LENGTH + 20));
if (hitArc.contains(me.getX(), me.getY())) {
hitArc.setAngleExtent(MULTIP * (ang - START_ANG) - 10);
if (hitArc.contains(me.getX(), me.getY())) {
decValue();
} else {
incValue();
}
}
}
});
// Let the user control the knob with the mouse
addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent me) {
if (dragType == SIMPLE) {
float f = DRAG_SPEED * ((me.getX() + me.getY()) - dragpos);
setValue(startVal + f);
} else if (dragType == ROUND) {
// Measure relative the middle of the button!
int xpos = middle - me.getX();
int ypos = middle - me.getY();
double ang = Math.atan2(xpos, ypos);
double diff = lastAng - ang;
setValue((float) (getValue() + (diff / LENGTH_ANG)));
lastAng = ang;
}
}
@Override
public void mouseMoved(MouseEvent me) {
}
});
// Let the user control the knob with the keyboard
addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
int k = e.getKeyCode();
if (k == KeyEvent.VK_RIGHT) {
incValue();
} else if (k == KeyEvent.VK_LEFT) {
decValue();
}
}
});
// Handle focus so that the knob gets the correct focus highlighting.
addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
repaint();
}
@Override
public void focusLost(FocusEvent e) {
repaint();
}
});
}
use of java.awt.event.FocusListener in project cytoscape-impl by cytoscape.
the class EnhancedSearchPanel method initComponents.
private void initComponents() {
final String defText = "Enter search term...";
final Font defFont = UIManager.getFont("TextField.font") != null ? UIManager.getFont("TextField.font").deriveFont(LookAndFeelUtil.getSmallFontSize()) : null;
tfSearchText = new JTextField();
tfSearchText.putClientProperty("JTextField.variant", "search");
tfSearchText.setToolTipText("<html>Example Search Queries:<br><br>YL* -- Search all columns<br>name:YL* -- Search 'name' column<br>GO\\:1232 -- Escape special characters with backslash</html>");
tfSearchText.setName("tfSearchText");
if (!isAquaLAF()) {
tfSearchText.setText(defText);
if (defFont != null)
tfSearchText.setFont(defFont);
}
tfSearchText.addActionListener(evt -> tfSearchTextActionPerformed(evt));
tfSearchText.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
if (tfSearchText.getText().equals(defText)) {
tfSearchText.setText("");
tfSearchText.setFont(UIManager.getFont("TextField.font"));
}
}
@Override
public void focusLost(FocusEvent e) {
if (!isAquaLAF() && tfSearchText.getText().trim().isEmpty()) {
tfSearchText.setText(defText);
if (defFont != null)
tfSearchText.setFont(defFont);
}
}
});
setKeyBindings(tfSearchText);
final GroupLayout layout = new GroupLayout(this);
setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createSequentialGroup().addGap(10, 20, Short.MAX_VALUE).addComponent(tfSearchText, 120, 240, 300));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(tfSearchText, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE));
}
Aggregations