Maybe this will help. Create an instance of the new window in the class which is calling the other class.
Class A{
//the constructor of this class creates a window
}
Class B{
private mouseClicked (MouseEvent evt)
{
A newWindow = new A();
newWindow.setVisible;
}
}
I guess u are more confused now :D
Hi dude check this code
import javax.swing.*;
import java.awt.event.*;
class Test10 extends JFrame
{
private javax.swing.JButton press = null ;
private javax.swing.JPanel mainPane;
Test10()
{
press = new javax.swing.JButton("Press");
mainPane = new JPanel();
mainPane.add(press);
press.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
doTestBtnAction();
}
});
}
private void createGUI()
{
getContentPane().add(mainPane);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//setSize(,400);
pack();
setVisible(true);
}
private static void createAndShowGUI()
{
Test10 tt = new Test10();
tt.createGUI();
}
private void doTestBtnAction()
{
System.out.println("Test");
new CallWindow();
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
createAndShowGUI();
}
});
}
}
class CallWindow
{
CallWindow()
{
JFrame jf = new JFrame();
jf.setVisible(true);
jf.setSize(200,200);
}
}
Thanks ,
Sb