Module: SwingParadise::BaseModule

Overview

SwingParadise::BaseModule

Constant Summary

Constants included from SwingParadise

LAST_UDPATE, VERSION

Instance Method Summary collapse

Methods included from SwingParadise

button, create_checkbox, create_grid, create_image, create_text_view, entry, frame, hbox, is_left_mouse_button?, #jcombobox, #jframe, jpanel, jruby_font, jscroll_pane, #jtextview, remove_html, set_global_font, #show_message_dialog, #swing_dimension, text, vbox, window

Instance Method Details

#bold_button(i = '', optional_widget_to_have_the_click_action_defined = nil, &block) ⇒ Object

#

bold_button

#


253
254
255
256
257
258
259
260
261
# File 'lib/swing_paradise/base_module/base_module.rb', line 253

def bold_button(
    i = '',
    optional_widget_to_have_the_click_action_defined = nil,
    &block
  )
  _ = create_button(i, optional_widget_to_have_the_click_action_defined, &block)
  _.setFont(_.getFont.deriveFont(Font::BOLD))
  return _
end

#bold_text(i = '') ⇒ Object Also known as: bold_label, create_text

#

bold_text

#


583
584
585
586
587
# File 'lib/swing_paradise/base_module/base_module.rb', line 583

def bold_text(i = '')
  _ = ::SwingParadise.text(i)
  make_bold(_)
  return _
end

#button_with_image(icon_location = '', optional_text = '', optional_widget_to_have_the_click_action_defined = nil, &block) ⇒ Object

#

button_with_image

This is a button with an image (also called an icon).

#


149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/swing_paradise/base_module/base_module.rb', line 149

def button_with_image(
    icon_location                                    = '',
    optional_text                                    = '',
    optional_widget_to_have_the_click_action_defined = nil,
    &block
  )
  if icon_location and icon_location.is_a?(String)
    icon_location = ImageIcon.new(icon_location)
  end
  if optional_text and !optional_text.empty?
    button = JButton.new(optional_text, icon_location)
  else
    button = JButton.new(icon_location)
  end
  # ======================================================================= #
  # === Handle blocks given to this method next
  # ======================================================================= #
  if block_given?
    yielded = yield
    # ===================================================================== #
    # === Handle Hashes next
    # ===================================================================== #
    if yielded.is_a? Hash
      # =================================================================== #
      # === :font
      # =================================================================== #
      if yielded.has_key? :font
        button.use_this_font = yielded.delete(:font)
      end
    else
      button.on_clicked {
        if optional_widget_to_have_the_click_action_defined
          optional_widget_to_have_the_click_action_defined.send(yielded.to_sym)
        else
          send(yielded.to_sym)
        end
      }
    end
  end
  return button    
end

#checkbox(i = '') ⇒ Object Also known as: jcheckbox, create_checkbox

#

checkbox

This method can be used to create a checkbox, in jruby-SWING.

#


699
700
701
702
703
# File 'lib/swing_paradise/base_module/base_module.rb', line 699

def checkbox(
    i = ''
  )
  return ::SwingParadise.create_checkbox(i)
end

#combo_box(optional_array = nil) ⇒ Object Also known as: create_combo_box

#

combo_box

You can pass an Array to this method; ideally an Array of Strings.

#


762
763
764
765
766
767
768
769
770
771
772
773
# File 'lib/swing_paradise/base_module/base_module.rb', line 762

def combo_box(
    optional_array = nil
  )
  _ = JComboBox.new
  if optional_array and optional_array.is_a?(Array) and !optional_array.empty?
    optional_array.each {|this_item|
      _.addItem(this_item)
    }
    _.setSelectedIndex(0) # Always have the first entry selected.
  end
  return _
end

#commandline_arguments?Boolean

#

commandline_arguments?

#

Returns:

  • (Boolean)


935
936
937
# File 'lib/swing_paradise/base_module/base_module.rb', line 935

def commandline_arguments?
  @commandline_arguments
end

#cpr(from = return_pwd, to = '.') ⇒ Object

#

cpr

This is recursive copy.

#


286
287
288
289
290
291
# File 'lib/swing_paradise/base_module/base_module.rb', line 286

def cpr(
    from = return_pwd,
    to   = '.'
  )
  FileUtils.cp_r(from, to, verbose: true)
end

#create_boxlayout(i, use_this_axis = BoxLayout::PAGE_AXIS) ⇒ Object Also known as: new_boxlayout

