Neues GUI und icons

This commit is contained in:
Noah
2021-09-28 22:05:49 +02:00
parent 16d469386c
commit 44d83c6cb7
11 changed files with 127 additions and 40 deletions
+8
View File
@@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="Conways-Game-of-Life:jar">
<output-path>$PROJECT_DIR$/out/artifacts/Conways_Game_of_Life_jar</output-path>
<root id="archive" name="Conways-Game-of-Life.jar">
<element id="module-output" name="Conways-Game-of-Life" />
</root>
</artifact>
</component>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 812 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 KiB

-1
View File
@@ -1 +0,0 @@
<?xml version="1.0" ?><svg data-name="Layer 1" id="Layer_1" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><title/><path d="M31,11.44A6.49,6.49,0,0,0,19.82,7H12.18A6.49,6.49,0,0,0,1,11.44,84.11,84.11,0,0,0,0,23.53c0,242,1,4,2.92,4.36A5.41,5.41,0,0,0,4,28a3.9,3.9,0,0,0,3.82-2.82c0.39-1.1,1.09-2.62,1.52-3.54A4,4,0,0,0,14.87,19h2.26a4,4,0,0,0,5.52,2.64c0.43,0.91,1.13,2.43,1.52,3.54A3.9,3.9,0,0,0,28,28a5.4,5.4,0,0,0,1.09-.11C31,27.5,32,25.95,32,23.53A84.11,84.11,0,0,0,31,11.44ZM6.89,24.85a3,3,0,0,1-3.77,2.06C1.37,26.54,1,24.87,1,23.53a78.9,78.9,0,0,1,.62-9.28A6.52,6.52,0,0,0,7,18v0a4,4,0,0,0,1.5,3.11C8,22.13,7.3,23.68,6.89,24.85ZM11,21a3,3,0,0,1-3-3,2.89,2.89,0,0,1,0-.43l0-.57H7.5a5.5,5.5,0,1,1,4.57-2.44L11.75,15l0.53,0.25A3,3,0,0,1,11,21Zm4-3a4,4,0,0,0-1.82-3.35A6.48,6.48,0,0,0,13,8H19a6.48,6.48,0,0,0-.22,6.65A4,4,0,0,0,17,18H15Zm3,0a3,3,0,0,1,1.73-2.71L20.25,15l-0.32-.48A5.5,5.5,0,1,1,24.52,17H23.88L24,17.57A2.89,2.89,0,0,1,24,18,3,3,0,0,1,18,18Zm10.88,8.91a3,3,0,0,1-3.77-2.06C24.7,23.68,24,22.13,23.5,21.11A4,4,0,0,0,25,18v0a6.51,6.51,0,0,0,5.38-3.73A79,79,0,0,1,31,23.53C31,24.87,30.63,26.54,28.88,26.91Z"/><path d="M9,13h2V10H9V8H6v2H4v3H6v2H9V13ZM8,14H7V12H5V11H7V9H8v2h2v1H8v2Z"/><path d="M24.5,10A1.5,1.5,0,1,0,23,8.5,1.5,1.5,0,0,0,24.5,10Zm0-2a0.5,0.5,0,1,1-.5.5A0.5,0.5,0,0,1,24.5,8Z"/><path d="M24.5,16A1.5,1.5,0,1,0,23,14.5,1.5,1.5,0,0,0,24.5,16Zm0-2a0.5,0.5,0,1,1-.5.5A0.5,0.5,0,0,1,24.5,14Z"/><path d="M21.5,13A1.5,1.5,0,1,0,20,11.5,1.5,1.5,0,0,0,21.5,13Zm0-2a0.5,0.5,0,1,1-.5.5A0.5,0.5,0,0,1,21.5,11Z"/><path d="M27.5,13A1.5,1.5,0,1,0,26,11.5,1.5,1.5,0,0,0,27.5,13Zm0-2a0.5,0.5,0,1,1-.5.5A0.5,0.5,0,0,1,27.5,11Z"/><path d="M11,16a2,2,0,1,0,2,2A2,2,0,0,0,11,16Zm0,3a1,1,0,1,1,1-1A1,1,0,0,1,11,19Z"/><path d="M21,16a2,2,0,1,0,2,2A2,2,0,0,0,21,16Zm0,3a1,1,0,1,1,1-1A1,1,0,0,1,21,19Z"/></svg>

Before

Width:  |  Height:  |  Size: 1.8 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

