Contol Windwo Update. Velocity Change implemented. FONT and some other Var and method needs to be implemented in the GUI class not in Menu Window

Update
This commit is contained in:
Noah Kessinger
2021-12-02 12:45:28 +01:00
parent 962e4efe61
commit e1c6b1cffc
4 changed files with 80 additions and 5 deletions
Binary file not shown.
+41 -2
View File
@@ -27,6 +27,8 @@ public class ControlWindow {
private JButton jump2GenButton; private JButton jump2GenButton;
private JTextField multipleGenSkipLable; private JTextField multipleGenSkipLable;
private JTextField jump2GenLable; private JTextField jump2GenLable;
private JTextField saveGrid;
private JLabel saveGridPlaceholder;
private int velocity, minVelocity = 1 , maxVelocity = 5000; private int velocity, minVelocity = 1 , maxVelocity = 5000;
@@ -87,6 +89,7 @@ public class ControlWindow {
initClearButton(); initClearButton();
initMultibleGenSkip(); initMultibleGenSkip();
initJump2Gen(); initJump2Gen();
initSaveGrid();
} }
private void initHeading(){ private void initHeading(){
@@ -372,9 +375,43 @@ public class ControlWindow {
}); });
} }
private void initSaveButton(){} private void initSaveGrid(){
private void initSaveNameField(){} saveGridPlaceholder = new JLabel("Save Grid...");
saveGridPlaceholder.setBounds(50, 300, 300, 50);
saveGridPlaceholder.setFont(text);
saveGridPlaceholder.setForeground(Color.decode("#121212"));
saveGridPlaceholder.setVisible(true);
saveGrid = new JTextField();
saveGrid.setDocument(new JTextFieldLimit(10));
saveGrid.setOpaque(false);
saveGrid.setBackground(null);
saveGrid.setBorder(null);
saveGrid.setBounds(50, 300, 300, 50);
saveGrid.setFont(text);
saveGrid.setForeground(Color.decode("#121212"));
saveGrid.setVisible(true);
saveGrid.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent evt) {
if (!(Character.isDigit(evt.getKeyChar()) || Character.isLetter(evt.getKeyChar()))) {
evt.consume();
}
}
});
saveGrid.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
saveGridPlaceholder.setVisible(false);
}
@Override
public void focusLost(FocusEvent e) {
saveGridPlaceholder.setVisible(true);
}
});
}
private void addComponents(){ private void addComponents(){
controlWindow.add(heading); controlWindow.add(heading);
@@ -390,6 +427,8 @@ public class ControlWindow {
controlWindow.add(jump2GenLable); controlWindow.add(jump2GenLable);
controlWindow.add(multipleGenSkipButton); controlWindow.add(multipleGenSkipButton);
controlWindow.add(jump2GenButton); controlWindow.add(jump2GenButton);
controlWindow.add(saveGridPlaceholder);
controlWindow.add(saveGrid);
} }
public void setVisibility(boolean value) { public void setVisibility(boolean value) {
+27
View File
@@ -0,0 +1,27 @@
package gui;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
class JTextFieldLimit extends PlainDocument {
private int limit;
JTextFieldLimit(int limit) {
super();
this.limit = limit;
}
JTextFieldLimit(int limit, boolean upper) {
super();
this.limit = limit;
}
public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException {
if (str == null)
return;
if ((getLength() + str.length()) <= limit) {
super.insertString(offset, str, attr);
}
}
}
+12 -3
View File
@@ -5,9 +5,18 @@ import game.Control;
public class Main { public class Main {
//TODO: Inputfield witch Changelistner to cange Slider, Generic ActionListener. //TODO: Database Seve Button. Alert when Name is already is taken.
//TODO: Window visibility, Control window create only one time. Visibility = false when game started, Visibility = true when game quited. :DONE Need a code Check when Brain is awake. //TODO: Database window to Delete Entries.
//TODO: Database //TODO: Save Velocity in DB
//TODO: Correct generation saving in DB and read out it
//TODO: Save button
//TODO: Reset game state when closing game
//TODO: Correct new Initialisation when game starts
//TODO: Change the population Rules
//TODO: Limit input length
//TODO: Implement Corona Virus. Infected, Vaccinated, Recovered and Normal
//TODO: Implement a war mode.