#

create_boxlayout

BoxLayout in Java resides at javax.swing.BoxLayout.

The first argument to this method should be the panel that contains the child elements.

The second argument can have any of these values:

BoxLayout::X_AXIS
BoxLayout::Y_AXIS
BoxLayout::LINE_AXIS
BoxLayout::PAGE_AXIS

The recommended API for using this method is this:

panel = create_boxlayout(:new_panel)
#


644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
# File 'lib/swing_paradise/base_module/base_module.rb', line 644

def create_boxlayout(
    i,
    use_this_axis = BoxLayout::PAGE_AXIS
  )
  case i
  # ======================================================================= #
  # === :new_panel
  # ======================================================================= #
  when :new_panel
    i = create_panel
  end
  case use_this_axis
  # ======================================================================= #
  # === :north
  # ======================================================================= #
  when :north
    use_this_axis = BorderLayout::NORTH
  # ======================================================================= #
  # === :west
  # ======================================================================= #
  when :west
    use_this_axis = BorderLayout::WEST
  # ======================================================================= #
  # === :east
  # ======================================================================= #
  when :east
    use_this_axis = BorderLayout::EAST
  # ======================================================================= #
  # === :south
  # ======================================================================= #
  when :south
    use_this_axis = BorderLayout::SOUTH
  end
  box_layout = BoxLayout.new(i, use_this_axis)
  i.setLayout(box_layout)
  return i
end

#create_file_chooserObject

#

create_file_chooser

#


354
355
356
# File 'lib/swing_paradise/base_module/base_module.rb', line 354

def create_file_chooser
  JFileChooser.new
end

#create_grid(argument1 = 3, argument2 = 3) ⇒ Object Also known as: grid

#

create_grid

#


778
779
780
781
782
783
# File 'lib/swing_paradise/base_module/base_module.rb', line 778

def create_grid(
    argument1 = 3,
    argument2 = 3
  )
  ::SwingParadise.create_grid(argument1, argument2)
end

#create_menubarObject Also known as: create_menu_bar

#

create_menubar

#


949
950
951
# File 'lib/swing_paradise/base_module/base_module.rb', line 949

def create_menubar
  JMenuBar.new
end

#create_window_or_runner(optional_widget = nil) ⇒ Object Also known as: create_window

#

create_window_or_runner

#


406
407
408
409
410
411
412
413
414
# File 'lib/swing_paradise/base_module/base_module.rb', line 406

def create_window_or_runner(
    optional_widget = nil
  )
  frame = SwingParadise.create_frame(internal_width?, internal_height?)
  if optional_widget
    frame.add(optional_widget)
  end
  return frame
end

#defaul_table_model(first_argument = nil, optional_columns = nil) ⇒ Object

#

defaul_table_model

#


296
297
298
299
300
301
302
303
304
305
# File 'lib/swing_paradise/base_module/base_module.rb', line 296

def defaul_table_model(
    first_argument   = nil,
    optional_columns = nil
  )
  if optional_columns
    javax.swing.table.DefaultTableModel.new(first_argument, optional_columns)
  else
    javax.swing.table.DefaultTableModel.new
  end
end

#default_closeObject

#

default_close

#


399
400
401
# File 'lib/swing_paradise/base_module/base_module.rb', line 399

def default_close
  setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
end

#do_quit(use_this_as_the_exit_code = 0) ⇒ Object

#

do_quit

This method can be used as a more convenient do-exit method.

#


442
443
444
445
446
# File 'lib/swing_paradise/base_module/base_module.rb', line 442

def do_quit(
    use_this_as_the_exit_code = 0
  )
  System.exit(use_this_as_the_exit_code)
end

#empty_border(a = 2, b = :default, c = :default, d = :default) ⇒ Object

#

empty_border

#


419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
# File 'lib/swing_paradise/base_module/base_module.rb', line 419

def empty_border(
    a = 2, # This is the primary value - the most important value.
    b = :default,
    c = :default,
    d = :default
  )
  if b == :default
    b = a
  end
  if c == :default
    c = a
  end
  if d == :default
    d = a
  end
  EmptyBorder.new(a, b, c, d)
end

#entry(i = '', optional_size = nil) ⇒ Object Also known as: hcentered_entry, create_entry, text_field, jtextfield, create_textfield

#

entry

This is simply a wrapper over JTextField.

