JOptionPane.showInputDialog与Eclipse的其余部分风格相同



所以我试图让对话框与Eclipse的其余部分具有相同的样式。按下菜单上的按钮时,将触发此输入。这是我现在的代码,但对话框看起来与 null 而不是(组件)获胜作为参数相同。

    // JFrame frame = new JFrame ("Something");
    IWorkbench wb = PlatformUI.getWorkbench();
    IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
    while (b != true) {
         userInput = (String) JOptionPane.showInputDialog((Component) win, "Entersomething", "GDB Server Connection Port:", JOptionPane.DEFAULT_OPTION, null,null,2345);
            if (userInput != null && userInput.matches("[0-9]+")) {
                b = true; }
            else {
                JOptionPane.showMessageDialog(Component) win, "Please enter valid input","Error",JOptionPane.WARNING_MESSAGE);
            }
    }
    return userInput ;

使用 LookAndFeel 在整个应用程序中具有相同的样式:

 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

编辑:

然后看看这个:

http://www.programcreek.com/java-api-examples/index.php?api=org.eclipse.swt.widgets.MessageBox

http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/DialogExamples.htm

http://www.vogella.com/tutorials/EclipseDialogs/article.html

最新更新