NotifyDescriptorを使用してポップアップダイアログボックスを作成する方法を学びました。 PURCHASE
とCASHOUT
という2つの大きなボタンを持つJPanelを設計しました。私が使用したコードは、Yes
とNo
の2つのボタンが表示されています。私はNotifyDescriptorが画面上に独自のボタンを置くことを望みません。私のボタンがそこにあるようにしたいのですが、私のカスタムボタンがクリックされたときにポップアップが閉じて値を保存するようにしてください(yes
またはno
をクリックしたときのウィンドウの閉じ方と同じです)。あなたはもう少しコントロールが必要な場合は、あなたが渡すことができ、options
引数にString[]
に渡したりすることができますいずれかoptions
ボタンのテキストを置き換えるためにNetbeansプラットフォームでカスタムNotifyDescriptorを使用する
// Create instance of your panel, extends JPanel... ChooseTransactionType popupSelector = new ChooseTransactionType(); // Create a custom NotifyDescriptor, specify the panel instance as a parameter + other params NotifyDescriptor nd = new NotifyDescriptor( popupSelector, // instance of your panel "Title", // title of the dialog NotifyDescriptor.YES_NO_OPTION, // it is Yes/No dialog ... NotifyDescriptor.QUESTION_MESSAGE, // ... of a question type => a question mark icon null, // we have specified YES_NO_OPTION => can be null, options specified by L&F, // otherwise specify options as: // new Object[] { NotifyDescriptor.YES_OPTION, ... etc. }, NotifyDescriptor.YES_OPTION // default option is "Yes" ); // let's display the dialog now... if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.YES_OPTION) { // user clicked yes, do something here, for example: System.out.println(popupSelector.getTRANSACTION_TYPE()); }
優秀!!これは私が探していたものです..それに感謝!! – Deepak
あなたの歓迎と幸運 –