脚本是这样的(在JDialog中写)
W_Test w_test = new W_Test();
w_test.jButton4.setEnabled(false);
w_test.jLabel1.setText("TEST");

解决方案 »

  1.   

    import javax.swing.*;
    import java.awt.event.*;public class JDialogTest extends JFrame
    implements ActionListener
    { JPanel jp = new JPanel();
    JButton jb = new JButton("button");
    AButtonDialog ad = new AButtonDialog(this);
    public JDialogTest(){
    setSize(400,300);
    jb.addActionListener(this);
    ad.jb1.addActionListener(this);
    jp.add(jb);
    getContentPane().add(jp);
    }
    public void actionPerformed(ActionEvent e){
    Object source = e.getSource();
    if (source==jb)
    ad.show();
    if(source==ad.jb1)
    jb.setEnabled(false);//是jb失效
    }
    public static void main(String[] args){
    JDialogTest jdt = new JDialogTest();
    jdt.show();
    }
    }
    class AButtonDialog extends JDialog{
    JButton jb1 = new JButton("Disable the button");
    JPanel jp1 = new JPanel();
    public AButtonDialog(JFrame parent){
    super(parent,"AButtonDialog");
    jp1.add(jb1);
    setSize(300,200);
    getContentPane().add(jp1);
    }
    }
      

  2.   

    我想你在打开新窗口的时候把JFrame作为构造函数的参数,
    这样可以通过JFrame修改本生组件的属性.
    public JDialog(Frame owner,
                   String title,
                   boolean modal)