hi all, i want to include an icon inside a JTextField(at the extreme right)and when that icon is clicked a dialog box should appear.Can anyone suggest an approach for doing this?? thanks in advance. arun
Originally posted by Arun Thulaseedharan: hi all, i want to include an icon inside a JTextField(at the extreme right)and when that icon is clicked a dialog box should appear.Can anyone suggest an approach for doing this?? thanks in advance. arun
1) Override the JTextField#paintComponent to paint the Icon at your desired location. 2) Add a MouseListener to your JTextField. 3) On receiving mouse clicks, find out if the click happened on your icon. 4) If yes, process it accordingly.
create a component: JPanel(BoxLayout) with JTextField and JLabel(icon). modify borders so it looks like a single component. add mouseListener to the label (to do whatever you want).