• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how can we use addAncestorListener in JOptionpan

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends

my problem is

i should the Joptionpane such that i when i click OK then i should write a ACTIONLISTENER such that it should

remove the frame on which this JOpti.... is there

so i have seen this "addAncestorListener" so can i any tell how can i acheive or and where or other way i can get the task..

but i have to use the Joptionpane only that the main proble..

bye
and thank you very much...
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
not sure if I'm reading the problem right, but see is this is close to
what you're trying to do.

 
sudhakar ananth
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no see actually my code is like this....
where i have a JOprionPane inside in JDialog... and i use timer concept

so that if the user is not clicking the OK button then it should automatically go off

so i need the code for on OK button see this is code..

code:

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class timy extends JFrame {
timy t;
JOptionPane jp;
JDialog jd;
public timy()
{
t = this;
System.out.println("this is the OVER(f)");
jd =new JDialog(t, "there is something wrong in the stations",false);
jd.setAlwaysOnTop(true);
jd.setBounds(50, 50, 500, 100);
JLabel jl = new JLabel("there is something wrong in the stations");
JOptionPane jp1 = new JOptionPane();


jd.add(jl);
jd.add(jp1);
jd.show();

java.util.Timer timer = new java.util.Timer();


java.util.TimerTask task = new java.util.TimerTask() {
public void run() {
jd.dispose();
}
};

timer.schedule(task,1000);
}
public void cal()
{

this.show();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
this.setSize(400, 400);
this.setVisible(true);


}
public static void main(String[] args) {
timyt = new timy();
t.cal();
}

}
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
see if this is any closer

reply
    Bookmark Topic Watch Topic
  • New Topic