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)
on 2012-12-13 15:49
on 2012-12-13 16:31
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. > 2) 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.
on 2012-12-13 16:38
That works perfect. You saved me from digging out my ancient thousand-pager Swing book. Thanks!
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.