All Downloads are FREE. Search and download functionalities are using the official Maven repository.

examples.Life.src.main.gosu.life.BoardFrame.gs Maven / Gradle / Ivy

package life

uses javax.swing.JFrame
uses javax.swing.JPanel
uses java.awt.BorderLayout
uses java.awt.event.WindowAdapter
uses java.awt.event.WindowEvent
uses java.awt.event.ComponentAdapter
uses java.awt.event.ComponentEvent
uses java.awt.EventQueue
uses javax.swing.border.EmptyBorder
uses javax.swing.JComponent
uses java.awt.Point
uses javax.swing.ImageIcon
uses javax.swing.JScrollPane

/**
 */
final class BoardFrame extends JFrame {
  var _board: Board
  var _controlBoard: ControlBoard
  var _statusBoard: StatusBoard as StatBoard
  var _clientArea: JPanel as ClientArea

  @SuppressWarnings( "all" )
  construct() {
    super( "Game of Life" )
    IconImage = new ImageIcon( Class.getResource( "/life/images/gol.png" ) ).Image
    DefaultCloseOperation = DISPOSE_ON_CLOSE
    ContentPane.setLayout( new BorderLayout() )
    _clientArea = new JPanel( new BorderLayout() )
    _board = new Board( new LifeModel() )
    _clientArea.add( _board, BorderLayout.CENTER )
    ContentPane.add( _clientArea, BorderLayout.CENTER )
    _controlBoard = new ControlBoard( _board, this )
    ContentPane.add( new JScrollPane( _controlBoard.TopBar, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ) {:Border = new EmptyBorder(0, 0, 0, 0)}, BorderLayout.NORTH )
    ContentPane.add( new JScrollPane( _controlBoard.LeftBar, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ) {:Border = new EmptyBorder(0, 0, 0, 0)}, BorderLayout.WEST )
    _statusBoard = new StatusBoard( _board, this )
    ContentPane.add( _statusBoard, BorderLayout.SOUTH )
    (ContentPane as JComponent).Border = new EmptyBorder( 4, 4, 0, 4 )

    addComponentListener( new ComponentAdapter() {
      override function componentResized( e: ComponentEvent ) {
        adjustClientArea()
      }
    } )

    setLocation( 300, 100 )
    setSize( 550, 475 )
    EventQueue.invokeLater( \-> {
        _controlBoard.init()
        _statusBoard.init()
        _board.start()}
      )
  }

  function adjustClientArea() {
    _controlBoard.resetCellSize()
    _clientArea.revalidate()
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy