Cof*_*ble 6 java swing jdialog joptionpane
我已经看到这可以在其他类型的对话框窗口中使用,例如"showConfirmDialog",其中可以指定按钮的数量及其名称; 但使用"showInputDialog"时是否可以实现相同的功能?我似乎无法在API中找到这种类型的东西.也许我只是错过了它,但任何帮助都表示赞赏.
Eng*_*uad 16
只需将自定义JPanel添加为消息JOptionPane.showOptionDialog():

String[] options = {"OK"};
JPanel panel = new JPanel();
JLabel lbl = new JLabel("Enter Your name: ");
JTextField txt = new JTextField(10);
panel.add(lbl);
panel.add(txt);
int selectedOption = JOptionPane.showOptionDialog(null, panel, "The Title", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
if(selectedOption == 0)
{
String text = txt.getText();
// ...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24045 次 |
| 最近记录: |