+31
View File
@@ -0,0 +1,31 @@
package game;
import gui.GUI;
public class Control {
private GUI gui;
private int xSize, ySize, cellCount;
public Control(){
gui = new GUI(this);
gui.buildControlWindow();
}
public void buildGameWindow(int xSize, int ySize, int cellCount){
this.xSize = xSize;
this.ySize = ySize;
this.cellCount = cellCount;
gui.buildGameWindow();
}
}
+56 -35
View File
@@ -1,15 +1,17 @@
package gui;
import game.Control;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.*;
public class StartGUI{
public class GUI {
private final Control control;
private JFrame jf;
@@ -22,6 +24,7 @@ public class StartGUI{
private JSlider yAxis;
private JLabel yAxisName;
private JLabel yAxisLabel;
private int cellCount = 6;
private JSlider startCells;
private JLabel startCellsName;
private JLabel startCellsLabel;
@@ -32,13 +35,18 @@ public class StartGUI{
private JButton manuelStart;
public StartGUI(){
public GUI(Control control) {
this.control = control;
}
public void buildControlWindow() {
jf = new JFrame();
jf.setTitle("CT-Conway's Game of Life");
jf.setTitle("Conway's Game of Life");
ImageIcon imageIcon = new ImageIcon("src/data/cotroller.png");
ImageIcon imageIcon = new ImageIcon("src/data/PNG/Icon.png");
jf.setIconImage(imageIcon.getImage());
//getContentPane().setBackground(Color.decode("#121212"));
@@ -49,21 +57,19 @@ public class StartGUI{
jf.setAutoRequestFocus(false);
jf.setLayout(null);
jf.setSize(752, 424);
//jf.getContentPane().setPreferredSize(new Dimension(752, 423));
jf.setResizable(false);
initComponents();
addComponents();
initControlComponents();
addControlComponents();
jf.setLocationRelativeTo(null);
jf.setVisible(true);
}
public void initComponents(){
private void initControlComponents() {
Font head = new Font("Segoe UI Light", Font.PLAIN, 24);
Font text = new Font("Segoe UI Light", Font.PLAIN, 16);
@@ -134,9 +140,6 @@ public class StartGUI{
yAxisLabel.setVisible(true);
startCells = new JSlider(6, 6);
startCells.setBounds(180, 210, 200, 20);
startCells.setFont(text);
@@ -145,8 +148,8 @@ public class StartGUI{
startCells.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int value = startCells.getValue();
updateSliderLables(2, value);
cellCount = startCells.getValue();
updateSliderLables(2, cellCount);
}
});
startCells.setVisible(true);
@@ -170,9 +173,8 @@ public class StartGUI{
public void mouseEntered(MouseEvent e) {
super.mouseEntered(e);
JButton b = (JButton) e.getSource();
b.setContentAreaFilled(true);
b.setBackground(Color.decode("#121212"));
b.setForeground(Color.decode("#F8F8FF"));
b.setForeground(Color.decode("#C40233"));
b.setBounds(b.getX() - 10, b.getY() - 10, b.getWidth() + 20, b.getHeight() + 20);
}
@Override
@@ -180,7 +182,7 @@ public class StartGUI{
super.mouseExited(e);
JButton b = (JButton) e.getSource();
b.setForeground(Color.decode("#121212"));
b.setContentAreaFilled(false);
b.setBounds(b.getX() + 10, b.getY() + 10, b.getWidth() - 20, b.getHeight() - 20);
}
};
@@ -189,42 +191,51 @@ public class StartGUI{
randomStart.setText("Random Start");
randomStart.setFont(text);
randomStart.setForeground(Color.decode("#121212"));
randomStart.setBorderPainted(false);
randomStart.setBorderPainted(true);
randomStart.setFocusPainted(false);
randomStart.setContentAreaFilled(false);
randomStart.setBounds(50, 280, 150, 50);
randomStart.setVisible(true);
randomStart.addMouseListener(hover);
randomStart.setBorder(new RoundedBorder(25));
randomStart.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
control.buildGameWindow(xAxisSize, yAxisSize, cellCount);
}
});
manuelStart = new JButton();
manuelStart.setText("Manuel Start");
manuelStart.setFont(text);
manuelStart.setForeground(Color.decode("#121212"));
manuelStart.setBorderPainted(false);
manuelStart.setBorderPainted(true);
manuelStart.setFocusPainted(false);
manuelStart.setContentAreaFilled(false);
manuelStart.setBounds(225, 280, 150, 50);
manuelStart.setVisible(true);
manuelStart.addMouseListener(hover);
manuelStart.setBorder(new RoundedBorder(25));
manuelStart.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
});
manuelStart.setBounds(225, 280, 150, 50);
Icon gif = new ImageIcon("src/data/control2.png");
JLabel gifLabel = new JLabel(gif);
gifLabel.setBounds(391, 25, 336, 336);
jf.getContentPane().add(gifLabel);
preview = new ImageIcon("src/data/PNG/Preview.png");
previewLabel = new JLabel(preview);
previewLabel.setBounds(450, 45, 203, 302);
}
private void updateStartCells() {
startCells.setMaximum(xAxisSize * yAxisSize);
}
private void updateSliderLables(int slider, int val){
switch (slider){
private void updateSliderLables(int slider, int val) {
switch (slider) {
case 0:
xAxisLabel.setText(String.valueOf(val));
break;
@@ -237,8 +248,7 @@ public class StartGUI{
}
}
public void addComponents(){
private void addControlComponents() {
jf.add(heading);
jf.add(xAxis);
jf.add(xAxisName);
@@ -251,9 +261,20 @@ public class StartGUI{
jf.add(startCellsLabel);
jf.add(randomStart);
jf.add(manuelStart);
jf.add(previewLabel);
}
public void buildGameWindow() {
}
private void initGameComponents() {
}
private void addGameComponents() {
}
}
+29
View File
@@ -0,0 +1,29 @@
package gui;
import javax.swing.border.Border;
import java.awt.*;
public class RoundedBorder implements Border {
private int radius;
RoundedBorder(int radius) {
this.radius = radius;
}
public Insets getBorderInsets(Component c) {
return new Insets(this.radius+1, this.radius+1, this.radius+2, this.radius);
}
public boolean isBorderOpaque() {
return true;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.drawRoundRect(x, y, width-1, height-1, radius, radius);
}
}
+3 -4
View File
@@ -1,13 +1,12 @@
package main;
import gui.GameGUI;
import gui.StartGUI;
import game.Control;
public class Main {
public static void main(String[] args) {
GameGUI gameGUI = new GameGUI();
// StartGUI startGUI = new StartGUI();
Control control = new Control();
}