質問編集履歴

1

ソースコードの追加

2019/01/09 03:12

投稿

YM_anoahiro
YM_anoahiro

スコア21

test CHANGED
File without changes
test CHANGED
@@ -7,3 +7,179 @@
7
7
 
8
8
 
9
9
  がちがちの初心者なのでoracleのサイトだけ載せていただいても理解するのが難しいためどのように書けばいいか教えて頂けると幸いです。
10
+
11
+
12
+
13
+ ```java
14
+
15
+ import javafx.application.Application;
16
+
17
+ import javafx.geometry.Insets;
18
+
19
+ import javafx.scene.Scene;
20
+
21
+ import javafx.scene.control.*;
22
+
23
+ import javafx.scene.layout.*;
24
+
25
+ import javafx.stage.Stage;
26
+
27
+ import javafx.scene.paint.Color;
28
+
29
+ import javafx.scene.text.Font;
30
+
31
+ import java.awt.Dimension;
32
+
33
+ import javafx.scene.control.TextArea;
34
+
35
+ import java.util.*;
36
+
37
+
38
+
39
+ public class pp extends Application {
40
+
41
+ Label l1, l2,l3; // ラベル
42
+
43
+ TextField tx1, tx2; // テキストフィールド
44
+
45
+ Button start, buttonSub, buttonMul, buttonDiv, buttonMod, bC; // ボタン
46
+
47
+ TextArea textArea,ta2; // テキストエリア
48
+
49
+ ChoiceBox<String> cb;//チョイスボックス
50
+
51
+ RadioButton rb1,rb2,rb3;//ラジオボタン
52
+
53
+ ToggleGroup ping;
54
+
55
+ int num1, num2;
56
+
57
+
58
+
59
+ public void start(Stage stage) {
60
+
61
+ stage.setWidth(1100);
62
+
63
+ stage.setHeight(700);
64
+
65
+
66
+
67
+
68
+
69
+ l1 = new Label("pingコマンドデモ");
70
+
71
+ l1.setFont(new Font(40));
72
+
73
+ //label1.setTextFill(Color.RED);色の設定
74
+
75
+
76
+
77
+ l2 = new Label("コマンド選択してください");
78
+
79
+
80
+
81
+ //cb =new ChoiceBox<>();
82
+
83
+ //cb.getItems().addAll("コマンドを入力してください。","ping 10.100.3.0","ping 192.168.10.1");
84
+
85
+ //cb.setValue("コマンドを入力してください。");
86
+
87
+
88
+
89
+ rb1=new RadioButton("ping 10.40.83.63");//自分のPC
90
+
91
+ rb2=new RadioButton("ping www.yahoo.co.jp");//www.yahoo.co.jpに応答確認した場合
92
+
93
+ rb3=new RadioButton("ping www.columbia.edu");//www.columbia.eduに応答確認した場合
94
+
95
+ ping=new ToggleGroup();
96
+
97
+ rb1.setToggleGroup(ping);
98
+
99
+ rb2.setToggleGroup(ping);
100
+
101
+ rb3.setToggleGroup(ping);
102
+
103
+ rb1.setSelected(true);
104
+
105
+
106
+
107
+
108
+
109
+ bC = new Button("Clear");
110
+
111
+ bC.setOnAction(event -> buttonClearPressed());
112
+
113
+ start = new Button("実行");
114
+
115
+ start.setOnAction(event -> buttonStartPressed());
116
+
117
+
118
+
119
+ textArea = new TextArea("実行結果が表示されます。\nC:¥Users¥f17K6○○○>");
120
+
121
+ textArea.setStyle("-fx-text-fill: white;-fx-font-size: 16;");
122
+
123
+ ta2=new TextArea("解説");
124
+
125
+ ta2.setWidth(200);
126
+
127
+
128
+
129
+
130
+
131
+ HBox hbox = new HBox(5);
132
+
133
+ hbox.getChildren().addAll(start,bC);
134
+
135
+
136
+
137
+ VBox vbox = new VBox(5);
138
+
139
+ vbox.setPadding(new Insets(20, 25, 25, 25));
140
+
141
+ vbox.getChildren().addAll(l1,l2,rb1,rb2,rb3,hbox);
142
+
143
+
144
+
145
+ BorderPane root = new BorderPane();
146
+
147
+ root.setLeft(vbox);
148
+
149
+ root.setCenter(ta2);
150
+
151
+ root.setRight(textArea);
152
+
153
+ stage.setScene(new Scene(root));
154
+
155
+ stage.show();
156
+
157
+ textArea.lookup(".content").setStyle("-fx-background-color: black;");//色の変更
158
+
159
+ }
160
+
161
+
162
+
163
+ void buttonClearPressed() {
164
+
165
+ textArea.clear();
166
+
167
+ textArea.setText("実行結果が表示されます。\nC:¥Users¥f17K6○○○>");
168
+
169
+ }
170
+
171
+ void buttonStartPressed(){
172
+
173
+ ~略~
174
+
175
+ }
176
+
177
+ public static void main(String[] args) {
178
+
179
+ launch();
180
+
181
+ }
182
+
183
+ }
184
+
185
+ ```