Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-05-2008, 07:23 AM
Mir Mir is offline
Senior Member
 
Join Date: Mar 2008
Posts: 447
Mir is on a distinguished road
Unexpected Error
Hi all

I am in big problem.When i run the code every thing is work fine.But when i run exe of this code then i am facing problem.What happen when i click on About Dialog then exe close autometically.All other menu is working..

If any one need my code of About Dialog then i will give..

Plz help me it's a urgent...
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-05-2008, 08:21 AM
Member
 
Join Date: Jul 2008
Posts: 1
khai is on a distinguished road
code
may i see what your code looks like?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-05-2008, 08:28 AM
Mir Mir is offline
Senior Member
 
Join Date: Mar 2008
Posts: 447
Mir is on a distinguished road
Quote:
Originally Posted by khai View Post
may i see what your code looks like?
Thxs for responce

here is code

Code:
package main; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.awt.Color; import java.awt.Cursor; import java.awt.Graphics; import javax.swing.JLabel; /* * * AboutDlg * */ public class AboutDlg extends JDialog implements MouseListener { private String URL = "http://www.yahoo.com"; private String Email = "abc@yahoo.com"; public String getURL() { return URL; } public void setURL(String URL) { this.URL = URL; } public void setEmail(String URL) { this.Email = Email; } public AboutDlg(Frame parent) { super(); JLabel Dru = new JLabel( " Email : abc@yahoo.com" , JLabel.LEFT); JLabel Drw = new JLabel( " http://www.yahoo.com" , JLabel.LEFT); AboutDlg.setDefaultLookAndFeelDecorated(true); this.setURL(URL); Drw.addMouseListener(this); Drw.setCursor(new Cursor(Cursor.HAND_CURSOR)); Drw.setForeground(Color.BLUE); this.setEmail(Email); Dru.addMouseListener(this); Dru.setCursor(new Cursor(Cursor.HAND_CURSOR)); Dru.setForeground(Color.BLUE); Font f3= new Font("Terminal", Font.PLAIN, 12); Dru.setFont(f3); Drw.setFont(f3); setTitle( "About" ) ; setContentPane( new MyPanel() ) ; getContentPane().setLayout(new FlowLayout()); getContentPane().add(Drw ); getContentPane().add(Dru ); getContentPane().add( new Button(" OK ")); setSize( 300 ,225 ) ; Point fatherLocation = parent.location(); move(fatherLocation.x + 150,fatherLocation.y + 200); show(); } public void mouseClicked(MouseEvent e){ try{ String command = "start " + this.URL; Process process = Runtime.getRuntime().exec("cmd /c \"" + command + "\""); //Following line works as it should. Runtime.getRuntime().exec("cmd.exe /c start mailto:abc@yahoo.com"); } catch (Exception exception){ System.out.println("Exception caught : " + exception.getMessage()); } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void paint(Graphics graphis){ super.paint(graphis); graphis.setColor(this.getForeground()); graphis.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight() - 1); } public class MyPanel extends JPanel { private Image img ; public MyPanel() { setLayout( new BorderLayout() ) ; img = new ImageIcon("logod.jpg").getImage() ; if( img == null ) { System.out.println( "Image is null" ); System.exit( 1 ) ; } if( img.getHeight(this) <= 0 || img.getWidth( this ) <= 0 ) { System.out.println( "Image width or height must be +ve" ); System.exit( 2 ) ; } } public void drawBackground( Graphics g ) { int w = getWidth() ; int h = getHeight() ; int iw = img.getWidth( this ) ; int ih = img.getHeight( this ) ; for( int i = 0 ; i < w ; i+=iw ) { for( int j = 0 ; j < h ; j+= ih ) { g.drawImage( img ,0,9 , this ) ; } } } protected void paintComponent(Graphics g) { super.paintComponent(g); Color underline = getForeground(); g.setColor(underline); drawBackground( g ) ; } } public boolean action (Event evt, Object arg) { if (evt.target instanceof Button) { hide(); dispose(); return true; } return false; } private boolean updateDB() { hide(); dispose(); return true; } public boolean handleEvent (Event event) { switch (event.id) { case Event.WINDOW_DESTROY: dispose(); return true; default: return super.handleEvent(event); } } }
Plz help me...
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-05-2008, 01:55 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 421
Nicholas Jordan is on a distinguished road
possible cause
Code:
public boolean action (Event evt, Object arg) { if (evt.target instanceof Button) { hide(); dispose(); return true; } return false; }
If event is button, this closes the app.
__________________
Please provide your feedback on our
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-05-2008, 02:46 PM
Mir Mir is offline
Senior Member
 
Join Date: Mar 2008
Posts: 447
Mir is on a distinguished road
Quote:
Originally Posted by Nicholas Jordan View Post
Code:
public boolean action (Event evt, Object arg) { if (evt.target instanceof Button) { hide(); dispose(); return true; } return false; }
If event is button, this closes the app.
Sir now i use this code

Code:
public boolean action (Event evt, Object arg) { if (evt.target instanceof Button) { if (evt.target == OK) { return updateDB(); } return false; } return false; }

But problem is same.Plz help me to solve it..
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-05-2008, 03:21 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SW MO, USA
Posts: 940
Norm is on a distinguished road
A suggestion to help YOU find your problem:
Add println() statements before any statement that will dispose or exit and see if any of them are being executed.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-05-2008, 03:42 PM
Mir Mir is offline
Senior Member
 
Join Date: Mar 2008
Posts: 447
Mir is on a distinguished road
Quote:
Originally Posted by Norm View Post
A suggestion to help YOU find your problem:
Add println() statements before any statement that will dispose or exit and see if any of them are being executed.
Yes Norm I fiend it

here is last line code is actually executed..

Code:
Dru.setFont(f3); Drw.setFont(f3); JOptionPane.showMessageDialog(null,"HI It is last part to show in this Dialog");
plz help me
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 07-05-2008, 04:05 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SW MO, USA
Posts: 940
Norm is on a distinguished road
Not sure what your problem is now if you've found it? What is it that you have found?

What lines of code follows what you have posted as being
"last line is actually executed"? Those lines sound like they could be important, but you left them off your post.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 07-07-2008, 07:12 AM
Mir Mir is offline
Senior Member
 
Join Date: Mar 2008
Posts: 447
Mir is on a distinguished road
Quote:
Originally Posted by Norm View Post
Not sure what your problem is now if you've found it? What is it that you have found?

What lines of code follows what you have posted as being
"last line is actually executed"? Those lines sound like they could be important, but you left them off your post.
ok here i full line code

Code:
public AboutDlg(Frame parent) { super(); JLabel Dru = new JLabel( " Email : abc@yahoo.com" , JLabel.LEFT); JLabel Drw = new JLabel( " http://www.yahoo.com" , JLabel.LEFT); AboutDlg.setDefaultLookAndFeelDecorated(true); this.setURL(URL); Drw.addMouseListener(this); Drw.setCursor(new Cursor(Cursor.HAND_CURSOR)); Drw.setForeground(Color.BLUE); this.setEmail(Email); Dru.addMouseListener(this); Dru.setCursor(new Cursor(Cursor.HAND_CURSOR)); Dru.setForeground(Color.BLUE); Font f3= new Font("Terminal", Font.PLAIN, 12); Dru.setFont(f3); Drw.setFont(f3); // JOptionPane.showMessageDialog(null,"HI It is last part to show in this Dialog"); here the last line for execute the code.. setTitle( "About" ) ; setContentPane( new MyPanel() ) ; getContentPane().setLayout(new FlowLayout()); getContentPane().add(Drw ); getContentPane().add(Dru ); getContentPane().add( new Button(" OK ")); setSize( 300 ,225 ) ; Point fatherLocation = parent.location(); move(fatherLocation.x + 150,fatherLocation.y + 200); show(); } public void mouseClicked(MouseEvent e){ try{ String command = "start " + this.URL; Process process = Runtime.getRuntime().exec("cmd /c \"" + command + "\""); //Following line works as it should. Runtime.getRuntime().exec("cmd.exe /c start mailto:abc@yahoo.com"); } catch (Exception exception){ System.out.println("Exception caught : " + exception.getMessage()); } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void paint(Graphics graphis){ super.paint(graphis); graphis.setColor(this.getForeground()); graphis.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight() - 1); } public class MyPanel extends JPanel { private Image img ; public MyPanel() { setLayout( new BorderLayout() ) ; img = new ImageIcon("logod.jpg").getImage() ; if( img == null ) { System.out.println( "Image is null" ); System.exit( 1 ) ; } if( img.getHeight(this) <= 0 || img.getWidth( this ) <= 0 ) { System.out.println( "Image width or height must be +ve" ); System.exit( 2 ) ; } } public void drawBackground( Graphics g ) { int w = getWidth() ; int h = getHeight() ; int iw = img.getWidth( this ) ; int ih = img.getHeight( this ) ; for( int i = 0 ; i < w ; i+=iw ) { for( int j = 0 ; j < h ; j+= ih ) { g.drawImage( img ,0,9 , this ) ; } } } protected void paintComponent(Graphics g) { super.paintComponent(g); Color underline = getForeground(); g.setColor(underline); drawBackground( g ) ; } } public boolean action (Event evt, Object arg) { if (evt.target instanceof Button) { hide(); dispose(); return true; } return false; } private boolean updateDB() { hide(); dispose(); return true; } public boolean handleEvent (Event event) { switch (event.id) { case Event.WINDOW_DESTROY: dispose(); return true; default: return super.handleEvent(event); } } }
JOptionPane.showMessageDialog(null,"HI It is last part to show in this Dialog");
plz help me
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 07-07-2008, 07:20 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 421
Nicholas Jordan is on a distinguished road
handleEvent not switching on type of event
Quote:
Originally Posted by Mir View Post
(...snip...)What happen when i click on About Dialog then exe close autometically.All other menu is working..
Norm, what is happening here is that window events and other events are processed in code by a mix of sub-typing ( class a instance of class b )? true/false and a java construct called a switch. A switch is an effective code construct for having the compiler create a jump table.

Poster has:
Code:
public boolean handleEvent (Event event) { switch (event.id) { case Event.WINDOW_DESTROY: dispose(); return true; default: return super.handleEvent(event); } }
Okay, sounds good but due to using event id, we should look at the value of Event.WINDOW_DESTROY as it should not be but may be numeric equivalent of some other class that is shipping an event to the code here.

At least that is what it sounds like, based on poster's original description:
Quote:
when i click on About Dialog then exe close autometically.
Above that, code shows:
Code:
if (evt.target instanceof Button)
Which also ( with logic that follows ) closes the window.

Code:
public void mouseClicked(MouseEvent e){
would process a mouse event to launch URL, but that is not shown in code.

This project needs additional work disentangling event processing logic.
__________________
Please provide your feedback on our
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 07-07-2008, 08:57 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SW MO, USA
Posts: 940
Norm is on a distinguished road
In the code you've posted I don't see any println() statements where there are possiblities of your program changing what is displayed. Ie before all dispose() statements.
If you'd put these in your code, you might see what is happening.
You need to do some work yourself to find your problem!!!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
An unexpected error has been detected by HotSpot Virtual Machine: 82rathi.angara Networking 2 06-14-2008 02:23 PM
error 530 error authentication required rgale JavaServer Pages (JSP) and JSTL 0 05-12-2008 05:28 PM
Error: unexpected type silvia New To Java 1 08-07-2007 06:41 AM
An unexpected jumper bug on my IO code? cruxblack New To Java 7 07-29-2007 09:24 AM


All times are GMT +3. The time now is 10:01 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org