use of java.awt.event.FocusListener in project com.revolsys.open by revolsys.
the class MouseOverlay method focusLost.
@Override
public void focusLost(final FocusEvent e) {
if (!e.isTemporary()) {
final Component component = e.getComponent();
if (component != this) {
final Component oppositeComponent = e.getOppositeComponent();
if (oppositeComponent != SwingUtilities.getWindowAncestor(this)) {
for (final Component overlay : getOverlays()) {
if (overlay instanceof FocusListener) {
final FocusListener listener = (FocusListener) overlay;
listener.focusLost(e);
}
}
}
}
}
}
use of java.awt.event.FocusListener in project deltahex-java by exbin.
the class CodeArea method registerControlListeners.
private void registerControlListeners() {
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(@Nonnull ComponentEvent event) {
resetPainter();
}
});
addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(@Nonnull KeyEvent keyEvent) {
commandHandler.keyTyped(keyEvent);
}
@Override
public void keyPressed(@Nonnull KeyEvent keyEvent) {
commandHandler.keyPressed(keyEvent);
}
});
addFocusListener(new FocusListener() {
@Override
public void focusGained(@Nonnull FocusEvent e) {
repaint();
}
@Override
public void focusLost(@Nonnull FocusEvent e) {
repaint();
}
});
UIManager.addPropertyChangeListener((@Nonnull PropertyChangeEvent evt) -> {
worker.rebuildColors();
});
}
use of java.awt.event.FocusListener in project bytecode-viewer by Konloch.
the class ResourceListPane method attachQuickSearchListeners.
public void attachQuickSearchListeners() {
quickSearch.addKeyListener(search);
quickSearch.addFocusListener(new FocusListener() {
@Override
public void focusGained(final FocusEvent arg0) {
if (quickSearch.getText().equals(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.toString())) {
quickSearch.setText("");
quickSearch.setForeground(Color.black);
}
}
@Override
public void focusLost(final FocusEvent arg0) {
if (quickSearch.getText().isEmpty()) {
quickSearch.setText(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.toString());
quickSearch.setForeground(Color.gray);
}
}
});
}
use of java.awt.event.FocusListener in project vcell by virtualcell.
the class ScrollTable method initialize.
private void initialize() {
autoResizeMode = AUTO_RESIZE_OFF;
// make it bigger on Mac
setRowHeight(getRowHeight() + 4);
putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
putClientProperty("JTable.autoStartsEdit", Boolean.FALSE);
scrollTableActionManager = new DefaultScrollTableActionManager(this);
enclosingScrollPane = new JScrollPane(this);
enclosingScrollPane.getViewport().setBackground(Color.WHITE);
contentPanel = new JPanel(new BorderLayout());
contentPanel.add(enclosingScrollPane, BorderLayout.CENTER);
setPreferredScrollableViewportSize(new Dimension(200, 100));
setIntercellSpacing(new Dimension(2, 2));
defaultTableCellRenderer = new DefaultScrollTableCellRenderer();
setDefaultRenderer(Object.class, defaultTableCellRenderer);
setDefaultRenderer(Number.class, defaultTableCellRenderer);
setDefaultRenderer(Double.class, defaultTableCellRenderer);
setDefaultRenderer(Boolean.class, new ScrollTableBooleanCellRenderer());
setDefaultEditor(Boolean.class, new ScrollTableBooleanEditor());
final TableCellRenderer defaultTableCellHeaderRenderer = getTableHeader().getDefaultRenderer();
TableCellRenderer defaultTableHeaderRenderer = new TableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component component = defaultTableCellHeaderRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (component instanceof JLabel) {
JLabel label = (JLabel) component;
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setBackground(tableHeaderColor);
label.setBorder(BorderFactory.createCompoundBorder(tableCellHeaderBorder, new EmptyBorder(1, 0, 1, 0)));
}
return component;
}
};
getTableHeader().setDefaultRenderer(defaultTableHeaderRenderer);
MouseAdapter mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
if (!javaVersion.startsWith("1.5")) {
if (!hasFocus()) {
if (e.getButton() == MouseEvent.BUTTON1) {
addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
}
public void focusGained(FocusEvent e) {
removeFocusListener(this);
Robot robot;
try {
robot = new Robot();
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
} catch (AWTException ex) {
ex.printStackTrace();
}
}
});
}
requestFocusInWindow();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
scrollTableActionManager.triggerPopup(e);
}
@Override
public void mouseReleased(MouseEvent e) {
scrollTableActionManager.triggerPopup(e);
}
@Override
public void mouseEntered(MouseEvent e) {
hoverRow = rowAtPoint(e.getPoint());
hoverColumn = columnAtPoint(e.getPoint());
repaint();
}
@Override
public void mouseExited(MouseEvent e) {
hoverRow = -1;
hoverColumn = -1;
repaint();
}
};
MouseMotionAdapter mouseMotionListener = new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
hoverRow = rowAtPoint(e.getPoint());
hoverColumn = columnAtPoint(e.getPoint());
repaint();
}
};
addMouseListener(mouseListener);
addMouseMotionListener(mouseMotionListener);
}
use of java.awt.event.FocusListener in project triplea by triplea-game.
the class CollectionProperty method getEditorComponent.
@Override
public JComponent getEditorComponent() {
if (m_values == null) {
return new JTable();
}
final Object[][] tableD = new Object[m_values.size()][1];
for (int i = 0; i < m_values.size(); i++) {
tableD[i][0] = m_values.get(i);
}
final JTable table = new JTable(tableD, new Object[] { "Values: " });
table.addFocusListener(new FocusListener() {
@Override
public void focusGained(final FocusEvent e) {
}
@Override
public void focusLost(final FocusEvent e) {
// TODO: change m_values
}
});
return table;
}
Aggregations