Skip to content

Commit 4002d50

Browse files
committed
good
1 parent feccc48 commit 4002d50

4 files changed

Lines changed: 165 additions & 9 deletions

File tree

‎JavaFX Practice/nologo.jpg‎

18.5 KB
Loading

‎JavaFX Practice/src/practice14/Tabscollation/Template.fxml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<?import javafx.scene.shape.Line?>
99
<?import javafx.scene.text.Font?>
1010

11-
<AnchorPane xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="practice14.Tabscollation.TemplateController">
11+
<AnchorPane xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="practice14.Tabscollation.TemplateControlSingle">
1212
<children>
1313
<ImageView fitHeight="548.0" fitWidth="662.0" layoutY="-14.0" pickOnBounds="true" preserveRatio="true">
1414
<image>
@@ -24,7 +24,7 @@
2424
<Line endX="200.0" layoutX="260.0" layoutY="70.0" startX="-100.0" stroke="WHITE" strokeWidth="3.0" />
2525
<ScrollPane fx:id="scrollPane" layoutX="16.0" layoutY="89.0" prefHeight="401.0" prefWidth="612.0">
2626
<content>
27-
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="200.0" prefWidth="200.0" />
27+
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="383.0" prefWidth="535.0" style="-fx-background-color: green;" />
2828
</content>
2929
</ScrollPane>
3030
</children>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package practice14.Tabscollation;
2+
3+
import javafx.fxml.FXML;
4+
import javafx.geometry.HPos;
5+
import javafx.geometry.Insets;
6+
import javafx.scene.control.Label;
7+
import javafx.scene.control.ScrollPane;
8+
import javafx.scene.image.Image;
9+
import javafx.scene.image.ImageView;
10+
import javafx.scene.layout.ColumnConstraints;
11+
import javafx.scene.layout.GridPane;
12+
import javafx.scene.text.Font;
13+
14+
public class TemplateControlSingle {
15+
@FXML
16+
private ScrollPane scrollPane;
17+
18+
public void initialize() {
19+
20+
GridPane grid = new GridPane();
21+
grid.setPadding(new Insets(25));
22+
grid.setHgap(5);
23+
grid.setVgap(5);
24+
25+
ColumnConstraints column1 = new ColumnConstraints(50); // fixed for labels
26+
ColumnConstraints column2 = new ColumnConstraints(130); // min,pref,max
27+
ColumnConstraints column3 = new ColumnConstraints(100);
28+
ColumnConstraints column4 = new ColumnConstraints(130);
29+
ColumnConstraints column5 = new ColumnConstraints(100);
30+
31+
grid.getColumnConstraints().addAll(column1, column2,column3,column4,column5);
32+
33+
Image image = new Image("file:nologo.jpg");
34+
ImageView img1 = new ImageView(image);
35+
img1.setFitWidth(108);
36+
img1.setFitHeight(65);
37+
img1.setPreserveRatio(true);
38+
39+
Image image2 = new Image("file:nologo.jpg");
40+
ImageView img6 = new ImageView(image2);
41+
img6.setFitWidth(308);
42+
img6.setFitHeight(365);
43+
img6.setPreserveRatio(true);
44+
45+
Label label1 = new Label("Name");
46+
Label label2 = new Label("VS");
47+
Label label3 = new Label("Name");
48+
ImageView img2 = new ImageView(image);
49+
img2.setFitWidth(108);
50+
img2.setFitHeight(65);
51+
img2.setPreserveRatio(true);
52+
/*
53+
Label group = new Label("Group1");
54+
group.setFont(Font.font("Arial", 20));
55+
grid.add(group, 0, 0);
56+
GridPane.setColumnSpan(group, 4);
57+
GridPane.setHalignment(group, HPos.CENTER);
58+
group.styleProperty();
59+
String backgroundStyle =
60+
"-fx-background-color: lightblue;";
61+
62+
group.setStyle(backgroundStyle);*/
63+
grid.add(img1, 0, 1);
64+
grid.add(label1, 1, 1);
65+
GridPane.setHalignment(label1, HPos.CENTER);
66+
grid.add(label2, 2, 1);
67+
grid.add(label3, 3, 1);
68+
grid.add(img2, 4, 1);
69+
70+
grid.add(new Label("Name"), 0, 2);
71+
/*grid.add(label1, 1, 1);
72+
//GridPane.setHalignment(label1, HPos.CENTER);
73+
grid.add(label2, 2, 1);
74+
grid.add(label3, 3, 1);
75+
grid.add(img2, 4, 1);*/
76+
77+
78+
/*HBox box = new HBox(5);
79+
80+
81+
Button btn = new Button("Click Me");
82+
btn.setOnAction(e->{
83+
FileChooser fc = new FileChooser();
84+
fc.setInitialDirectory(new File("C:\\Users\\Chinedu\\Pictures"));
85+
File file3 = fc.showOpenDialog(null);
86+
// for the image
87+
if (file3 != null) {
88+
String localUrl = null;
89+
try {
90+
localUrl = file3.toURI().toURL().toString();
91+
} catch (MalformedURLException e1) {
92+
// TODO Auto-generated catch block
93+
e1.printStackTrace();
94+
}
95+
Image localImage = new Image(localUrl, false);
96+
img2.setImage(localImage);
97+
}
98+
});
99+
100+
String localUrl = file4.toURI().toURL().toString();
101+
Image localImage = new Image(localUrl, false);
102+
imgArray.get(3).setImage(localImage);
103+
104+
box.getChildren().addAll(img1,label1,label2,label3,img2,btn);*/
105+
scrollPane.setContent(grid);
106+
}
107+
108+
}
Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,67 @@
11
package practice14.Tabscollation;
22

