All Classes Namespaces Files Functions Variables
EditPanel.java
Go to the documentation of this file.
1 package fi.jyu.mit.fxgui;
2 
3 import java.io.IOException;
4 
5 import javafx.fxml.FXML;
6 import javafx.fxml.FXMLLoader;
7 import javafx.scene.control.Label;
8 import javafx.scene.control.TextField;
9 import javafx.scene.layout.AnchorPane;
10 
11 public class EditPanel extends AnchorPane {
12 
13  private final String resourcePath = "EditPanel.fxml";
14 
15  @FXML private Label label;
16  @FXML private TextField edit;
17 
18  public EditPanel() {
19  /*
20  FXMLLoader loader = new FXMLLoader();
21 
22  loader.setController(this);
23  URL n = this.getViewURL();
24  loader.setLocation(n);
25 
26  try {
27  Node root = (Node) loader.load();
28  this.getChildren().add(root);
29  }
30  catch (IOException ex) {
31  throw new RuntimeException(ex);
32  }
33  */
34  super();
35  FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(resourcePath));
36  fxmlLoader.setRoot(this);
37  fxmlLoader.setController(this);
38  try {
39  fxmlLoader.load();
40  } catch (IOException exception) {
41  throw new RuntimeException(exception);
42  }
43  }
44 
45 
46  public String getText() {
47  return edit.getText();
48  }
49 
50 
51  public void setText(String t) {
52  edit.setText(t);
53  }
54 
55  public TextField getEdit() {
56  return edit;
57  }
58 
59  public void setEdit(TextField edit) {
60  this.edit = edit;
61  }
62 
63  public double getLabelWidth() {
64  return AnchorPane.getLeftAnchor(edit);
65  }
66 
67  public void setLabelWidth(double w) {
68  AnchorPane.setLeftAnchor(edit,w);
69  }
70 
71 }