Hi,
I am a novice in Swing so I need help from you... I have a situation here :
In one JFrame I have multiple JPanels.
In each JPanel I have 1 JLabel , 1 JTextfield & 1 JButton .
Now clicking on the JButton a small JFrame opens up where the user can search for a particular user.
Now if he wants to select the user , he has to select the JRadioButton against it.
Now I want here is that when he clicks the Add button then that small JFrame should be closed and the selected User ID should be populated in the respective JtextField of the JPanel.
Can anyone help me in this situation.
Note I am able to close the small JFrame by invoking JFrame.dispose(); but how should I populate the JTextField.
The whole concept highlights about selecting a User from a Popup and adding it to the Parent JTextField.
How about using JOptionPane? The "message" parameter can be anything, including entire JPanels with contents.
However, maybe a single selection JList (inside a JScrollPane) is a better option for selecting the user.
Hi Rob Sir,
But in my small JFrame (It is a Popup )
I have 3 JTextFields(User ID , First Name & Last Name) as Search Parameter and a Search JButton.
Now after providing any of the 3 values when I click on the Search Button.
I am populating a JTable with 3 columns a) User ID (JRadioButton), b) User Name & c) Email Address.
And two Jbutton "ADD"(which will add the User in the Main JFrame TextField) & "Exit" which will only close the Popup.
Rob Prime wrote:The message, searchView in this case, cannot be a JFrame or JDialog.
Yes actually the I was adding a JFrame but now I have chaged it to a JPanel within that there is my Main Panel which holds all the Components but the Problem is that it is not showing
Are you trying to show the content of an existing frame? You should create a new JPanel that isn't shown anywhere else yet; the JOptionPane will create a JDialog that will house the JPanel.