33
import javafx.fxml.FXML;
4-
import javafx.scene.control.Button;
4+
import javafx.geometry.HPos;
5+
import javafx.geometry.Insets;
6+
import javafx.scene.control.Label;
57
import javafx.scene.control.ScrollPane;
6-
import javafx.scene.layout.VBox;
8+
import javafx.scene.image.Image;
9+
import javafx.scene.image.ImageView;
10+
import javafx.scene.layout.ColumnConstraints;
11+
import javafx.scene.layout.GridPane;
12+
import javafx.scene.text.Font;
713

814
public class TemplateController {
915
@FXML
1016
private ScrollPane scrollPane;
11-
17+
private int row;
18+
private int col;
19+
1220
public void initialize() {
13-
VBox box = new VBox(5);
14-
Button btn = new Button("Chinedu");
15-
box.getChildren().add(btn);
16-
//scrollPane.add
21+
// GridPane settings
22+
GridPane grid = new GridPane();
23+
grid.setPadding(new Insets(25));
24+
grid.setHgap(5);
25+
grid.setVgap(5);
26+
// ColumnSettings for all five columns
27+
ColumnConstraints column1 = new ColumnConstraints(70); // fixed for labels
28+
ColumnConstraints column2 = new ColumnConstraints(130); // min,pref,max
29+
ColumnConstraints column3 = new ColumnConstraints(100);
30+
ColumnConstraints column4 = new ColumnConstraints(130);
31+
ColumnConstraints column5 = new ColumnConstraints(100);
32+
33+
grid.getColumnConstraints().addAll(column1, column2, column3, column4, column5);
34+
// Variable Delarations
35+
36+
Image image = new Image("file:nologo.jpg");
37+
ImageView logo[] = new ImageView[20];
38+
Label playerName[] = new Label[20];
39+
Label VS[] = new Label[10];
40+
41+
// initialize testing
42+
for (int i = 0; i < logo.length; i++) {
43+
logo[i] = new ImageView(image);
44+
//logo[i].setImage(image);
45+
logo[i].setFitWidth(108);
46+
logo[i].setFitHeight(65);
47+
logo[i].setPreserveRatio(true);
48+
playerName[i] = new Label();
49+
playerName[i].setText("Player " + i);
50+
if (i < 9)
51+
VS[i]= new Label("VS");
52+
//VS[i].setText();
53+
}
54+
55+
int c = 0;
56+
for (int i = 0; i < 9; i++) {
57+
grid.add(logo[c], 0, i);
58+
grid.add(playerName[c], 1, i);
59+
grid.add(VS[i], 2, i);
60+
grid.add(playerName[c + 1], 3, i);
61+
grid.add(logo[c + 1], 4, i);
62+
c += 2;
63+
}
64+
scrollPane.setContent(grid);
1765
}
1866

1967
}

0 commit comments

Comments
 (0)