iPhoneのデスクトップで動作するJavaアプリ
一応、動作しました。
元ネタはid:masuidriveさんのThinkITの記事です。
アイコンの「めも」はボクの手書きです(照)
実行環境は下記です。
ソースはこんな感じ。
import static joc.Static.NO; import static joc.Static.YES; import joc.Message; import obc.CGRect; import obc.CGSize; import obc.NSMutableString; import obc.NSNotification; import obc.NSString; import obc.UIApplication; import obc.UIHardware; import obc.UIKeyboard; import obc.UITextView; import obc.UIView; import obc.UIWindow; public class TextEditor extends UIApplication { private UIWindow window; private UITextView textView; @Message public void applicationDidFinishLaunching$(NSNotification unused) throws Exception { CGRect screenRect = UIHardware.$fullScreenApplicationContentRect(); window = new UIWindow().initWithContentRect$(screenRect); window.orderFront$(this); window.makeKey$(this); window._setHidden$(NO); // 使ってなくない? // CGRect mainRect = UIHardware.$fullScreenApplicationContentRect(); UIView mainView = new UIView().initWithFrame$(screenRect); CGSize keyboardSize = UIKeyboard.$defaultSize(); textView = new UITextView().initWithFrame$(new CGRect(0, 0, screenRect.size.width, screenRect.size.height)); textView.setEditable$(YES); // メソッドが見当たらん・・・ // textView.setTextSize$(14); UIKeyboard keyboard = new UIKeyboard().initWithFrame$(new CGRect(0, screenRect.size.height - keyboardSize.height, screenRect.size.width, keyboardSize.height)); keyboard.setHidden$(YES); window.setContentView$(mainView); mainView.addSubview$(textView); mainView.addSubview$(keyboard); textView.setText$(NSMutableString .$stringWithContentsOfFile$encoding$error$("/var/tmp/memo.txt", 4, null)); } @Message public void applicationWillTerminate$(NSNotification pointer) throws Exception { ((NSString) textView.text()).writeToFile$atomically$encoding$error$( "/var/tmp/memo.txt", NO, 4, null); } }
TODOとしてはapplicationWillTerminateが呼ばれてないっぽくてメモを書いても保存できないです。
というかイベントハンドラをいろいろと書いてみたのですがなかなか呼びだしてくれません。
これだったら素直にObjective-Cを勉強したほうがいいのかな。。。