- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.java
More file actions
Latest commit
64 lines (50 loc) · 1.87 KB
/
Copy pathMainWindow.java
File metadata and controls
64 lines (50 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
packageGrafica.JavaClashOfClans;
importjavax.swing.*;
importjava.awt.*;
publicclassMainWindowextendsJFrame {
//! EDIT THIS PATH IF IMAGES DOESN'T APPEAR
publicstaticStringassetsPath = "Grafica/JavaClashOfClans/assets";
privateCardLayoutcardLayout;
GamePanelgamePanel;
ShopPanelshopPanel;
publicMainWindow(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(400,50, 1185, 950);
setResizable(false);
//? inizializzazione del layout
cardLayout = newCardLayout();
getContentPane().setLayout(cardLayout);
//? aggiunta dei pannelli al pannello con CardLayout
gamePanel = newGamePanel(15, 44, 50, this);
shopPanel = newShopPanel(this);
getContentPane().add(gamePanel, "Game");
getContentPane().add(shopPanel, "Shop");
setVisible(true);
}
voidswitchGameState(StringcardName) {
cardLayout.show(getContentPane(), cardName);
}
publicGamePanelgetGamePanel() {
returngamePanel;
}
staticintcalcRightX(MainWindowmainWindow, intpadding) {
intborder;
if (mainWindow.getInsets().left == 0) {
border = 8;
} else {
border = mainWindow.getInsets().left;
}
//? utilizzo il metodo getBounds perché come scritto nelle docs garantisce prestazioni migliori nella memoria
returnmainWindow.getBounds().width - border - padding;
}
staticintcalcBottomY(MainWindowmainWindow, intpadding) {
intborder;
if (mainWindow.getInsets().left == 0) {
border = 31;
} else {
border = mainWindow.getInsets().left;
}
//? utilizzo il metodo getBounds perché come scritto nelle docs garantisce prestazioni migliori nella memoria
returnmainWindow.getBounds().height - border - padding;
}
}