Jump to content

i have a problem please help me!!!????

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1
stack

stack

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
Hi,
i have a problem with the following code.. the problem is: if i run the java applet window and if I click in it in the first time ,the JOptionPane window appear one time and if i click OK button ,the JOptionPane window Disappear..
If i click in the java applet window in the second time ,the JOptionPane window appear and if i click OK button the JOptionPane window appers again and if i click OK button the JOptionPane window Disappear..and So On with third ,fourth.....etc times. the the JOptionPane window appears with Increase in each time!!!

if i delete setSize(900,600),the problem disappear !!!!
i can't delete the setSize method, because i need this size pleaze..

How can I solve this problem?????:confused:
import javax.swing.JApplet;
import javax.swing.JOptionPane;
import java.awt.Graphics;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseMotionListener;
import java.awt.Color;

public class HH extends JApplet
{
 public void init(){

setSize(900,600); //<< Here is the reason of the problem

}

 public void paint(Graphics g){

   addMouseListener(
    new MouseAdapter()
	 {
	 
	 	public void mouseClicked( MouseEvent event)
		{
			
	    
			
		      JOptionPane.showMessageDialog( null, "Welcome ", 
         "welcome##",JOptionPane.INFORMATION_MESSAGE  );

								

		}//end of mouseClicked


	 }// end anonymous inner class
	 );// end call to addMouseListener

}

}


#2
stack

stack

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
do you have a solution to my problem???
i need a help please....

#3
stack

stack

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
please help me,,
it is not possible that all java applet window must be in the same size!!! ... i want to know how to solve Recurrence problem for JOptionPane window !!!
i want the JOptionPane window appear one time if i click in the java applet window at any time...

#4
stack

stack

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
where are you???!!!

Is there is any thing which is Incomprehensible in my Expression??

#5
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
There is no need to excessively bump your posts. When someone who knows the answer reads your post, it will get answered, until then be patient.

stack said:

where are you???!!!

Is there is any thing which is Incomprehensible in my Expression??

And since you asked, your excessive use of punctuation where it is unneeded, and your ill-use of punctuation where it is needed does make your posts rather incomprehensible.

Moreover, after four posts in a row, I am still unclear of what you are exactly asking, if you can, ask your question in a single sentence and make it as clear as possible.

#6
stack

stack

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
i'm very sorry ,but i'm very worry...
run my code and you will know the problem

#7
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I'll add my interpretation:
You have a button you press to open a "pop up"
When you press it, it creates a pop-up window with a message, which you close.
When you press it again, it creates 2 pop-ups
when you press it again, it creates 3 pop-ups
etc.

It's supposed to create 1 pop-up each time.

My thought is that each button press creates, but does not destroy a popup. As a result, when you "show" a popup the second time, it shows BOTH existing popups.

I don't know Java well enough to know if this is what's actually happening, but that's my theory.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#8
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
If you click the Applet window, the Dialog box will appear, if you click the Applet window again, the Applet is the window that is focused and it dialog box is behind the applet, if you move the applet window / resize it, you will still see the dialog box.

From what I see, there is nothing wrong with your code, it does exactly what you have coded it to do.

#9
CSJavaGuy

CSJavaGuy

    Newbie

  • Members
  • Pip
  • 4 posts
I agree from what I see, there is nothing wrong with your code, it does exactly what you have coded it to do.

#10
script

script

    Newbie

  • Members
  • Pip
  • 2 posts
What is it you are trying to make? Your writing is unreadable...
So if you need help try and use your commas like this (Hi, how are you) not Hi ,how are you.)
-S

#11
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
Okey, first of all. I have never used extends JApplet before. Don't know what it is or what it does. With some 'googleing' i changed a few things to your code.

Result: i think it runs as you want it to run.
What changed? the white background from the screen is now grey.

Code:
import javax.swing.*;
import java.awt.Graphics;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseMotionListener;
import java.awt.Color;


public class HH extends JApplet
{
    public void init(){

    setSize(900,600); //<< Here is the reason of the problem

}

     public HH(){
    
       addMouseListener(
        new MouseAdapter()
         {

            public void mouseClicked( MouseEvent event)
            {



                  JOptionPane.showMessageDialog( null, "Welcome ",
             "welcome##",JOptionPane.INFORMATION_MESSAGE  );



            }//end of mouseClicked


         }// end anonymous inner class
         );// end call to addMouseListener

    }

}

Changed public void paint into a constructor with no parameters to get to this.
Maybe this helped you, or maybe it didn't :001_unsure: but it sure works ;)

Edited by wim DC, 26 May 2009 - 05:36 AM.
added some stuff at the end