Coverage Summary for Class: Window (it.polimi.ingsw.Client.GUI)
Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
Window |
0%
(0/1)
|
0%
(0/5)
|
0%
(0/4)
|
0%
(0/16)
|
1 package it.polimi.ingsw.Client.GUI;
2
3 import javax.swing.*;
4 import java.awt.*;
5
6 import static it.polimi.ingsw.Client.GUI.IconLoader.logo;
7
8 /**
9 * Window creates the top-level container (Java Swing component) onto which the game will be rendered
10 */
11 public class Window {
12 /**
13 * Frame that will contain GUI's game version
14 */
15 private final JFrame frame;
16
17 public Window() {
18 //create frame and set its properties
19 this.frame = new JFrame("Eriantys");
20 assert logo != null;
21 frame.setIconImage(logo.getImage());
22 frame.setMinimumSize(new Dimension(1080, 720));
23 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
24 frame.setVisible(true);
25 frame.setResizable(false);
26 }
27
28 /**
29 * Remove all previous frame's contents and add a new JComponent
30 *
31 * @param newView Component that will be drawn inside the frame
32 */
33 public void changeView(JComponent newView) {
34 SwingUtilities.invokeLater(() -> {
35 frame.getContentPane().removeAll();
36 frame.add(newView);
37 frame.getContentPane().validate();
38 frame.getContentPane().repaint();
39 frame.pack();
40 });
41 }
42
43 /**
44 * @return GUI'S frame
45 */
46 public JFrame getFrame() {
47 return frame;
48 }
49 }