Class: GamesAndRpgParadise::GUI::VierGewinnt

Inherits:
JFrame
  • Object
show all
Includes:
SharedCode, SwingParadise, SwingParadise::AWT
Defined in:
lib/games_and_rpg_paradise/gui/jruby/vier_gewinnt/vier_gewinnt.rb

Constant Summary

Constants included from SharedCode

SharedCode::HEIGHT, SharedCode::NAMESPACE, SharedCode::N_ELEMENTS_IN_THE_X_AXIS, SharedCode::N_ELEMENTS_IN_THE_Y_AXIS, SharedCode::RED, SharedCode::TITLE, SharedCode::UNICODE_BIG_DOT, SharedCode::WIDTH, SharedCode::YELLOW

Instance Method Summary collapse

Constructor Details

#initialize(run_already = true) ⇒ VierGewinnt

#

initialize

#


39
40
41
42
43
# File 'lib/games_and_rpg_paradise/gui/jruby/vier_gewinnt/vier_gewinnt.rb', line 39

def initialize(
    run_already = true
  )
  run if run_already
end

Instance Method Details

#runObject

#

run

#


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/games_and_rpg_paradise/gui/jruby/vier_gewinnt/vier_gewinnt.rb', line 48

def run
  frame = JFrame.new(TITLE)
  panel = JPanel.new # This is an instance of Java::JavaxSwing::JPanel.
  panel.set_font(Font.new 'Sans serif', Font::PLAIN, 25)
  frame.getContentPane.add(panel)
  panel.setLayout(nil)
  panel.hint = 'A game.'
  panel.background = ROYALBLUE
  button_test = create_button('Click me')
  button_test.add_action_listener { |event|
    e 'HEY THERE' # System.exit(0) # quit here
  }
  button_test.setBounds(
    WIDTH / 2 - (100 / 2),
    HEIGHT * 0.2,
     80,
    25
  )
  panel << button_test
  _ = quit_button
  _.setBounds(
    WIDTH / 2 - (100 / 2),
    HEIGHT * 0.8,
    100,
    40
  )
  panel << _
  frame.setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
  frame.setSize(WIDTH, HEIGHT)
  frame.setLocationRelativeTo(nil)
  frame.setVisible(true) 
  frame.show_all
end