package Ġexample Ċ Ċ import Ġjava . awt .* Ġ// Ġk tl int - disable Ġno - wildcard - imports Ċ import Ġjava . awt . event . Focus Event Ċ import Ġjava . awt . event . Focus Listener Ċ import Ġjavax . swing .* Ġ// Ġk tl int - disable Ġno - wildcard - imports Ċ Ċ fun Ġmake UI (): ĠComponent Ġ{ ĊĠ Ġval Ġfield 1 Ġ= ĠJTextField (" 0 1 2 3 4 5 6 7 8 9 0 ") ĊĠ Ġfield 1 . add Focus Listener ( Background Focus Listener ( Color ( 0 xE 6 _ E 6 _ FF ))) ĊĊĠ Ġval Ġfield 2 Ġ= ĠJTextField () ĊĠ Ġfield 2 . add Focus Listener ( Background Focus Listener ( Color ( 0 xFF _ FF _ E 6 ))) ĊĊĠ Ġval Ġfield 3 Ġ= ĠJTextField (" 1 2 3 4 6 5 7 8 9 7 3 5 ") ĊĠ Ġfield 3 . add Focus Listener ( Background Focus Listener ( Color ( 0 xFF _ E 6 _ E 6 ))) ĊĊĠ Ġval Ġbox Ġ= ĠBox . create Vertical Box (). also Ġ{ ĊĠĠĠ Ġit . add ( make Title d Panel (" Color ( 2 3 0 , Ġ 2 3 0 , Ġ 2 5 5 )", Ġfield 1 )) ĊĠĠĠ Ġit . add ( Box . create Vertical Str ut ( 5 )) ĊĠĠĠ Ġit . add ( make Title d Panel (" Color ( 2 5 5 , Ġ 2 5 5 , Ġ 2 3 0 )", Ġfield 2 )) ĊĠĠĠ Ġit . add ( Box . create Vertical Str ut ( 5 )) ĊĠĠĠ Ġit . add ( make Title d Panel (" Color ( 2 5 5 , Ġ 2 3 0 , Ġ 2 3 0 )", Ġfield 3 )) ĊĠĠĠ Ġit . border Ġ= ĠBorder Factory . create Empty Border ( 5 , Ġ 5 , Ġ 5 , Ġ 5 ) ĊĠ Ġ} ĊĊĠ Ġreturn ĠJPanel ( Border Layout ()). also Ġ{ ĊĠĠĠ Ġit . add ( box , ĠBorderLayout . NORTH ) ĊĠĠĠ Ġit . preferred Size Ġ= ĠDimension ( 3 2 0 , Ġ 2 4 0 ) ĊĠ Ġ} Ċ } Ċ Ċ private Ġfun Ġmake Title d Panel ( title : ĠString , Ġc : ĠComponent ) Ġ= ĠJPanel ( Border Layout ()). also Ġ{ ĊĠ Ġit . border Ġ= ĠBorder Factory . create Title d Border ( title ) ĊĠ Ġit . add ( c ) Ċ } Ċ Ċ private Ġclass ĠBackground Focus Listener ( private Ġval Ġcolor : ĠColor ) Ġ: ĠFocus Listener Ġ{ ĊĠ Ġoverride Ġfun Ġfocus G ained ( e : ĠFocus Event ) Ġ{ ĊĠĠĠ Ġe . component . background Ġ= Ġcolor ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġfocus Lost ( e : ĠFocus Event ) Ġ{ ĊĠĠĠ Ġe . component . background Ġ= ĠUI Manager . getColor (" TextField . background ") ĊĠ Ġ} Ċ } Ċ Ċ fun Ġmain () Ġ{ ĊĠ ĠEvent Queue . invoke Later Ġ{ ĊĠĠĠ Ġrun Catch ing Ġ{ ĊĠĠĠĠĠ ĠUI Manager . set Look And Feel ( UI Manager . getSystem Look And Feel ClassName ()) ĊĠĠĠ Ġ}. on Failure Ġ{ ĊĠĠĠĠĠ Ġit . printStackTrace () ĊĠĠĠĠĠ ĠToolkit . getDefault Toolkit (). be ep () ĊĠĠĠ Ġ} ĊĠĠĠ ĠJ Frame (). apply Ġ{ ĊĠĠĠĠĠ Ġdefault Close Operation Ġ= ĠWindow Constants . EXIT _ ON _ CLOSE ĊĠĠĠĠĠ Ġcontent Pane . add ( make UI ()) ĊĠĠĠĠĠ Ġpack () ĊĠĠĠĠĠ Ġset Location Relative To ( null ) ĊĠĠĠĠĠ Ġis Visible Ġ= Ġtrue ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