Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #6026

Re: Needs help in logic

From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: Needs help in logic
Date 2011-07-09 19:56 -0700
Organization A noiseless patient Spider
Message-ID <ivb4d0$o98$1@dont-email.me> (permalink)
References <fbfce98a-335f-4465-b8b3-bd3c4d087d1c@b21g2000yqc.googlegroups.com>

Show all headers | View raw


Well, I don't do homework for people, but I'll give you some hints.

1.  Don't use BorderLayout, it kinda sucks for what you're trying to do. 
  The default FlowLayout of a JPanel is proabably better.  Put all the 
components in the JPanel and add that to the main content pane of the 
JFrame.  Then pack() the frame (frame.pack()) instead of setting its size.

2. This is the next bit to add to your program:

 > event-
 > handler method or the actionPerformed method of class based on the
 > ActionListener

Read this:

<http://download.oracle.com/javase/tutorial/uiswing/events/actionlistener.html>

Then add a method to your main class like this:

public class guessprogram implements .... name here... {

   	public static void main(String args[]) {
	    // this is what you have already...
   	}

	public void actionPerformed(ActionEvent e) {
	  // logic to test input here
	}

}

And add the ActionListener as that link shows you.  That should get you 
started.  Your program has threading problems, but we'll leave that 
alone for a beginner problem.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Needs help in logic Eric <ehtisham@gmail.com> - 2011-07-09 19:05 -0700
  Re: Needs help in logic markspace <-@.> - 2011-07-09 19:56 -0700
    Re: Needs help in logic lewbloch <lewbloch@gmail.com> - 2011-07-11 11:18 -0700
  Re: Needs help in logic Roedy Green <see_website@mindprod.com.invalid> - 2011-07-10 02:02 -0700

csiph-web