Methods Summary |
---|
public void | actionPerformed(java.awt.event.ActionEvent evt)
// build popup window
popup = new JWindow(getFrame(null));
popup.getContentPane().add(drop_down_comp);
popup.addWindowFocusListener(new WindowAdapter() {
public void windowLostFocus(WindowEvent evt) {
popup.setVisible(false);
}
});
popup.pack();
// show the popup window
Point pt = visible_comp.getLocationOnScreen();
System.out.println("pt = " + pt);
pt.translate(visible_comp.getWidth()-popup.getWidth(),visible_comp.getHeight());
System.out.println("pt = " + pt);
popup.setLocation(pt);
popup.toFront();
popup.setVisible(true);
popup.requestFocusInWindow();
|
public void | ancestorAdded(javax.swing.event.AncestorEvent event)
hidePopup();
|
public void | ancestorMoved(javax.swing.event.AncestorEvent event)
if (event.getSource() != popup) {
hidePopup();
}
|
public void | ancestorRemoved(javax.swing.event.AncestorEvent event)
hidePopup();
|
protected java.awt.Frame | getFrame(java.awt.Component comp)
if(comp == null) {
comp = this;
}
if(comp.getParent() instanceof Frame) {
return (Frame)comp.getParent();
}
return getFrame(comp.getParent());
|
public void | hidePopup()
if(popup != null && popup.isVisible()) {
popup.setVisible(false);
}
|
protected void | setupLayout()
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout(gbl);
c.weightx = 1.0; c.weighty = 1.0;
c.gridx = 0; c.gridy = 0;
c.fill = c.BOTH;
gbl.setConstraints(visible_comp,c);
add(visible_comp);
c.weightx = 0;
c.gridx++;
gbl.setConstraints(arrow,c);
add(arrow);
|