質問編集履歴
2
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -204,4 +204,4 @@
|
|
204
204
|
|
205
205
|
---
|
206
206
|
|
207
|
-
(追記)すいません。違うソースコードを上げてしまいました。
|
207
|
+
(追記)すいません。違うソースコードを上げてしまいました。アップしたのでよろしくお願いします。
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
+
|
10
|
+
|
9
11
|
package rensyuuyou;
|
10
12
|
|
11
13
|
|
@@ -48,6 +50,8 @@
|
|
48
50
|
|
49
51
|
|
50
52
|
|
53
|
+
|
54
|
+
|
51
55
|
public class Rensyuuyou extends Application {
|
52
56
|
|
53
57
|
|
@@ -70,112 +74,112 @@
|
|
70
74
|
|
71
75
|
stage.setHeight(1000);
|
72
76
|
|
73
|
-
|
77
|
+
|
74
78
|
|
75
79
|
Button botan = new Button("画像表示");
|
76
80
|
|
77
81
|
botan.setPrefSize(900, 30);
|
78
82
|
|
83
|
+
botan.setOnAction(new EventHandler<ActionEvent>() {
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
@Override
|
88
|
+
|
89
|
+
public void handle(ActionEvent event) {
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
FileChooser fileChooser = new FileChooser();
|
94
|
+
|
95
|
+
fileChooser.setTitle("画像を開く");
|
96
|
+
|
97
|
+
fileChooser.getExtensionFilters().addAll(
|
98
|
+
|
99
|
+
new FileChooser.ExtensionFilter("イメージファイル", "*.jpg", "*.png"));
|
100
|
+
|
101
|
+
File file = fileChooser.showOpenDialog(stage);
|
102
|
+
|
103
|
+
filepath = file.getAbsolutePath();
|
104
|
+
|
105
|
+
/*
|
106
|
+
|
107
|
+
画像を表示する
|
108
|
+
|
109
|
+
*/
|
110
|
+
|
111
|
+
FileInputStream fis = null;
|
112
|
+
|
113
|
+
try{
|
114
|
+
|
115
|
+
fis = new FileInputStream(filepath);
|
116
|
+
|
117
|
+
}catch(IOException e){
|
118
|
+
|
119
|
+
Alert keikoku = new Alert(Alert.AlertType.ERROR);
|
120
|
+
|
121
|
+
keikoku.setContentText("ファイルが読み込めません");
|
122
|
+
|
123
|
+
|
124
|
+
|
79
125
|
|
80
126
|
|
81
|
-
botan.setOnAction(new EventHandler<ActionEvent>() {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
127
|
+
}finally{
|
86
|
-
|
87
|
-
|
128
|
+
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
FileChooser fileChooser = new FileChooser();
|
94
|
-
|
95
|
-
fileChooser.setTitle("画像を開く");
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
129
|
+
if(fis != null){
|
100
|
-
|
130
|
+
|
101
|
-
try{
|
131
|
+
try {
|
102
|
-
|
132
|
+
|
103
|
-
|
133
|
+
fis.close();
|
104
|
-
|
134
|
+
|
105
|
-
}catch(
|
135
|
+
} catch (Exception e) {
|
136
|
+
|
106
|
-
|
137
|
+
}
|
138
|
+
|
107
|
-
|
139
|
+
}
|
140
|
+
|
108
|
-
|
141
|
+
}
|
142
|
+
|
143
|
+
Image image = new Image(fis);
|
144
|
+
|
109
|
-
|
145
|
+
ImageView imageView = new ImageView(image);
|
110
|
-
|
146
|
+
|
111
|
-
|
147
|
+
imageView.setFitHeight(500);
|
148
|
+
|
112
|
-
|
149
|
+
imageView.setFitWidth(1000);
|
113
|
-
|
114
150
|
|
115
151
|
|
116
152
|
|
117
|
-
}finally{
|
118
|
-
|
119
|
-
i
|
153
|
+
imageBox.setAlignment(Pos.TOP_CENTER);
|
120
|
-
|
121
|
-
|
154
|
+
|
122
|
-
|
123
|
-
|
155
|
+
imageBox.setPadding(new Insets(40, 40, 40, 40));
|
124
|
-
|
156
|
+
|
125
|
-
|
157
|
+
imageBox.getChildren().addAll(imageView);
|
126
|
-
|
127
|
-
|
158
|
+
|
128
|
-
|
129
|
-
|
159
|
+
|
130
160
|
|
131
161
|
}
|
132
162
|
|
133
|
-
Image image = new Image(fis);
|
134
|
-
|
135
|
-
ImageView imageView = new ImageView(image);
|
136
|
-
|
137
|
-
imageView.setFitHeight(500);
|
138
|
-
|
139
|
-
imageView.setFitWidth(1000);
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
imageBox.setAlignment(Pos.TOP_CENTER);
|
146
|
-
|
147
|
-
imageBox.setPadding(new Insets(40, 40, 40, 40));
|
148
|
-
|
149
|
-
imageBox.getChildren().addAll(imageView);
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
163
|
});
|
156
164
|
|
165
|
+
VBox hyouji = new VBox();
|
166
|
+
|
167
|
+
hyouji.setAlignment(Pos.CENTER);
|
168
|
+
|
169
|
+
hyouji.setPadding(new Insets(30, 30, 30, 30));
|
170
|
+
|
171
|
+
hyouji.getChildren().addAll(imageBox,botan);
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
stage.setScene(new Scene(hyouji));
|
176
|
+
|
177
|
+
stage.show();
|
178
|
+
|
179
|
+
|
180
|
+
|
157
181
|
|
158
182
|
|
159
|
-
|
160
|
-
|
161
|
-
VBox hyouji = new VBox();
|
162
|
-
|
163
|
-
hyouji.setAlignment(Pos.CENTER);
|
164
|
-
|
165
|
-
hyouji.setPadding(new Insets(30, 30, 30, 30));
|
166
|
-
|
167
|
-
hyouji.getChildren().addAll(imageBox,botan);
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
stage.setScene(new Scene(hyouji));
|
172
|
-
|
173
|
-
stage.show();
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
183
|
|
180
184
|
|
181
185
|
}
|
@@ -194,4 +198,10 @@
|
|
194
198
|
|
195
199
|
|
196
200
|
|
201
|
+
|
202
|
+
|
197
203
|
```
|
204
|
+
|
205
|
+
---
|
206
|
+
|
207
|
+
(追記)すいません。違うソースコードを上げてしまいました。すいません。
|