Class: __NAME__Frame
- Inherits:
-
Frame
- Object
- Frame
- __NAME__Frame
- Defined in:
- lib/templates/basic/basic_ui.rb
Overview
This is the main class used by your view.
Important: Make sure that all components are exposed as accessors so that the View code can use them.
Constant Summary collapse
- FRAME_WIDTH =
600
- FRAME_HEIGHT =
130
- LABEL_WIDTH =
400
- LABEL_HEIGHT =
60
Instance Attribute Summary collapse
-
#about_menu ⇒ Object
Make sure our components are available!.
-
#default_button ⇒ Object
Make sure our components are available!.
-
#default_label ⇒ Object
Make sure our components are available!.
-
#exit_menu ⇒ Object
Make sure our components are available!.
-
#menu_bar ⇒ Object
Make sure our components are available!.
Instance Method Summary collapse
-
#initialize(args) ⇒ __NAME__Frame
constructor
A new instance of __NAME__Frame.
- #set_up_components ⇒ Object
Constructor Details
#initialize(args) ⇒ __NAME__Frame
Returns a new instance of __NAME__Frame.
60 61 62 63 64 65 |
# File 'lib/templates/basic/basic_ui.rb', line 60 def initialize args super self.minimum_width = FRAME_WIDTH self.minimum_height = FRAME_HEIGHT set_up_components end |
Instance Attribute Details
#about_menu ⇒ Object
Make sure our components are available!
54 55 56 |
# File 'lib/templates/basic/basic_ui.rb', line 54 def @about_menu end |
#default_button ⇒ Object
Make sure our components are available!
54 55 56 |
# File 'lib/templates/basic/basic_ui.rb', line 54 def @default_button end |
#default_label ⇒ Object
Make sure our components are available!
54 55 56 |
# File 'lib/templates/basic/basic_ui.rb', line 54 def default_label @default_label end |
#exit_menu ⇒ Object
Make sure our components are available!
54 55 56 |
# File 'lib/templates/basic/basic_ui.rb', line 54 def @exit_menu end |
#menu_bar ⇒ Object
Make sure our components are available!
54 55 56 |
# File 'lib/templates/basic/basic_ui.rb', line 54 def @menu_bar end |
Instance Method Details
#set_up_components ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/templates/basic/basic_ui.rb', line 67 def set_up_components component_panel = Panel.new # If we were clever we would define a method that took a single hex value, like CSS. component_panel.background_color 255, 255, 255 component_panel.size FRAME_WIDTH, FRAME_HEIGHT # This code uses the MiG layout manager. # To learn more about MiGLayout, see: # http://www.miglayout.com/ component_panel.layout = Java::net::miginfocom::swing::MigLayout.new("wrap 2") @menu_bar = MenuBar.new do || @file_menu = Menu.new do |m| @exit_menu = MenuItem.new do |mi| mi.name = 'exit_menu' mi.mnemonic= Monkeybars::Key.symbol_to_code :VK_X mi.text ="Exit" end m.name = 'file_menu' m.text ="File" m.add end @help_menu = Menu.new do |m| @about_menu = MenuItem.new do |mi| mi.name = 'about_menu' mi.mnemonic= Monkeybars::Key.symbol_to_code :VK_A mi.text ="About" end m.name = 'help_menu' m.text = 'Help' m.add end # Worth noting: you can add the mnu item objects directly, which NetBeans doesn't seem to allow .add @file_menu .add @help_menu end @default_label = Label.new do |l| # A nicer way to set fonts would be welcome l.font = java::awt.Font.new "Lucida Grande", 0, 18 l.minimum_dimensions LABEL_WIDTH, LABEL_HEIGHT l.text = "Neurogami::SwingSet rulez!" end # We need to set a name so that the controller can catch events from this button @default_button = Button.new do |b| b.name = "default_button" b.text = "Click me!" end # Add components to panel component_panel.add @default_button, 'grow x' component_panel.add @default_label, "gap unrelated" add component_panel end |