JRBuilder: Table Demo 1
Home «  Prev    Contents    Next  » Download
JRBuilder: Table Demo 1
A table.
Commentary TBD         
require 'jrbuilder'

ctx = JRBuilder.new_swing_context

ctx.enter {
  attr_reader :my_frame
  attr_accessor :my_table

  bgcolor = color(240,238,220)
  
  column_headings = ['SKU','Product Name','Quantity','Unit Price','Total Price']
  data = [
    ['123-456-789','Foo',3,2.75,3*2.75],
    ['123-456-790','Foo Plus',5,3.75,5*3.75],
    ['555-867-5309','Super Foo',2,9.27,2*9.27],
    ['987-654-321','Foo for Bars',4,7.99,4*7.99]
  ]

  @my_frame = frame('Table Demo 1') { size 500, 375
    content_pane { background  bgcolor; layout :box, _parent, :Y_AXIS
      border :bevel, :RAISED }
    on_window_closing { my_frame.dispose }
    menu_bar { background bgcolor
      menu("File") {  mnemonic :VK_F; background :WHITE
        menu_item("Exit") { mnemonic :VK_X; background :WHITE
          on_click { my_frame.dispose }
        }
    } }
    panel { background bgcolor; layout :box, _parent, :Y_AXIS
      border :compound, border(:titled, 'Current Order Items') {
        border :etched,:LOWERED }, border(:empty,7,7,7,7)
      scroll_pane(
        @my_table = table(data,column_headings) {
          get_table_header {
            background :BLUE; foreground :WHITE;
            font('Dialog',:BOLD,12)
          }
      }) {
        get_viewport { background :WHITE }
      }
    }
  }
}

ctx.my_frame.show
Home «  Prev    Contents    Next  » Download