JOptionPane显示对话框的问题? 如何覆写JOptionPane.showInputDialog()方法,要求此对话的显示位置,可以自定义?!!!还望各位指点! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class YourOptionPane extends JOptionPane{} 因为JOptionPane实际是封装了一系列JDialog的工厂类(暂且这样理解吧),如果你要实现自定义其显示的对话框,你就得自己实现一个JOptionPane,并且自己定义JDialog下面是JOptionPane的源码: public static Object showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue) throws HeadlessException { JOptionPane pane = new JOptionPane(message, messageType, OK_CANCEL_OPTION, icon, null, null); pane.setWantsInput(true); pane.setSelectionValues(selectionValues); pane.setInitialSelectionValue(initialSelectionValue); pane.setComponentOrientation(((parentComponent == null) ? getRootFrame() : parentComponent).getComponentOrientation()); int style = styleFromMessageType(messageType); JDialog dialog = pane.createDialog(parentComponent, title, style);//这儿 pane.selectInitialValue(); dialog.show(); dialog.dispose(); Object value = pane.getInputValue(); if (value == UNINITIALIZED_VALUE) { return null; } return value; } 是设置dialog.setSize(xxx,yyy)就可以吗? java入门表示很困惑 关于sun.net.ftp.FtpClient;的用法 关于synchronized的问题 MyEclipse 生成webservice 错误 怎么解决 帮忙把java代码翻译成c++ 或c#. 急急急 问个关于命令行下运行java程序的问题? 谁能给推荐几本好的,电子版的js书籍!! 郁闷。没办法只能请教了 我想给JTextArea加一个滚动条,为什么不能显示??? 在retrieve()部分! JAVA求学者. 编译后出现问题,请高手指点. 百分求一思路,关于动态加载类库
public static Object showInputDialog(Component parentComponent,
Object message, String title, int messageType, Icon icon,
Object[] selectionValues, Object initialSelectionValue)
throws HeadlessException {
JOptionPane pane = new JOptionPane(message, messageType,
OK_CANCEL_OPTION, icon,
null, null); pane.setWantsInput(true);
pane.setSelectionValues(selectionValues);
pane.setInitialSelectionValue(initialSelectionValue);
pane.setComponentOrientation(((parentComponent == null) ?
getRootFrame() : parentComponent).getComponentOrientation()); int style = styleFromMessageType(messageType);
JDialog dialog = pane.createDialog(parentComponent, title, style);//这儿 pane.selectInitialValue();
dialog.show();
dialog.dispose(); Object value = pane.getInputValue(); if (value == UNINITIALIZED_VALUE) {
return null;
}
return value;
}