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.
各 JButton にも番号または ID を関連付けたいと思います。そのため、JButton クラスを拡張してクラス SuperJButton を作成することにしました。
このボタンがクリックされたときに生成されるアクションイベントに id/number の値を含めて、このアクションに応答するクラスが id にアクセスできるようにするにはどうすればよいですか?
Action イベントを変更する必要はありません。
SuperJButton jButton = (SuperJButton) actionEvent.getSource(); jButton.getId() jButton.getNumber()
観点からMVC:JButtonは でありview、JButtonクラスは のようなものに適した場所ではありませんid。id のはるかに適切な場所は、独自のButtonModel実装です。
MVC
JButton
view
id
ButtonModel
routes.rb ファイルに次のコードがあります。
resources :users do member do get :following,:followers end collection do put :activate_email end end