Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 merging text with jpanel
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
magicman




PostPosted: Mon Jun 12, 2006 12:32 pm   Post subject: merging text with jpanel

i have this program
code:

import java.awt.*;
import java.io.*;
import hsa.Console;

public class Test4
{
    static Console c;
    public static void main (String [] args) throws IOException
    {
        c = new Console ();
        int winnings = 0, number;
        number = stage ("questions1.dat");
        winnings += number;
        c.println ("You just earned " + number);
        c.println ("Your current winngins are " + winnings);
    }


    public static int stage (String filename) throws IOException
    {
        BufferedReader input;
        input = new BufferedReader (new FileReader (filename));
        //change the size up by one, by each question you add.
        int money = 0, stg1, num = 0, size = 3;
        String temp;
        String [] number, question, choiceA, choiceB, choiceC, choiceD, correct;
        number = new String [size];
        question = new String [size];
        choiceA = new String [size];
        choiceB = new String [size];
        choiceC = new String [size];
        choiceD = new String [size];
        correct = new String [size];
        String answer, reply;
        number [num] = input.readLine ();
        while (number [num] != null)
        {
            question [num] = input.readLine ();
            choiceA [num] = input.readLine ();
            choiceB [num] = input.readLine ();
            choiceC [num] = input.readLine ();
            choiceD [num] = input.readLine ();
            correct [num] = input.readLine ();
            num++;
            number [num] = input.readLine ();
        }

        input.close ();
        boolean done = false;
        stg1 = (int) (Math.random () * 2) + 1;
        temp = correct [stg1 - 1].toLowerCase ();
        c.println (question [stg1 - 1]);
        c.print (choiceA [stg1 - 1], 30);
        c.println (choiceB [stg1 - 1]);
        c.print (choiceC [stg1 - 1], 30);
        c.println (choiceD [stg1 - 1]);
        do
        {
            c.print ("enter letter of correct answer: ");
            answer = c.readString ();
            c.println ("Is that the final answer??");
            c.println ("y/n");
            reply = c.readString ();
            if (reply.equals ("y") || reply.equals ("Y"))
            {
                done = true;
            }
            else if (reply.equals ("n") || reply.equals ("N"))
            {
                c.println ("try again");
                done = false;
            }
            else
            {
                c.println ("Please enter only 'y' or 'n'");
                done = false;
            }
        }
        while (!done);
        if (answer.equals (correct [stg1 - 1]) || answer.equals (temp))
        {
            money = 100;
            c.println ("you have won $100");
        }
        else
        {
            c.println ("You are history...");
        }
        return money;
    } //stage1 method
} //test 4 class

and i need to merge it with this one
code:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import hsa.Console;
public class Keystrokes
{
    static Console c;
    public Keystrokes ()
    {
        JFrame frame = new JFrame ("New Window");
        Container content = frame.getContentPane ();
        content.setLayout (new FlowLayout ());
        frame.setSize (500, 500);
        JMenuBar jmb = new JMenuBar ();
        JMenu fileMenu = new JMenu ("File");
        JMenuItem newItem = new JMenuItem ("New Game");
        JMenuItem quitItem = new JMenuItem ("Quit");
        jmb.add (fileMenu);
        fileMenu.add (newItem);
        fileMenu.add (quitItem);
        frame.setJMenuBar (jmb);
        quitItem.addActionListener (new ActionListener ()
        {
            public void actionPerformed (ActionEvent ae)
            {
                System.exit (0);
            }
        }
        );
        fileMenu.setMnemonic (KeyEvent.VK_F);
        newItem.setMnemonic (KeyEvent.VK_N);
        quitItem.setMnemonic (KeyEvent.VK_Q);
        frame.setVisible (true);
    }


    public static void main (String [] args)
    {
        new Keystrokes ();
    }
}



and i know if i dont do this the right way... the text will show up in a different text box, what/and how can i complete this?
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: