Skip to content
Snippets Groups Projects
Commit c234ba5f authored by Andrea Magnussen's avatar Andrea Magnussen
Browse files

Merge branch 'master' into '11-ui-design'

# Conflicts:
#   src/sample/sample.fxml
parents af1e26e7 a126ab9e
No related branches found
No related tags found
1 merge request!14Resolve "UI design"
......@@ -11,18 +11,19 @@ public class Controller {
@FXML
private void handleSubmit() {
System.out.println("Mamma sønn");
String tmp = "";
tmp = textArea.getText();
//create new thought, parameter from textArea
Thought t = new Thought(textArea.getText());
System.out.println(tmp);
//clear textArea
textArea.clear();
//Thought tmpThought = new Thought();
//get the thought manager and add the thought to the manager
ThoughtManager tm = ThoughtManager.getInstance();
tm.add(t);
tm.displayList();
// Button was clicked, do something...
//outputTextArea.appendText("Button Action\n");
}
}
......@@ -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 = new String();
public void makeList()
{
Thought t = new Thought("yeet1");
......@@ -17,4 +34,23 @@ public class ThoughtManager {
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