tags:

views:

209

answers:

1

Hi,I want to add component into JTextField as a popup like this.

alt text

i want to add my component for example JPanel...

+4  A: 

You could use a JPopupMenu -- launched via your button and placed relative to your text field:

final JTextField textField = ...
JButton button = ...
button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        JPopupMenu popup = new JPopupMenu();
        popup.setLayout(new BorderLayout());
        popup.add(new JPanel()); // your component
        popup.setPopupSize(100, 100);
        popup.show(textField, 0, textField.getHeight());
    }
});
netzwerg