Guest User

Untitled

a guest
May 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. private Main(){
  2. super("TicTacToe" + "v1.0");
  3.  
  4. JPanel buttonPanel = new JPanel();
  5. JPanel inputPanel = new JPanel();
  6. inputArea = new JTextArea();
  7. outputArea = new OutputArea();
  8. JLabel inputLabel = new JLabel("CLI: ");
  9.  
  10. setSize(500, 700);
  11. setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  12. setVisible(true);
  13. setResizable(false);
  14.  
  15. buttons = initializeXOButtons(buttonPanel);
  16. buttonPanel.setLayout(new GridLayout(3,3));
  17. buttonPanel.setPreferredSize(new Dimension(400, 400));
  18.  
  19. submit = new ButtonSubmit(inputArea, outputArea, buttons, this);
  20.  
  21. inputArea.setPreferredSize(new Dimension(300, 20));
  22. disableKeys(inputArea.getInputMap(),new String[]{"ENTER"});
  23.  
  24. inputPanel.add(inputLabel);
  25. inputPanel.add(inputArea);
  26. inputPanel.add(submit);
  27.  
  28. //outputPanel.add(outputArea);
  29. JScrollPane scrollPane = new JScrollPane(outputArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
  30. JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  31. scrollPane.setPreferredSize(new Dimension(400, 150));
  32.  
  33. JMenuBar menuBar = new JMenuBar();
  34. JMenu menu = new JMenu("File");
  35.  
  36. this.gameSaver = new GameSaver();
  37. this.gameLoader = new GameLoader();
  38.  
  39. menu.add(gameSaver);
  40. menu.add(gameLoader);
  41.  
  42. menuBar.add(Box.createHorizontalGlue());
  43. menuBar.add(menu);
  44.  
  45. JPanel mainPanel = new JPanel();
  46.  
  47. mainPanel.setLayout(new BorderLayout());
  48.  
  49. mainPanel.add(menuBar, BorderLayout.NORTH);
  50. mainPanel.add(buttonPanel, BorderLayout.CENTER);
  51. mainPanel.add(inputPanel, BorderLayout.SOUTH);
  52. mainPanel.add(scrollPane, BorderLayout.SOUTH);
  53.  
  54. this.getContentPane().add(mainPanel);
  55.  
  56. }
Add Comment
Please, Sign In to add comment