Eclipse 4.4ではじめる Javaプログラミング入門 Eclipse 4.4 Luna対応

グラフィック・ファイルアクセス・スレッド・日付/テキスト処理 - ファイルアクセスについて

Icon comment count 0
Icon stock count 0

4.2.2Reader/Writerを利用する

ではこれらのクラスを使ってテキストファイルにアクセスするサンプルを作成しながら、具体的な処理の仕方を見ていくことにします。例によって第3章で作成したMyFXAppプロジェクトを書き換えて利用することにしましょう。

まずは、FXMLファイルでGUIを作成します。以下のように変更してください(<? import ?>タグは新規追加するもの以外省略します)。

リスト4.15 window.fxml(書き換える部分)
<BorderPane prefHeight="200.0" prefWidth="300.0" fx:id="border"
  xmlns="http://javafx.com/javafx/8" 
  xmlns:fx="http://javafx.com/fxml/1"
  fx:controller="jp.tuyano.eclipsebook.WindowController">
  <center>
    <TextArea fx:id="ta" />
  </center>
  <bottom>
    <HBox alignment="CENTER">
      <Button fx:id="b1" text="Load" onAction="#doAction" />
      <Button fx:id="b2" text="Save" onAction="#doAction" />
    </HBox>
  </bottom>
</BorderPane>

今回

コメント

    コメントはありません