#


381
382
383
384
385
386
387
388
389
390
# File 'lib/swing_paradise/base_module/base_module.rb', line 381

def entry(
    i             = '',
    optional_size = nil
  )
  if optional_size
    JTextField.new(i, optional_size) # This is similar to e. g. JTextField.new("", 20).
  else
    JTextField.new(i)
  end
end

#esystem(i = '') ⇒ Object

#

esystem

#


277
278
279
# File 'lib/swing_paradise/base_module/base_module.rb', line 277

def esystem(i = '')
  e i; system i
end

#first_argument?Boolean Also known as: first?

#

first_argument?

#

Returns:

  • (Boolean)


942
943
944
# File 'lib/swing_paradise/base_module/base_module.rb', line 942

def first_argument?
  @commandline_arguments.first
end

#has_the_enter_key_been_pressed?(event) ⇒ Boolean

#

has_the_enter_key_been_pressed?

This method assumes that a java-swing event was passed as argument.

#

Returns:

  • (Boolean)


372
373
374
# File 'lib/swing_paradise/base_module/base_module.rb', line 372

def has_the_enter_key_been_pressed?(event)
  event.getKeyCode == KeyEvent::VK_ESCAPE
end

#hboxObject Also known as: create_hbox

#

hbox (hbox tag)

#


606
607
608
# File 'lib/swing_paradise/base_module/base_module.rb', line 606

def hbox
  Box.createHorizontalBox
end

#height?Boolean Also known as: internal_height?

#

height?

#

Returns:

  • (Boolean)


852
853
854
# File 'lib/swing_paradise/base_module/base_module.rb', line 852

def height?
  @internal_height
end

#infer_the_namespaceObject

#

infer_the_namespace

This will assume the true namespace from the inspectable name.

#


552
553
554
555
556
557
558
559
560
561
562
563
564
# File 'lib/swing_paradise/base_module/base_module.rb', line 552

def infer_the_namespace
  _ = inspect.to_s.delete('<')
  if _.include? ' '
    _ = _.split(' ').first.delete('#')
    if _.include? ':'
      _ = _.split(':')[0 .. -2].reject {|entry| entry.empty? }.join('::')
    end
  end
  if @internal_hash.nil?
    reset_the_internal_hash
  end
  @internal_hash[:namespace] = _ # And assign it here.
end

#infer_the_size_based_on_constants(width = WIDTH, height = HEIGHT) ⇒ Object

#

infer_the_size_based_on_constants

#


788
789
790
791
792
793
794
795
796
# File 'lib/swing_paradise/base_module/base_module.rb', line 788

def infer_the_size_based_on_constants(
    width  = WIDTH,
    height = HEIGHT
  )
  set_size(
    width,
    height
  )
end

#insets(n = 6) ⇒ Object

#

insets

#


536
537
538
# File 'lib/swing_paradise/base_module/base_module.rb', line 536

def insets(n = 6)
  Insets.new(n, n, n, n)
end

#internal_title?Boolean Also known as: title?

#

internal_title?

#

Returns:

  • (Boolean)


866
867
868
# File 'lib/swing_paradise/base_module/base_module.rb', line 866

def internal_title?
  @internal_title
end

#is_visibleObject

#

is_visible

#


489
490
491
# File 'lib/swing_paradise/base_module/base_module.rb', line 489

def is_visible
  setVisible(true)
end

#java_colour(use_this_symbol = :steelblue) ⇒ Object Also known as: java_color

#

java_colour

This method only works with symbols as input, such as :steelblue or :bisque.

This method depends on the external gem called ‘colours’.

Usage examples:

use_this_colour = java_colour(:bisque)
use_this_colour = java_colour(:steelblue)
#


516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'lib/swing_paradise/base_module/base_module.rb', line 516

def java_colour(
    use_this_symbol = :steelblue
  )
  begin
    require 'colours/constants/file_constants.rb'
  rescue LoadError; end
  _ = ::Colours.file_html_colours
  if File.exist? _
    dataset = YAML.load_file(_)
    if dataset.has_key? use_this_symbol.to_s
      pointer = dataset[use_this_symbol.to_s]
      return Color.new(pointer[0], pointer[1], pointer[2])
    end
  end
  return nil # else we return nil.
end

#jbutton(i = '', optional_widget_to_have_the_click_action_defined = nil, &block) ⇒ Object Also known as: button, create_button

