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 アプリケーションで無効な入力のエラー メッセージを表示するタイミング
さまざまなテキスト ボックスに合計 100 の数字を入力するようにユーザーに促す Java GUI を作成する必要があります。
各テキストボックスの上に非表示のラベルを付け、入力されていない場合は表示することができます。
たとえば単純な でステータス メッセージを表示し、JLabel関連するボタンを無効にすることができます。各テキスト フィールド ドキュメントに を追加しDocumentListenerて、編集が行われるたびにステータスを再計算します。(Swing を前提としています - 他のウィンドウ ツールキットが利用可能です。)
JLabel
DocumentListener