mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Fixed loss of focus with ctrl + f
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@5544 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
@ -30,7 +30,6 @@ import org.jivesoftware.sparkimpl.profile.VCardManager;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
@ -57,6 +56,7 @@ import java.util.Set;
|
||||
* Manager. You would use the UserManager to get visitors in a chat room or secondary agents.
|
||||
*/
|
||||
public class UserManager {
|
||||
private JWindow window;
|
||||
|
||||
public UserManager() {
|
||||
}
|
||||
@ -406,30 +406,33 @@ public class UserManager {
|
||||
|
||||
}
|
||||
}
|
||||
if (window != null) {
|
||||
window.dispose();
|
||||
}
|
||||
|
||||
final JWindow frame = new JWindow(parent);
|
||||
final JContactItemField contactField = new JContactItemField(new ArrayList(contacts), frame);
|
||||
window = new JWindow(parent);
|
||||
final JContactItemField contactField = new JContactItemField(new ArrayList(contacts));
|
||||
|
||||
|
||||
JPanel layoutPanel = new JPanel();
|
||||
layoutPanel.setLayout(new GridBagLayout());
|
||||
frame.getContentPane().setLayout(new BorderLayout());
|
||||
window.setLayout(new BorderLayout());
|
||||
JLabel enterLabel = new JLabel(Res.getString("label.contact.to.find"));
|
||||
enterLabel.setFont(new Font("dialog", Font.BOLD, 10));
|
||||
layoutPanel.add(enterLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));
|
||||
layoutPanel.add(contactField, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 200, 0));
|
||||
layoutPanel.setBorder(BorderFactory.createBevelBorder(0));
|
||||
frame.getContentPane().add(layoutPanel);
|
||||
window.add(layoutPanel);
|
||||
|
||||
frame.pack();
|
||||
window.pack();
|
||||
|
||||
frame.setLocationRelativeTo(parent);
|
||||
frame.setVisible(true);
|
||||
window.setLocationRelativeTo(parent);
|
||||
window.setVisible(true);
|
||||
|
||||
frame.addKeyListener(new KeyAdapter() {
|
||||
window.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent keyEvent) {
|
||||
if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) {
|
||||
frame.dispose();
|
||||
window.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -441,13 +444,13 @@ public class UserManager {
|
||||
ContactItem item = (ContactItem)contactMap.get(contactField.getText());
|
||||
if (item != null) {
|
||||
SparkManager.getChatManager().activateChat(item.getFullJID(), item.getNickname());
|
||||
frame.dispose();
|
||||
window.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) {
|
||||
frame.dispose();
|
||||
window.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -24,7 +24,6 @@ import javax.swing.ListCellRenderer;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
@ -42,10 +41,9 @@ public class JContactItemField extends JPanel {
|
||||
private JList list = new JList(model);
|
||||
private JWindow popup;
|
||||
private List<ContactItem> items;
|
||||
private JWindow parentWindow;
|
||||
|
||||
private Window parentWindow;
|
||||
|
||||
public JContactItemField(List items, Window parentWindow) {
|
||||
public JContactItemField(List items) {
|
||||
setLayout(new BorderLayout());
|
||||
this.items = items;
|
||||
|
||||
@ -83,21 +81,14 @@ public class JContactItemField extends JPanel {
|
||||
});
|
||||
|
||||
|
||||
list.addKeyListener(new KeyAdapter() {
|
||||
public void keyReleased(KeyEvent keyEvent) {
|
||||
if (keyEvent.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
textField.requestFocus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
popup = new JWindow(parentWindow);
|
||||
popup = new JWindow();
|
||||
|
||||
|
||||
popup.getContentPane().add(new JScrollPane(list));
|
||||
popup.setAlwaysOnTop(true);
|
||||
|
||||
list.setCellRenderer(new PopupRenderer());
|
||||
|
||||
}
|
||||
|
||||
public void setItems(List list) {
|
||||
@ -133,6 +124,7 @@ public class JContactItemField extends JPanel {
|
||||
popup.toFront();
|
||||
popup.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user