#

jbutton (button tag)

This method can be used to create a new button, aka a jbutton in java-swing parlance.

#


197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/swing_paradise/base_module/base_module.rb', line 197

def jbutton(
    i = '',
    optional_widget_to_have_the_click_action_defined = nil,
    &block
  )
  button = JButton.new(i)
  # ======================================================================= #
  # === Handle blocks given to this method next
  # ======================================================================= #
  if block_given?
    yielded = yield
    # ===================================================================== #
    # === Handle Hashes next
    # ===================================================================== #
    if yielded.is_a? Hash
      # =================================================================== #
      # === :font
      # =================================================================== #
      if yielded.has_key? :font
        button.use_this_font = yielded.delete(:font)
      end
    else
      button.on_clicked {
        if optional_widget_to_have_the_click_action_defined
          optional_widget_to_have_the_click_action_defined.send(yielded.to_sym)
        else
          send(yielded.to_sym)
        end
      }
    end
  end
  return button
end

#jlabel(i = '') ⇒ Object

#

jlabel

#


613
614
615
# File 'lib/swing_paradise/base_module/base_module.rb', line 613

def jlabel(i = '')
  JLabel.new(i)
end

#jpanel(optional_layout_to_use = nil, &block) ⇒ Object Also known as: new_panel, create_panel, create_jpanel

#

jpanel

Usage example:

panel = create_panel { :left }
#


733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
# File 'lib/swing_paradise/base_module/base_module.rb', line 733

def jpanel(
    optional_layout_to_use = nil,
    &block
  )
  if optional_layout_to_use
    _ = JPanel.new(optional_layout_to_use)
  else
    _ = JPanel.new
  end
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :left
    # ===================================================================== #
    when :left
      _.layout = FlowLayout.new(FlowLayout::LEFT)
    end
  end
  return _
end

#jruby_font(i = 'Sans serif 28') ⇒ Object Also known as: font

#

jruby_font

Simply delegate towards SwingParadise.jruby_font().

#


901
902
903
904
905
# File 'lib/swing_paradise/base_module/base_module.rb', line 901

def jruby_font(
    i = 'Sans serif 28'
  )
  ::SwingParadise.jruby_font(i)
end

#jscroll_pane(child_widget, vertical_scrollbar_policy = :vertical_always, horizontal_scrollbar_policy = :default) ⇒ Object Also known as: scroll_pane, scrollpane, scrolled_window, scrolling, created_scrolled_window, create_scrolled_window, default_scroll_pane

#

jscroll_pane

A JScrollPane provides a scrollable view of another widget. The JScrollPane manages a viewport, optional vertical and horizontal scroll bars, and optional row and column heading viewports.

#


314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/swing_paradise/base_module/base_module.rb', line 314

def jscroll_pane(
    child_widget,
    vertical_scrollbar_policy   = :vertical_always,
    horizontal_scrollbar_policy = :default
  )
  case vertical_scrollbar_policy
  # ======================================================================= #
  # === :vertical_always
  # ======================================================================= #
  when :vertical_always
    vertical_scrollbar_policy = Java::JavaxSwing::ScrollPaneConstants::VERTICAL_SCROLLBAR_ALWAYS
  end
  case horizontal_scrollbar_policy
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    horizontal_scrollbar_policy = Java::JavaxSwing::ScrollPaneConstants::HORIZONTAL_SCROLLBAR_ALWAYS
  # ======================================================================= #
  # === :horizontal_never
  # ======================================================================= #
  when :horizontal_never
    horizontal_scrollbar_policy = Java::JavaxSwing::ScrollPaneConstants::HORIZONTAL_SCROLLBAR_NEVER
  end
  JScrollPane.new(
    child_widget,
    vertical_scrollbar_policy,
    horizontal_scrollbar_policy
  )
end

#jtextarea(optional_argument1 = nil, optional_argument2 = nil) ⇒ Object Also known as: create_textarea, create_text_view

#

jtextarea

#


801
802
803
804
805
806
807
808
809
810
# File 'lib/swing_paradise/base_module/base_module.rb', line 801

def jtextarea(
    optional_argument1 = nil,
    optional_argument2 = nil
  )
  if optional_argument1.nil?
    JTextArea.new
  elsif optional_argument1 and optional_argument2
    JTextArea.new(optional_argument1, optional_argument2)
  end
end

