2012-06-26 21 views
13

Tôi chỉ cần có một nút trong showConfirmDialog.JOptionPane showConfirmDialog chỉ với một nút

Tôi cố gắng này:

int response = JOptionPane.showConfirmDialog(null, "Time Entered Successfully", 
        "", JOptionPane.OK_OPTION, JOptionPane.PLAIN_MESSAGE); 

if (response == JOptionPane.CLOSED_OPTION || response == JOptionPane.OK_OPTION) 
{ 
    System.out.println("CLOSING>>>>>>"); 
} 

Nhưng điều này cho thấy hộp thoại với Yes_No_option.

Tôi chỉ muốn nút OK được hiển thị ở đó. Có thể không?

Trả lời

17

Tôi chỉ muốn nút OK được hiển thị ở đó. Có thể không?

Sử dụng phương thức showOptionDialog().

Object[] options = {"OK"}; 
    int n = JOptionPane.showOptionDialog(frame, 
        "Message here ","Title", 
        JOptionPane.PLAIN_MESSAGE, 
        JOptionPane.QUESTION_MESSAGE, 
        null, 
        options, 
        options[0]); 
+0

ok ốm hãy u biết –

+0

nhờ mà làm việc .. :) –

20

hãy thử sử dụng này, nó tạo ra chỉ có một nút

JOptionPane.showMessageDialog(null, "Loading Complete...!!!"); 
+0

Làm việc hoàn hảo, cảm ơn bạn – AMB

8

Đó là JOptionPane.DEFAULT_OPTION

JOptionPane.showConfirmDialog(null, 
       "MESSAGE", 
       "TITLE", 
       JOptionPane.DEFAULT_OPTION, 
       JOptionPane.PLAIN_MESSAGE); 
Các vấn đề liên quan