Skip to content
Snippets Groups Projects
Commit cfad1b44 authored by Läspä Vili Valtteri's avatar Läspä Vili Valtteri
Browse files

Liikkeiden näyttäminen

parent 25bb4870
No related branches found
No related tags found
No related merge requests found
package fxPuntti;
import java.io.PrintStream;
import java.net.URL;
import java.util.ResourceBundle;
import fi.jyu.mit.fxgui.Dialogs;
import fi.jyu.mit.fxgui.ListChooser;
import fi.jyu.mit.fxgui.ModalController;
import fi.jyu.mit.fxgui.TextAreaOutputStream;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.text.Font;
import puntti.Liike;
import puntti.Puntti;
import puntti.SailoException;
......@@ -21,6 +26,7 @@ import puntti.SailoException;
public class PunttiGUIController implements Initializable{
@FXML private ListChooser<Liike> chooserLiikkeet;
@FXML private ScrollPane panelLiike;
......@@ -68,10 +74,28 @@ public class PunttiGUIController implements Initializable{
* puntti mitä käytetään
*/
private Puntti puntti;
private TextArea areaLiike = new TextArea(); //Poista lopuksi
private void alusta() {
chooserLiikkeet.clear();
chooserLiikkeet.addSelectionListener(e -> naytaLiike());
panelLiike.setContent(areaLiike);
areaLiike.setFont(new Font("Arial", 12));
panelLiike.setFitToHeight(true);
}
private void naytaLiike() {
Liike liikeKohdalla = chooserLiikkeet.getSelectedObject();
if (liikeKohdalla == null) return;
areaLiike.setText("");
try(PrintStream os = TextAreaOutputStream.getTextPrintStream(areaLiike)){
liikeKohdalla.tulosta(os);
}
}
private void lueTiedosto(@SuppressWarnings("unused") String nimi) {
......
......@@ -80,7 +80,7 @@
<items>
<BorderPane>
<center>
<ScrollPane fitToWidth="true" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<ScrollPane fx:id = "panelLiike" fitToWidth="true" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<content>
<GridPane hgap="10.0">
<columnConstraints>
......
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