Skip to content
Snippets Groups Projects
Commit 052a717d authored by Anders Langlie's avatar Anders Langlie :crab:
Browse files

Merge branch '9-displaylist-v3' into 'master'

Resolve "DisplayList v3"

Closes #9

See merge request !12
parents d5ea620c b55f60d0
No related branches found
No related tags found
1 merge request!12Resolve "DisplayList v3"
...@@ -28,11 +28,11 @@ public class Main extends Application { ...@@ -28,11 +28,11 @@ public class Main extends Application {
//get access to the text field: //get access to the text field:
ScrollPane scrollyPlane = (ScrollPane) sceneMain.lookup("#scrollyboi"); ScrollPane scrollyPlane = (ScrollPane) sceneMain.lookup("#scrollyboi");
Node content = scrollyPlane.getContent(); Node content = scrollyPlane.getContent();
Text ta = (Text) content.lookup("#thoughtId"); Text ourTextField = (Text) content.lookup("#thoughtId");
ta.setText("testing"); ThoughtManager tm = ThoughtManager.getInstance();
ThoughtManager tm = new ThoughtManager(); //NOTE! if you reinitalize ThoughtManager it will just change where it will be writing to:
tm.initialize(ourTextField);
tm.makeList(); tm.makeList();
primaryStage.show(); primaryStage.show();
} }
......
package sample; package sample;
import javafx.scene.text.Text;
import java.util.*; import java.util.*;
public class ThoughtManager { 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 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 = "";
public void makeList() public void makeList()
{ {
Thought t = new Thought("yeet1"); Thought t = new Thought("yeet1");
...@@ -17,4 +34,19 @@ public class ThoughtManager { ...@@ -17,4 +34,19 @@ public class ThoughtManager {
this.thoughts.add(t4); this.thoughts.add(t4);
this.thoughts.add(t5); this.thoughts.add(t5);
} }
void initialize(Text text)
{
}
void displayList()
{
this.textfield.setText(this.text);
}
void add(Thought thought)
{
this.thoughts.add(thought);
this.text += thought.getThought() + "\n";
}
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<Text id="thoughtField" layoutX="65.0" layoutY="31.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Your thoughts" /> <Text id="thoughtField" layoutX="65.0" layoutY="31.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Your thoughts" />
<ScrollPane id="scrollyboi" layoutX="1.0" layoutY="40.0" prefHeight="258.0" prefWidth="700.0"> <ScrollPane id="scrollyboi" layoutX="1.0" layoutY="40.0" prefHeight="258.0" prefWidth="700.0">
<content> <content>
<Text id="thoughtId" strokeType="OUTSIDE" strokeWidth="20.0" text="Text" wrappingWidth="33.22460746765137" /> <Text id="thoughtId" strokeType="OUTSIDE" strokeWidth="20.0" wrappingWidth="700" text="Text" />
</content> </content>
</ScrollPane> </ScrollPane>
</children> </children>
......
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