/************************************************************** ** ** Program : hilo_win.java (GUI only) ** ** Author : Ryan J. Stradling ** ** Created : July 10, 1996 ** ** Revisions : August 5, 1996 - changed the design ** November 1996 - added panels (AJT) ** ** Purpose : This is a GUI for a hilo card game that is text based. ** ***************************************************************/ import java.awt.*; /********************************************************************* ** ** Class : hilo_win ** ** Inherits : From the applet class ** ** This class provides the hilo game interface. ** (Only the interface is done here.) **********************************************************************/ public class hilo_win extends java.applet.Applet { // Instance variables TextField cash_text, bet_text; // the player's cash and bet windows TextField first_text, second_text, third_text; // the card display windows TextField msg_text; // the message window Label cash_label, bet_label; // the player's cash and bet labels Label first_label, second_label, third_label; // the card display labels Label msg_label; // the message label Panel first_panel, second_panel, third_panel; // panels for card displays Panel fourth_panel; // panel for bet field Panel fifth_panel; // panel for message field Button deal_button; // deal button // (Overridden) init method: public void init() { setBackground(Color.blue); // Set background color to blue setForeground(Color.white); // Set foreground color to white setLayout(new FlowLayout()); // Set Layout Style // Add the label and the text field for the winnings balance. cash_label = new Label("Your cash:"); cash_text = new TextField(8); add (cash_label); add(cash_text); // Add the Deal button. deal_button = new Button("DEAL"); add(deal_button); // Add the text fields and labels for the cards. // Create the labels and text fields. first_label = new Label("First Card:"); first_text = new TextField(25); third_label = new Label("Middle Card:"); third_text = new TextField(25); second_label = new Label("Second Card:"); second_text = new TextField(25); // Create a panel for each label-text field pair. first_panel = new Panel(); first_panel.setLayout(new FlowLayout()); second_panel = new Panel(); second_panel.setLayout(new FlowLayout()); third_panel = new Panel(); third_panel.setLayout(new FlowLayout()); // Put a label and text field into each of the three panels. first_panel.add(first_label); first_panel.add(first_text); second_panel.add(third_label); second_panel.add(third_text); third_panel.add(second_label); third_panel.add(second_text); // Add the panels to the applet. add(first_panel); add(second_panel); add(third_panel); // Add the bet field and label. bet_label = new Label("Your Bet: $"); bet_text = new TextField(5); fourth_panel = new Panel(); fourth_panel.setLayout (new FlowLayout()); fourth_panel.add(bet_label); fourth_panel.add(bet_text); add(fourth_panel); // Add the message field and label. msg_label = new Label("Message:"); msg_text = new TextField(30); fifth_panel = new Panel(); fifth_panel.setLayout (new FlowLayout()); fifth_panel.add(msg_label); fifth_panel.add(msg_text); add(fifth_panel); // Initialize the text fields and prohibit input. cash_text.setText("$0"); cash_text.setEditable(false); first_text.setEditable(false); second_text.setEditable(false); third_text.setEditable(false); msg_text.setEditable(false); } }