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:
Binary file not shown.
@@ -27,6 +27,8 @@ public class ControlWindow {
|
||||
private JButton jump2GenButton;
|
||||
private JTextField multipleGenSkipLable;
|
||||
private JTextField jump2GenLable;
|
||||
private JTextField saveGrid;
|
||||
private JLabel saveGridPlaceholder;
|
||||
|
||||
private int velocity, minVelocity = 1 , maxVelocity = 5000;
|
||||
|
||||
@@ -87,6 +89,7 @@ public class ControlWindow {
|
||||
initClearButton();
|
||||
initMultibleGenSkip();
|
||||
initJump2Gen();
|
||||
initSaveGrid();
|
||||
}
|
||||
|
||||
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(){
|
||||
controlWindow.add(heading);
|
||||
@@ -390,6 +427,8 @@ public class ControlWindow {
|
||||
controlWindow.add(jump2GenLable);
|
||||
controlWindow.add(multipleGenSkipButton);
|
||||
controlWindow.add(jump2GenButton);
|
||||
controlWindow.add(saveGridPlaceholder);
|
||||
controlWindow.add(saveGrid);
|
||||
}
|
||||
|
||||
public void setVisibility(boolean value) {
|
||||
|
||||
@@ -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
@@ -5,9 +5,18 @@ import game.Control;
|
||||
|
||||
public class Main {
|
||||
|
||||
//TODO: Inputfield witch Changelistner to cange Slider, Generic ActionListener.
|
||||
//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
|
||||
//TODO: Database Seve Button. Alert when Name is already is taken.
|
||||
//TODO: Database window to Delete Entries.
|
||||
//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.
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user