This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Multiple javaw.exe instances created while creating swing components  RSS feed

 
Smitha Bhat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to create new swing components like Jcalendar of my
own and when i try to create a sample application which is using that
swing component, when i try to run that sample application multiple
instances of javaw.exe are being created and the system gets hanged.

Why is this happening and how to solve this? Kindly help me ASAP.

Thanks,
Smitha
 
Sachin Dimble
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Smitha!
It should not create multiple instances of java.exe. could you through some code over here to understand what you have done excatly. I think you are doing some simple mistake in your code itself.

Regards,
Saaaaaaachin!!!
 
Jonathan Janisch
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Smitha, you have to either:

1) myjframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

or

2) add a window listener to the frame and System.exit on window close.

If you do not do this the java/javaw process will never terminate.
 
Smitha Bhat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please find the sample code. The sample code uses the swing component which i have created. After adding the last line the javaw instances are being closed. But whether its necessary that everytime i run this code the javaw.exe instance should be created. This is my doubt.

Sample Code:

JFrame frame = new JFrame("FileUpload Demo");

//Instantiating my own swing component
FileUploadDemo app = new FileUploadDemo();


Component cont = app.createComponent();
frame.getContentPane().add(cont, BorderLayout.CENTER);


frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);

//Added after your comment - Its working
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!