Skip to content
Snippets Groups Projects
Commit ac7cbeae authored by Herman Andersen Dyrkorn's avatar Herman Andersen Dyrkorn
Browse files

Merge branch '17-cleanup' into 'master'

Resolve "cleanup"

Closes #17

See merge request !21
parents de12997b de3be45e
No related branches found
No related tags found
1 merge request!21Resolve "cleanup"
package sample; package sample;
import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode; import javafx.scene.control.SelectionMode;
......
...@@ -23,16 +23,6 @@ public class Main extends Application { ...@@ -23,16 +23,6 @@ public class Main extends Application {
Scene sceneMain = new Scene(root, 700, 498); Scene sceneMain = new Scene(root, 700, 498);
primaryStage.setScene(sceneMain); primaryStage.setScene(sceneMain);
//get access to the text field:
ScrollPane scrollyPlane = (ScrollPane) sceneMain.lookup("#scrollyboi");
Node content = scrollyPlane.getContent();
Text ourTextField = (Text) content.lookup("#thoughtId");
ThoughtManager tm = ThoughtManager.getInstance();
//NOTE! if you reinitalize ThoughtManager it will just change where it will be writing to:
tm.initialize(ourTextField);
tm.makeList();
primaryStage.show(); primaryStage.show();
} }
......
package sample;
import javafx.scene.text.Text;
import java.util.*;
public class ThoughtManager {
//Making it a singleton:
private static final ThoughtManager INSTANCE = new ThoughtManager();
private ThoughtManager() {}
public static ThoughtManager getInstance()
{
return INSTANCE;
}
//Singleton done.
//VARIABLES:
private List<Thought> thoughts = new ArrayList<>();
private Text textfield;
//string NOTE! veit ikke om vi burde gjøre detta for i veit ikke ka man kan gjøre:
private String text = new String();
public void makeList()
{
Thought t = new Thought("yeet1");
Thought t2 = new Thought("yeet12");
Thought t3 = new Thought("yeet3");
Thought t4 = new Thought("yeet4");
Thought t5 = new Thought("yeet5");
this.thoughts.add(t);
this.thoughts.add(t2);
this.thoughts.add(t3);
this.thoughts.add(t4);
this.thoughts.add(t5);
}
void initialize(Text text)
{
this.textfield = text;
}
void displayList()
{
this.textfield.setText(this.text);
}
void add(Thought thought)
{
this.thoughts.add(thought);
this.text += thought.getThought() + "\n";
}
void hurl()
{
this.text = "";
this.thoughts.clear();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment