package jrummikub.view; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.UIManager; import jrummikub.util.IListener; @SuppressWarnings("serial") public class View extends JFrame implements IView { private Table table; private PlayerPanel playerPanel; private final static int PLAYER_PANEL_HEIGHT = 150; public ITable getTable() { return table; } public IPlayerPanel getPlayerPanel() { return playerPanel; } public View() { super("JRummikub"); setSize(1000, 700); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BorderLayout()); table = new Table(); add(table, BorderLayout.CENTER); playerPanel = new PlayerPanel(); playerPanel.setBorder(new CustomBorder(Color.BLACK, 1, 0, 0, 0)); playerPanel.setPreferredSize(new Dimension(0, PLAYER_PANEL_HEIGHT+1)); add(playerPanel, BorderLayout.SOUTH); } /** * @param args */ public static void main(String[] args) { // FIXME Only test main for GUI preview String nativeLF = UIManager.getSystemLookAndFeelClassName(); try { UIManager.setLookAndFeel(nativeLF); } catch (Exception e) { } View view = new View(); view.getPlayerPanel().setCurrentPlayerName("Player 1"); view.getPlayerPanel().setTimeLeft(42); view.getTable().setLeftPlayerName("Player 2"); view.getTable().setTopPlayerName("Player 3"); view.getTable().setRightPlayerName("Player 4"); view.getPlayerPanel().getSortByNumberEvent().add(new IListener() { @Override public void fire() { System.out.println("'Sort by number' fired"); }}); view.getPlayerPanel().getSortByColorEvent().add(new IListener() { @Override public void fire() { System.out.println("'Sort by color' fired"); }}); view.getPlayerPanel().getEndTurnEvent().add(new IListener() { @Override public void fire() { System.out.println("'End turn' fired"); }}); view.setVisible(true); } }