#left_mouse_click?(event) ⇒ Boolean

#

left_mouse_click?

#

Returns:

  • (Boolean)


120
121
122
123
124
# File 'lib/swing_paradise/base_module/base_module.rb', line 120

def left_mouse_click?(
    event
  )
  javax.swing.SwingUtilities.isLeftMouseButton(event)
end

#make_bold(i) ⇒ Object

#

make_bold

#


593
594
595
596
597
598
599
600
601
# File 'lib/swing_paradise/base_module/base_module.rb', line 593

def make_bold(i)
  bold_font = Font.new(
    i.getFont.getName,
    Font::BOLD,
    i.getFont.getSize
  )
  i.setFont(bold_font)
  return i
end
#

menu_item

#


543
544
545
# File 'lib/swing_paradise/base_module/base_module.rb', line 543

def menu_item(i = '')
  JMenuItem.new(i)
end

#middle_mouse_click?(event) ⇒ Boolean

#

middle_mouse_click?

#

Returns:

  • (Boolean)


129
130
131
132
133
# File 'lib/swing_paradise/base_module/base_module.rb', line 129

def middle_mouse_click?(
    event
  )
  javax.swing.SwingUtilities.isMiddleMouseButton(event)
end

#namespace?Boolean

#

namespace?

#

Returns:

  • (Boolean)


569
570
571
# File 'lib/swing_paradise/base_module/base_module.rb', line 569

def namespace?
  @internal_hash[:namespace]
end

#password_field(i = '') ⇒ Object

#

password_field

#


496
497
498
499
500
# File 'lib/swing_paradise/base_module/base_module.rb', line 496

def password_field(
    i = ''
  )
  JPasswordField.new(i)
end

#platform?Boolean

#

platform?

Little helper-method to find out whether we are running jruby or another operating system.

#

Returns:

  • (Boolean)


913
914
915
916
917
918
919
920
921
922
# File 'lib/swing_paradise/base_module/base_module.rb', line 913

def platform?
  case RUBY_PLATFORM
  when /java/, /jruby/
    :java
  when /linux/ # This is for x86_64-linux, for instance.
    :linux
  else
    :unknown
  end
end

#quit_button(use_this_text = 'Quit') ⇒ Object

#

quit_button

#


266
267
268
269
270
271
272
# File 'lib/swing_paradise/base_module/base_module.rb', line 266

def quit_button(
    use_this_text = 'Quit'
  )
  _ = button(use_this_text)
  _.on_clicked { do_quit }
  return _
end

#radio_button(text = '', selected_or_not_selected = false) ⇒ Object Also known as: radiobutton, jradio_button

#

radio_button

#


235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/swing_paradise/base_module/base_module.rb', line 235

def radio_button(
    text                     = '',
    selected_or_not_selected = false
  )
  case selected_or_not_selected
  # ======================================================================= #
  # === :is_selected
  # ======================================================================= #
  when :is_selected
    selected_or_not_selected = true
  end
  JRadioButton.new(text, selected_or_not_selected)
end

#reset_the_internal_hashObject

#

reset_the_internal_hash

#


576
577
578
# File 'lib/swing_paradise/base_module/base_module.rb', line 576

def reset_the_internal_hash
  @internal_hash = {}
end

#return_pwdObject

#

return_pwd

#


620
621
622
# File 'lib/swing_paradise/base_module/base_module.rb', line 620

def return_pwd
  (Dir.pwd+'/').squeeze('/')
end

#right_aligned_label(i = '') ⇒ Object

#

right_aligned_label

Note that JLabel also has setHorizontalAlignment:

label.setHorizontalAlignment(SwingConstants::RIGHT)
#


721
722
723
# File 'lib/swing_paradise/base_module/base_module.rb', line 721

def right_aligned_label(i = '')
  return JLabel.new(i, SwingConstants::RIGHT)
end

#right_mouse_click?(event) ⇒ Boolean

#

right_mouse_click?

#

Returns:

  • (Boolean)


138
139
140
141
142
# File 'lib/swing_paradise/base_module/base_module.rb', line 138

def right_mouse_click?(
    event
  )
  javax.swing.SwingUtilities.isRightMouseButton(event)
end

#run_main(i = main_window? ) ⇒ Object

#

run_main

#


873
874
875
876
877
878
879
880
881
882
# File 'lib/swing_paradise/base_module/base_module.rb', line 873

