Need Swing dialog with 2 Inputs

My java is very rusty. I need to write a little jruby script with some
dialogs that have multiple text inputs. The code below shows up, but 1)
I don’t know how to access the results and 2) how can I have a newline
between the label/text input pairs? Thanks, Ken

    panel = JPanel.new
    panel.add(JLabel.new('param1'))
    panel.add(JTextField.new(5))
    panel.add(JLabel.new('param2'))
    panel.add(JTextField.new(5))
    JOptionPane.showMessageDialog(JFrame.new, panel)

Hi Ken,

My java is very rusty. I need to write a little jruby script with some
dialogs that have multiple text inputs. The code below shows up, but 1)
I don’t know how to access the results and

Store the Textfields into variable, and then retrieve the text property.

  1. how can I have a newline
    between the label/text input pairs?

By using layouts, for example GridLayout.
Example:

tf1 = JTextField.new(5)
tf2 = JTextField.new(5)

panel = JPanel.new(java.awt.GridLayout.new(2,2))
panel.add(JLabel.new(‘param1’))
panel.add(tf1)
panel.add(JLabel.new(‘param2’))
panel.add(tf2)
JOptionPane.showMessageDialog(JFrame.new, panel)

puts “#{tf1.text} - #{tf2.text}”

Regards,
Sbastien.

That works perfect. You saved me from digging out my ancient
thousand-pager Swing book. Thanks!