Class: SimpleGuiCreator::NonBlockingDialog
- Inherits:
-
JDialog
- Object
- JDialog
- SimpleGuiCreator::NonBlockingDialog
- Defined in:
- lib/simple_gui_creator/swing_helpers.rb
Instance Method Summary collapse
-
#initialize(title_and_display_text, close_button_text = 'Close') ⇒ NonBlockingDialog
constructor
A new instance of NonBlockingDialog.
Constructor Details
#initialize(title_and_display_text, close_button_text = 'Close') ⇒ NonBlockingDialog
Returns a new instance of NonBlockingDialog.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/simple_gui_creator/swing_helpers.rb', line 152 def initialize title_and_display_text, = 'Close' super nil # so that set_title will work lines = title_and_display_text.split("\n") set_title lines[0] get_content_pane.set_layout nil lines.each_with_index{|line, idx| jlabel = JLabel.new line jlabel.set_bounds(10, 15*idx, 550, 24) get_content_pane.add jlabel } close = JButton.new( ).on_clicked { self.dispose } number_of_lines = lines.length close.set_bounds(125,30+15*number_of_lines, .length * 15,25) get_content_pane.add close set_size 550, 100+(15*number_of_lines) # XXX variable width? or use swing build in better? set_visible true setDefaultCloseOperation JFrame::DISPOSE_ON_CLOSE setLocationRelativeTo nil # center it on the screen end |