Class: Example

Inherits:
JFrame show all
Defined in:
lib/roebe/jruby/swing/tooltip_example.rb,
lib/roebe/jruby/swing/quit_button_example.rb,
lib/roebe/jruby/swing/two_buttons_example.rb,
lib/roebe/jruby/swing/simple_swing_example.rb,
lib/roebe/jruby/swing/complete_windows_example.rb,
lib/roebe/jruby/swing/absolute_positioning_example.rb

Constant Summary collapse

WIDTH =
#

WIDTH

#
500
PANEL_TOOLTIP_TEXT =
#

PANEL_TOOLTIP_TEXT

#
'A Panel container'
USE_THIS_AS_THE_TOOLTIP_TEXT_FOR_THE_BUTTON =
#

USE_THIS_AS_THE_TOOLTIP_TEXT_FOR_THE_BUTTON

#
'A button component -  (Ruby version in use is: '+RUBY_VERSION.to_s+')'
BASE_IMG_DIR =

BASE_IMG_DIR

'/home/x/data/images/'

Instance Method Summary collapse

Constructor Details

#initializeExample

#

initialize

#


37
38
39
40
41
42
43
# File 'lib/roebe/jruby/swing/tooltip_example.rb', line 37

def initialize(
    run_already = true
  )
  super 'Tooltips'
  reset
  run if run_already
end

Instance Method Details

#connect_skeletonObject

#

connect_skeleton

#


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/roebe/jruby/swing/tooltip_example.rb', line 55

def connect_skeleton
  panel = JPanel.new
  getContentPane.add(panel)
  panel.setLayout(nil)
  panel.setToolTipText(PANEL_TOOLTIP_TEXT)
  # ======================================================================= #
  # Create the button next - it will be an instance of
  # Java::JavaxSwing::JButton
  # ======================================================================= #
  button = JButton.new(
    'Button showcasing a tooltip (Ruby version in use is: '+RUBY_VERSION.to_s+')'
  )
  button.setBounds(100, 60, 100, 30)
  # ======================================================================= #
  # Set a tool tip next:
  # ======================================================================= #
  button.hint = USE_THIS_AS_THE_TOOLTIP_TEXT_FOR_THE_BUTTON
  panel.add(button)

  setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
  setLocationRelativeTo nil
  set_visible(true)
end

#create_skeletonObject

#

create_skeleton

#


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/roebe/jruby/swing/quit_button_example.rb', line 28

def create_skeleton
  panel = JPanel.new # This is of class Java::JavaxSwing::JPanel
  getContentPane.add panel
  panel.setLayout nil
  quit_button = JButton.new 'Quit'
  quit_button.setBounds 50, 60, 80, 30
  quit_button.add_action_listener { |event|
    System.exit 0
  }

  panel << quit_button
  setDefaultCloseOperation JFrame::EXIT_ON_CLOSE
  setSize 300, 200
  setLocationRelativeTo nil
  setVisible true
end

#img1?Boolean

#

img1?

#

Returns:

  • (Boolean)


21
22
23
# File 'lib/roebe/jruby/swing/absolute_positioning_example.rb', line 21

def img1?
  BASE_IMG_DIR+'LIFESTYLE1.jpg'
end

#img2?Boolean

#

img2?

#

Returns:

  • (Boolean)


28
29
30
# File 'lib/roebe/jruby/swing/absolute_positioning_example.rb', line 28

def img2?
  BASE_IMG_DIR+'LIFESTYLE2.jpg'
end

#img3?Boolean

#

img3?

#

Returns:

  • (Boolean)


35
36
37
# File 'lib/roebe/jruby/swing/absolute_positioning_example.rb', line 35

def img3?
  BASE_IMG_DIR+'KONTAKT1.jpg'
end

#resetObject

#

reset

#


48
49
50
# File 'lib/roebe/jruby/swing/tooltip_example.rb', line 48

def reset
  setSize(WIDTH, 500)
end

#runObject

#

run

#


82
83
84
# File 'lib/roebe/jruby/swing/tooltip_example.rb', line 82

def run
  connect_skeleton
end