Commit 10925a5f authored by nargessalehi98's avatar nargessalehi98

Update setting frame class.

parent 108ae5b3
...@@ -16,6 +16,9 @@ public class SettingFrame extends JFrame { ...@@ -16,6 +16,9 @@ public class SettingFrame extends JFrame {
private JLabel tankLabel; private JLabel tankLabel;
private JLabel tankPhoto; private JLabel tankPhoto;
private ImageIcon tank; private ImageIcon tank;
private JSlider tankHealthSlider;
private JSlider shotDamageSlider;
private JSlider wallsHealthSlider;
public SettingFrame() { public SettingFrame() {
...@@ -69,7 +72,6 @@ public class SettingFrame extends JFrame { ...@@ -69,7 +72,6 @@ public class SettingFrame extends JFrame {
add(userInformationPanel); add(userInformationPanel);
} }
public void textAndLabel(String pngFile, String textField) { public void textAndLabel(String pngFile, String textField) {
...@@ -100,9 +102,12 @@ public class SettingFrame extends JFrame { ...@@ -100,9 +102,12 @@ public class SettingFrame extends JFrame {
gameDetailsPanel.setLayout(new GridLayout(3, 2)); gameDetailsPanel.setLayout(new GridLayout(3, 2));
settingPanel.setBackground(Color.darkGray); settingPanel.setBackground(Color.darkGray);
settingPanel.setLayout(new BorderLayout()); settingPanel.setLayout(new BorderLayout());
sliderAndIcon("pictures/tankHealth.png", 40); tankHealthSlider = new JSlider(10, 100, 40);
sliderAndIcon("pictures/shotDamage.png", 80); shotDamageSlider = new JSlider(10, 100, 80);
sliderAndIcon("pictures/DestructibleWall.png", 20); wallsHealthSlider = new JSlider(10, 100, 20);
sliderAndIcon(tankHealthSlider, "pictures/tankHealth.png");
sliderAndIcon(shotDamageSlider, "pictures/shotDamage.png");
sliderAndIcon(wallsHealthSlider, "pictures/DestructibleWall.png");
initServerPanel(); initServerPanel();
add(settingPanel); add(settingPanel);
settingPanel.add(gameDetailsPanel, BorderLayout.NORTH); settingPanel.add(gameDetailsPanel, BorderLayout.NORTH);
...@@ -118,6 +123,9 @@ public class SettingFrame extends JFrame { ...@@ -118,6 +123,9 @@ public class SettingFrame extends JFrame {
okButton.addActionListener(new ActionListener() { okButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Controller.bulletDamage=shotDamageSlider.getValue();
Controller.tankHealth=tankHealthSlider.getValue();
Controller.wallsHealth=wallsHealthSlider.getValue();
dispose(); dispose();
} }
}); });
...@@ -125,9 +133,8 @@ public class SettingFrame extends JFrame { ...@@ -125,9 +133,8 @@ public class SettingFrame extends JFrame {
serverPanel.add(okButton, BorderLayout.EAST); serverPanel.add(okButton, BorderLayout.EAST);
} }
public void sliderAndIcon(String iconName, int value) { public void sliderAndIcon(JSlider slider, String iconName) {
JSlider slider = new JSlider(10, 100, value);
slider.setMajorTickSpacing(10); slider.setMajorTickSpacing(10);
slider.setBackground(Color.darkGray); slider.setBackground(Color.darkGray);
slider.setBorder(new LineBorder(Color.GRAY, 2)); slider.setBorder(new LineBorder(Color.GRAY, 2));
...@@ -143,4 +150,6 @@ public class SettingFrame extends JFrame { ...@@ -143,4 +150,6 @@ public class SettingFrame extends JFrame {
gameDetailsPanel.add(slider); gameDetailsPanel.add(slider);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment