Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ユーザーがテキストを入力したときにアクションを実行する Swing JTextPane を作成したいと考えています。しかし、その変更をユーザーの入力として扱わずに、そのペイン内のテキストを変更できるようにしたいと考えています。これどうやってするの?
更新イベントを発生させないと、実際の実装によっては、UI も更新されない可能性があります。したがって、次の変更がプログラムによる変更になることをイベント ハンドラーに知らせて、イベント ハンドラーと対話する方がよいことに同意します。このようなもの:
try { listener.setProgrammaticChange(true); // change document } finally { listener.setProgrammaticChange(false); }