def run_main(
    i = main_window?
  )
  i.exit_on_close
  i.set_title(internal_title?)
  i.set_size(internal_width?, internal_height?)
  i.setLocationRelativeTo(nil)
  i.show_all
  return i
end

#set_commandline_arguments(i = '') ⇒ Object

#

set_commandline_arguments

#


927
928
929
930
# File 'lib/swing_paradise/base_module/base_module.rb', line 927

def set_commandline_arguments(i = '')
  i = [i].flatten.compact
  @commandline_arguments = i
end

#set_global_font(use_this_font = Font.new('Hack', Font::PLAIN, 40)) ⇒ Object

#

set_global_font

This method can be used to set a global font for a jruby-SWING application.

#


473
474
475
476
477
# File 'lib/swing_paradise/base_module/base_module.rb', line 473

def set_global_font(
    use_this_font = Font.new('Hack', Font::PLAIN, 40)
  )
  SwingParadise.set_global_font(use_this_font)
end

#set_internal_font(i) ⇒ Object

#

set_internal_font

#


887
888
889
# File 'lib/swing_paradise/base_module/base_module.rb', line 887

def set_internal_font(i)
  @internal_font = i
end

#set_internal_height(i) ⇒ Object

#

set_internal_height

#


845
846
847
# File 'lib/swing_paradise/base_module/base_module.rb', line 845

def set_internal_height(i)
  @internal_height = i
end

#set_internal_title(i) ⇒ Object

#

set_internal_title

#


831
832
833
# File 'lib/swing_paradise/base_module/base_module.rb', line 831

def set_internal_title(i)
  @internal_title = i
end

#set_internal_width(i) ⇒ Object

#

set_internal_width

#


838
839
840
# File 'lib/swing_paradise/base_module/base_module.rb', line 838

def set_internal_width(i)
  @internal_width = i
end

#text(i = '') ⇒ Object Also known as: label

#

text

#


709
710
711
# File 'lib/swing_paradise/base_module/base_module.rb', line 709

def text(i = '')
  ::SwingParadise.text(i)
end

#this_file_was_not_found(i) ⇒ Object Also known as: no_file_exists_at, no_file_was_found_at

#

this_file_was_not_found

Use this to notify the user, whenever the open-gem was unable to find a file that was assumed to exist locally.

#


688
689
690
691
# File 'lib/swing_paradise/base_module/base_module.rb', line 688

def this_file_was_not_found(i)
  e "#{rev}No file called `#{sfile(i)}` was found. It "\
    "is assumed to not exist."
end

#title_width_height_font(title, width, height, font) ⇒ Object

#

title_width_height_font

#


816
817
818
819
820
821
822
823
824
825
826
# File 'lib/swing_paradise/base_module/base_module.rb', line 816

def title_width_height_font(
    title,
    width,
    height,
    font
  )
  set_internal_title(title)
  set_internal_width(width)
  set_internal_height(height)
  set_internal_font(font)
end

#use_gtk_paradise_project_css_fileObject

#

The methods that come past this point are “deliberately” not useful.

#


894
# File 'lib/swing_paradise/base_module/base_module.rb', line 894

def use_gtk_paradise_project_css_file; end

#use_jruby?Boolean

#

use_jruby?

#

Returns:

  • (Boolean)


482
483
484
# File 'lib/swing_paradise/base_module/base_module.rb', line 482

def use_jruby?
  true
end

#vboxObject Also known as: create_vbox

#

vbox

A vertical box.

#


363
364
365
# File 'lib/swing_paradise/base_module/base_module.rb', line 363

def vbox
  javax.swing.Box.createVerticalBox
end

#width?Boolean Also known as: internal_width?

#

width?

#

Returns:

  • (Boolean)


859
860
861
# File 'lib/swing_paradise/base_module/base_module.rb', line 859

def width?
  @internal_width
end

#word_wrap(text, line_width = 75) ⇒ Object

#

word_wrap

#


451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'lib/swing_paradise/base_module/base_module.rb', line 451

def word_wrap(
    text,
    line_width = 75
  )
  if line_width.is_a? Hash
    # ===================================================================== #
    # === :threshold
    # ===================================================================== #
    if line_width.has_key? :threshold
      line_width = line_width.delete(:threshold)
    end
  end
  result = text.scan(/\S.{0,#{line_width}}\S(?=\s|$)|\S+/).join(N)
  return result
end