Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!cs.uu.nl!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Knute Johnson Newsgroups: comp.lang.java.gui Subject: Re: Design Suggestions? Date: Thu, 02 May 2013 18:18:45 -0700 Organization: A noiseless patient Spider Lines: 78 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 3 May 2013 01:15:13 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="2bf91f193b65f3bb5327cc2231268b99"; logging-data="18971"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+inGlr6H3YdgHVsntpyOer" User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: Cancel-Lock: sha1:3750M2Es9PRCnnAq1+vwljJjZi4= Xref: csiph.com comp.lang.java.gui:5331 On 5/2/2013 14:56, Henry wrote: > I need someone to brainstorm with me about a very small project. > > I'm trying to build a small private application (or applet) to simulate > a draw with a small number of tickets. It's for a club to which I belong. > > Currently, we do the draw with real paper tickets, purchased from an > office supply place. Anyone who wants to purchase tickets indicates how > many they want and paper tickets, each containing two copies of a 6 > digit unique number are torn in half so that each half has the unique > number intact. The buyer gets half of the ticket and the other half is > tossed into a hat or suitable container. Tickets sell for $0.25 each or > 5 for a dollar. No one has ever bought more than 10 tickets for a given > draw. After everyone who wants one has their tickets, a neutral party > draws a winning ticket; the winner gets half of the cash raised by the > draw (rounded up to the nearest quarter if necessary) and one book or > DVD from a pile of books and DVDs donated by various members. After the > winner has claimed his/her prize, a second draw is made and the second > place winner gets first choice of the remaining books and movies but no > cash. Drawing continues with each subsequent winner getting first choice > of whatever books and films remain until all books and films are > exhausted. The club keeps the remaining half of the money raised by the > ticket sales. Tickets are discarded after the draw. > > I want to write a Java application or applet that duplicates what > happens in our existing draw. I'm intrigued by Java FX and am tempted to > write the program that way to learn more about FX but I'm more familiar > with Swing and would be willing to go that way. > > I've installed NetBeans 7.3 and Scenebuilder but as I look through > Scenebuilder, I don't see anything that looks like Card Layout. You see, > I'm picturing this like one of the Windows wizards where each stage is a > separate page of a CardLayout and you can go back and forth between > different stages. For example, the first "page" is ticket sales and for > each buyer, you put his/her name in a text box (or combo box) and use a > Spinner to set the number of tickets purchased. Then you calculate the > cost of those tickets and display it beside the number of tickets. Then > you collect that money from the buyer. When you have collected all the > money for all the tickets sold, you have finished Page 1 of the draw. At > that point, you click a Next button and go to Page 2. > > Page 2 displays the ticket buyer names in a table or list. Beside each > buyer name is the unique numbers of the ticket that person has > purchased, e.g. 100001, 100002, 100003 or just 100006. (Ticket numbers > are given out sequentially, just as tickets appear sequentially numbered > in the paper roll of tickets.) At this point, a late arrival might want > to still buy tickets or an existing buyer may want to buy additional > tickets so it should be possible to go back to Page 1 and sell more > tickets, which will necessitate increasing the ticket count for an > existing buyer or adding a new buyer to the list. When that is done, you > go back to Page 2. The bottom of Page 2 needs a button that initiates > the actual selection of the winning tickets. > > The winning ticket numbers should be listed in order (with buyer name) > on the third page. The person operating the program should be able to > scroll up and down if necessary and simply reads the list of winners > from top to bottom, stopping after reading each one to allow that person > to collect his prize before moving on. All the details of that draw - > who bought tickets, how many they bought, what ticket numbers were > issued, and which tickets won - should be written to a file so that it > can be easily viewed again at some point in case anyone wants to > challenge the fairness (or the randomness of the random number generator). > > At least that's the way I'm thinking of doing this. Unfortunately, I > don't see how I can do that in JavaFX since I don't see any equivalent > to CardLayout there. But perhaps there is a better way to design this. > That's why I'm asking here. > > Does anyone have any thoughts on the best way to design this? I don't think you need card layout. I see it more as a single frame with a button to add more tickets, a list of all the ticket holders names, with a name for each ticket they bought, and a button to produce a random index to select a winner. You could have another button to remove someone for a refund. Menu items for reports and clearing out the database. knute...