• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Cannot take populate JTextfield

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ???
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




any help
 
Rob Spoor
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The message, searchView in this case, cannot be a JFrame or JDialog.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"...adding a window to a container"

so, what is 'searchView'
 
Rohit Kedia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You can't have everything. Where would you put it?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic