Help w/ MouseListener (MasterMind)

JAVA

    Sponsored Links

    Next

  • 1. myThread.join() doesn't seem to work
    I'm starting a thread which is an http client to grab some xml from another webserver. The problem is my parent thread finishes before my child thread seems to even start. I thought the join would pause my current(parent) thread and wait on the child thread. Any help much appreciated. --- CommandHandler commandHandler = new CommandHandler(uri, cmd); new Thread(commandHandler).start(); // returns false, shouldn't commandHandler thread be alive here? System.out.println("is alive = " + commandHandler.isAlive()) // here I would put up a busy page on the screen while // data is being collected and maybe do some other small stuff. smallStuff(); // So I wanted to wait 7 seconds at most here for the child thread // to finish getting XML. Anylonger, then it's too slow and I'd // continue on showing slow msgs on the screen commandHandler.join(7000); // returns false System.out.println("is alive2 = " + commandHandler.isAlive()); // here I grab data collected from thread. Problem is, it's // all still null data cause the child thread hasn't recieved the // webserver response yet, so it didn't pause and wait for it // to die at the join() MyXMLInfo info= (MyXMLInfo) commandHandler.getXML();
  • 2. could write an alarm application in MIDlet?
    if MIDlet can do this kind of application, I'll to read more document to learn how to code it, if not, I'll give up.anybody knows? the alarm application need automatically start when the time had come, could cellphone give this privilege to JAVA VM? I want DIY a multi-task(it can alarm many things) MIDlet, if this possible? -- Your fault as a Government is My failure as a Citizen.
  • 3. microedition.io problem
    I'm trying to compile this code; import java.io.*; import java.util.*; import javax.microedition.io.*; import javax.microedition.lcdui.*; public class Connection implements HttpPosterListener { private final String proxyUrl; private final HttpPoster poster; private DBListener listener = null; .........etc. every time I get an error messagr like this; package javax.microedition.io does not exist package javax.microdition.lcdui does not..... how & where can I obtain this classes?

Help w/ MouseListener (MasterMind)

Postby Unknown » Thu, 01 Sep 2005 19:20:37 GMT

  I am having trouble implementing MasterMind (the game).  I designed a 
class that adds to a JPanel multiple JComponents which each contain 4 
circles.  Upon clicking a circle, the program prints an appropriate colored 
circle that the user has selected over the circle.  The problem is that when 
implementing it, I am only  allowed to let the user to click on one row at a 
time, starting with the first row.  I've tried many things...should I 
perhaps implement the MouseListener in a separate class rather than inside 
the ...Is there an easy way to allow the user to click on one row at a time? 



Re: Help w/ MouseListener (MasterMind)

Postby Eric Sosman » Fri, 02 Sep 2005 02:41:34 GMT





    How about theComponent.setEnable(boolean)?

    If that doesn't help, you'll probably need to show
actual code for what you're doing.

-- 
 XXXX@XXXXX.COM 


Similar Threads:

1.My Mastermind Game in Visual Basic, VBScript, JavaScript, ActionScript (Flash)

2.My Mastermind Game in VB, Flash, VBScript, JavaSc

3.Newbie MouseListener Problem

