Topic: applet中调用JDialog的问题 |
Print this page |
1.applet中调用JDialog的问题 | Copy to clipboard |
Posted by: cgd_60802 Posted on: 2005-04-07 11:19 class TestDialog extends JDialog{ public LoadingDialog(JFrame owner){ super(owner,"Loading....", false); Container contentPane = this.getContentPane(); JLabel dialogLabel = new JLabel(); dialogLabel.setText("fsdf"); contentPane.add(dialogLabel,BorderLayout.CENTER); setSize(250,150); } } 在applet中调用如下: ld= new TestDialog(null); ld.setVisible(true); |
2.Re:applet中调用JDialog的问题 [Re: cgd_60802] | Copy to clipboard |
Posted by: 九佰 Posted on: 2005-04-08 10:55 是这样的: 这个方法要求applet完全显示出来才能调用。 就是说,在applet初始化完毕之前是不能调用的。 public JFrame getParentWindow(Component compOnApplet){ Container c = compOnApplet.getParent(); while (c != null) { if (c instanceof JFrame) return (JFrame) c; c = c.getParent(); } return null; } 你可以把这个方法放在一个button里面测试一下。 这个方法要放在某个组件的事件里面调用才行。 不知道我说明了没有。 |
3.Re:applet中调用JDialog的问题 [Re: cgd_60802] | Copy to clipboard |
Posted by: cgd_60802 Posted on: 2005-04-08 11:49 LoadingDialog是我自己写的继承JDialog的一个Dialog类,下面的是我实例化。 private void jbInit() throws Exception { ....... void jLabel1_mousePressed(MouseEvent e) throws SQLException { ..... 我不知该怎么调用你写的这个方法。 loadingDialog = new LoadingDialog(new JFrame()); ...... } public JFrame getParentWindow(Component compOnApplet){ Container c = compOnApplet.getParent(); while (c != null) { if (c instanceof JFrame) return (JFrame) c; c = c.getParent(); } return null; } ... private LoadingDialog loadingDialog; private JFrame cgd; } class LoadingDialog extends JDialog{ public LoadingDialog(JFrame dialogOwner){ super(dialogOwner,"Loading....", false); Container contentPane = this.getContentPane(); JLabel dialogLabel = new JLabel(); dialogLabel.setText("fsdf"); contentPane.add(dialogLabel,BorderLayout.CENTER); setSize(250,150); } } |
4.Re:applet中调用JDialog的问题 [Re: cgd_60802] | Copy to clipboard |
Posted by: 九佰 Posted on: 2005-04-08 12:37 loadingDialog = new LoadingDialog(getParentWindow(this)); class LoadingDialog extends JDialog{ public LoadingDialog(JFrame dialogOwner){ super(dialogOwner,"Loading....", false); Container contentPane = this.getContentPane(); JLabel dialogLabel = new JLabel(); dialogLabel.setText("fsdf"); contentPane.add(dialogLabel,BorderLayout.CENTER); setSize(250,150); } |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |