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 {
//get access to the text field:
ScrollPane scrollyPlane = (ScrollPane) sceneMain.lookup("#scrollyboi");
Node content = scrollyPlane.getContent();
Text ta = (Text) content.lookup("#thoughtId");
ta.setText("testing");
ThoughtManager tm = new ThoughtManager();
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();
}
......
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 = "";
public void makeList()
{
Thought t = new Thought("yeet1");
......@@ -17,4 +34,19 @@ public class ThoughtManager {
this.thoughts.add(t4);
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 @@
<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">
<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>
</ScrollPane>
</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