NotifyDescriptor를 사용하여 팝업 대화 상자를 만드는 방법을 배웠습니다. PURCHASE
및 CASHOUT
을 읽는 두 개의 큰 버튼이있는 JPanel을 디자인했으며 사용했던 코드는 Yes
및 No
이라는 하단에 다른 두 개의 버튼을 표시하고 있습니다. NotifyDescriptor가 화면에 자신의 단추를 넣고 싶지 않습니다. 버튼을 닫고 팝업을 닫고 내 맞춤 버튼 중 하나를 클릭하면 값을 저장합니다. (yes
또는 no
을 클릭했을 때 창을 닫는 방법과 동일합니다.) 당신은 당신이 좀 더 컨트롤을 필요로하는 경우, 당신은에서 통과 할 수는 options
인수에 대한 String[]
에 전달하거나 할 수 있습니다 중 하나 options
버튼의 텍스트를 대체하기 위해Netbeans 플랫폼의 Custom 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
환영과 행운을 빕니다. –