Just started taking a class in java, and finding it pretty interesting, but
very difficult. I'm trying to write some code that will allow me to move a
counter on a chessboard. Got the board and counter setup (not very well),
but the counter won't move. Thanks in advance for any help.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Romeo extends Applet implements MouseListener,
MouseMotionListener {


private Point snail1, mouse;
private int select;

public void init() {

this.addMouseMotionListener(this);
this.addMouseListener(this);
select = 0;
snail1 = new Point (25,25);
mouse = new Point();
}


public void paint(Graphics g)
{
drawRect(g);
g.setColor (Color.red);
g.fillOval (snail1.x, snail1.y, 30,30);

}

public void mouseDragged(MouseEvent e) {
mouse = e.getPoint();
// continuously change the coordinates of the selected counter
if (select == 1) snail1 = mouse;
repaint();
}

public void mousePressed(MouseEvent e) {
//select a counter using the mouse
mouse = e.getPoint();

if (mouse.x > snail1.x - 5 && mouse.x < snail1.x + 5 &&
mouse.y > snail1.y - 5 && mouse.y < snail1.y + 5) select = 1;
}


// required for the interface
public void mouseClicked(MouseEvent event){}
public void mouseReleased(MouseEvent event){}
public void mouseEntered(MouseEvent event){}
public void mouseExited(MouseEvent event){}
public void mouseMoved(MouseEvent event){}


public void drawRect(Graphics g) {

g.setColor (Color.black);
g.fillRect (0,0,50,50);
g.drawRect (50,0,50,50);
g.fillRect (100,0,50,50);
g.drawRect (150,0,50,50);
g.fillRect (200,0,50,50);
g.drawRect (250,0,50,50);
g.fillRect (300,0,50,50);
g.drawRect (350,0,50,50);

g.drawRect (0,50,50,50);
g.fillRect (50,50,50,50);
g.drawRect (100,50,50,50);
g.fillRect (150,50,50,50);
g.drawRect (200,50,50,50);
g.fillRect (250,50,50,50);
g.drawRect (300,50,50,50);
g.fillRect (350,50,50,50);


g.fillRect (0,100,50,50);
g.drawRect (50,100,50,50);
g.fillRect (100,100,50,50);
g.drawRect (150,100,50,50);
g.fillRect (200,100,50,50);
g.drawRect (250,100,50,50);
g.fillRect (300,100,50,50);
g.drawRect (350,100,50,50);

g.drawRect (0,150,50,50);
g.fillRect (50,150,50,50);
g.drawRect (100,150,50,50);
g.fillRect (150,150,50,50);
g.drawRect (200,150,50,50);
g.fillRect (250,150,50,50);
g.drawRect (300,150,50,50);
g.fillRect (350,150,50,50);

g.fillRect (0,200,50,50);
g.drawRect(50,200,50,50);
g.fillRect(100,200,50,50);
g.drawRect (150,200,50,50);
g.fillRect (200,200,50,50);
g.drawRect (250,200,50,50);
g.fillRect (300,200,50,50);
g.drawRect (350,200,50,50);

g.drawRect (0,250,50,50);
g.fillRect (50,250,50,50);
g.drawRect (100,250,50,50);
g.fillRect (150,250,50,50);
g.drawRect (200,250,50,50);
g.fillRect (250,250,50,50);
g.drawRect (300,250,50,50);
g.fillRect (350,250,50,50);

g.fillRect (0,300,50,50);
g.drawRect (50,300,50,50);
g.fillRect (100,300,50,50);
g.drawRect (150,300,50,50);
g.fillRect (200,300,50,50);
g.drawRect (250,300,50,50);
g.fillRect (300,300,50,50);
g.drawRect (350,300,50,50);

g.drawRect (0,350,50,50);
g.fillRect (50,350,50,50);
g.drawRect (100,350,50,50);
g.fillRect (150,350,50,50);
g.drawRect (200,350,50,50);
g.fillRect (250,350,50,50);
g.drawRect (300,350,50,50);
g.fillRect (350,350,50,50);

}
}



4.JList/MouseListener

Hi all
I'm using two JLists with the same MouseListener in a JFrame. How can I find
out on which JList the MouseEvent was released?
Is it generally possible or should I use a MouseListener for each JList?
Thanx for your help
Roman


5.Using implements Runnable and MouseListener

I am fairly new to Java but have written an applet that uses 'implements
Runnable' to do some timing
eg
                   public class Puzzle extends Applet implements Runnable
{ etc.

and also an applet which detects left, right and double mouse clicks using
'implements MouseListener'
eg
                   public class TestMouse extends Applet implements
MouseListner { etc.

I would now like to write an applet that uses both of these so that I can
detect the mouse actions as well as do some timing.

Could someone show me the structure that would be used to allow both
implements Runnable and MouseListener in the same Java applet?  This is
probably quite obvious to a regular Java programmer but I am an old style
programmer trying to convert to Java.

Thank you.
Doug van Vianen
 XXXX@XXXXX.COM 


6. Adding MouseListener to an Object

7. More than 1 MouseListener

8. One shared MouseListener or many distributed



Return to JAVA

 

Who is online

Users browsing this forum: No registered users and 9 guest