|
@@ -1,6 +1,7 @@
|
|
|
package ui.view;
|
|
|
|
|
|
import ui.controller.Control;
|
|
|
+import ui.controller.SingletonControl;
|
|
|
import ui.model.Model;
|
|
|
|
|
|
import javax.swing.*;
|
|
@@ -39,6 +40,7 @@ public class TimePanel extends JPanel implements ActionListener{
|
|
|
private final JPanel timeBtnPanel = new JPanel();
|
|
|
private final JPanel iterationsPanel=new JPanel();
|
|
|
private final JPanel timePanel=new JPanel();
|
|
|
+ private LabelHint iterationsLblHint;
|
|
|
JSlider timeSlider = new JSlider() {
|
|
|
/**
|
|
|
*
|
|
@@ -275,9 +277,29 @@ public class TimePanel extends JPanel implements ActionListener{
|
|
|
btnAndSpeedPanel.add(speedPanel, BorderLayout.CENTER);
|
|
|
iterationsPanel.setLayout(new GridLayout(3,1));
|
|
|
iterationsPanel.add(iterationsLabel, BorderLayout.NORTH);
|
|
|
+ iterationsLblHint=new LabelHint(iterationsLabel);
|
|
|
iterationsField=new JTextField(6);//Considering hundreds of thousands in an extreme case
|
|
|
iterationsField.setText(""+cont.getModel().getIterations());
|
|
|
iterationsField.addActionListener(this);
|
|
|
+ iterationsField.addCaretListener((e)->
|
|
|
+ {
|
|
|
+ try{
|
|
|
+ int a=Integer.parseInt(iterationsField.getText());
|
|
|
+ iterationsField.setBackground(Color.WHITE);//red stings
|
|
|
+ if(
|
|
|
+ a!=
|
|
|
+ SingletonControl
|
|
|
+ .getInstance()
|
|
|
+ .getControl()
|
|
|
+ .getModel()
|
|
|
+ .getIterations()
|
|
|
+ )iterationsLblHint.go("Press ENTER");
|
|
|
+ }catch(NumberFormatException n){
|
|
|
+ iterationsLblHint.go("Invalid");
|
|
|
+ iterationsField.setBackground(GUI.PALE_RED);//red stings
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
iterationsPanel.add(iterationsField);
|
|
|
iterationsPanel.add(new JLabel(), BorderLayout.SOUTH);
|
|
|
timePanel.setLayout(new BorderLayout());
|
|
@@ -334,6 +356,7 @@ public class TimePanel extends JPanel implements ActionListener{
|
|
|
public void actionPerformed(ActionEvent arg0) {//I dislike anon classes.
|
|
|
try{
|
|
|
int iterations=Integer.parseInt(iterationsField.getText());
|
|
|
+ iterationsLblHint.reset();
|
|
|
boolean resetField=true;
|
|
|
if(iterations<1)iterations=1;
|
|
|
else if(iterations>MAX_ITERATIONS)iterations=MAX_ITERATIONS;
|
|
@@ -345,8 +368,6 @@ public class TimePanel extends JPanel implements ActionListener{
|
|
|
timeSlider.setMajorTickSpacing((int)Math.ceil(((double)controller.getModel().getIterations())/20));
|
|
|
timeSlider.setMinorTickSpacing((int)Math.ceil(((double)controller.getModel().getIterations())/100));//Even though the final mark can't actually be reached.
|
|
|
parentGUI.updateIterations();//First one in the chain
|
|
|
- }catch(NumberFormatException e){
|
|
|
-
|
|
|
- }
|
|
|
+ }catch(NumberFormatException e){}
|
|
|
}
|
|
|
}
|