Parent & Child window issues......
Hello friends,,,,
I am very new to java. Parent window is having on command button if i click that button i am doing some operation in action performed method...... The operations are ........ open a child window and next statement invoke a
simple function of child window in parent window........ the issue is when i invoke a child window method it will seconds to complete. meanwhile child window shows blank page it means Hang........ upto when the goes to end.....
pls help me how to solve this problem........ Sorry my poor english..... i have given the code.....
Parent.java
import java.awt.*;
public class Send extends javax.swing.JFrame {
Child d;
public Send() {
initComponents();
// d=new Child(new javax.swing.JFrame(),false);
}
private void initComponents() {//GEN-BEGIN:initComponents
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jLabel1.setText("jLabel1");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 60, -1, -1));
jLabel2.setText("jLabel2");
getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 60, -1, -1));
jButton1.setText("Open New Window");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 110, -1, -1));
pack();
}//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// Add your handling code here:
this.setVisible(false);
//System.out.println("Child form event :"+d.getComponents()Graphics());
d=new Child(new javax.swing.JFrame(),true,1000);
if(d.send()==false)
{
}
//d.dispose();
System.out.println("Child form event :"+d.getGraphics());
}//GEN-LAST:event_jButton1ActionPerformed
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
System.exit(0);
}//GEN-LAST:event_exitForm
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new Send().show();
}
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JButton jButton1;
}
child.java
import java.awt.*;
public class Child extends javax.swing.JDialog {
/** Creates new form Child */
Send d=new Send();
public Child(java.awt.Frame parent, boolean modal,int n) {
super(parent, modal);
m=n;
initComponents();
send();
this.show();
}
private void initComponents() {//GEN-BEGIN:initComponents
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
count = new javax.swing.JLabel();
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
jLabel1.setText("welcome ");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 30, -1, -1));
jLabel2.setText("no");
getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 100, -1, -1));
count.setText(" ");
getContentPane().add(count, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 100, -1, -1));
pack();
}//GEN-END:initComponents
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
setVisible(false);
dispose();
}//GEN-LAST:event_closeDialog
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new Child(new javax.swing.JFrame(), true,0).show();
}
int m;
public boolean send()
{
// this.setCo
this.setVisible(true);
System.out.println("MVALUE :"+m);
try{
for (int i=0;i<=m;i++)
{
count.setText(String.valueOf(i));
System.out.println("MVALUE :"+i);
// Thread.sleep(1000);
}
d.show();
}catch(Exception e)
{
e.printStackTrace();
}
return false;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel count;
// End of variables declaration//GEN-END:variables
}