File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot take populate JTextfield

 
Rohit Kedia
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rohit Kedia
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

So it this Possible in the JOptionPane ???
 
Rob Camick
Ranch Hand
Posts: 2476
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can show any Swing compnent using the showInputDialog(...) method. So yes you can add a JPanel containing the components you describe.
 
Rohit Kedia
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




any help
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The message, searchView in this case, cannot be a JFrame or JDialog.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"...adding a window to a container"

so, what is 'searchView'
 
Rohit Kedia
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
That issue is resolved but the now the Whole Panel is not displaying all the Components in the JOptionPane
 
Rohit Kedia
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic