LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 06-13-2006, 04:59 PM   #1
ohfaney
LQ Newbie
 
Registered: Apr 2006
Location: Harlow, Essex, England
Posts: 28

Rep: Reputation: 15
importing images into java, and problems with my arrays


H'okay, i haven't been on here in forever, since the start of my java year end project.

It's due tomorrow, and really i'm almost finished but I wanted to lol 'spice it up' and give the program a backround, fancy text headings, and so on. However, i don't know how to do this! i've looked all over the net but i can't find anything that makes any sense to me, so i figured...HEY! why not go back here.

here is my code...

Code:
import java.awt.*;
import java.io.*;
public class ISUPROJECT
{
    public static void main (String[] args)
        throws java.io.IOException
    {
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        //Opening Header
        System.out.println ("\t\t\t\tBuild-a-Webpage");

        FileWriter fw = new FileWriter ("textpage.txt");
        String input, name, quiz, builder;
        int userChoice;

        System.out.print ("\t\t\t\tWhat's your name?: ");
        name = br.readLine ();
        // Prints out the users input
        System.out.println ("\t\t\t\t" + name);
        System.out.println ("\n\n");
        // Saves the users name to the file 'test.txt'
        fw.write (name + "\r\n");


        String menuArray[] = {"A", "B", "C", "D", "E", "F", "H", "I", "J"};
        System.out.println ("Choose a menu option\n");
        System.out.println ("Getting Started A");
        System.out.println ("Learn about html B");
        System.out.println ("Basic Codes C");
        System.out.println ("Tutorials D");
        System.out.println ("Build your own page E");
        System.out.println ("Quiz Yourself F");

        System.out.println ("Your Choice");
        input = br.readLine ();

        if (input.equals (menuArray [0]))
        {
            //getting started page
            System.out.println ("\t\t\t\t\n\nMake a plan\n");
            System.out.println ("\t\t\t\tWhen you're first getting started, it's key to make a plan,\nput down all your thoughts, how the page is supposed to look,\nimages, frames; general page structure.Get a piece of paper,\nand draw out your index page and work out from there.\n\n");

            System.out.println ("\t\t\t\tFind a host\n");
            System.out.println ("\t\t\t\tNaturally you need someone/somewhere to host your page,\nthis is crucial; otherwise no one will see your page other than you on your own PC");
            System.out.println ("\t\t\t\tHosts");
            System.out.println ("\t\t\t\tgeocities.com");
            System.out.println ("\t\t\t\tpiczo.com");
        }
        else if (input.equals (menuArray [1]))
        {
            //history of
            System.out.println ("\t\t\tHTML has had a life-span of roughly seven years. During that time,\n\t\t\t it has evolved from a simple language with a small number of tags to a complex system of mark-up,\n\t\t\t enabling authors to create all-singing-and-dancing Web pages complete\n\t\t\t with animated images, sound and all manner of gimmicks.\n\t\t\t This chapter tells you something about the Web's\n\t\t\t early days, HTML, and about the people, companies and organizations who contributed to HTML+, HTML 2, HTML 3.2 and finally, HTML 4.\n\n");
            System.out.println ("\t\t\tHTML is the language that powers the Web in many respects, as the\n\t\t\t lingua franca that Web browsers are expected to be able to render.\n\t\t\t HTML has had unprecedented levels of success, and the uptake is all\n\t\t\t the more surprising when you realise that it was only invented in 1990,\n\t\t\t and few people knew about it before 1993. In fact, although HTML\n\t\t\t has changed relatively little since those early days, the history of HTML\n\t\t\t is rather cloudy. However, with a little detective work on the Web,\n\t\t\t it is possible to reconstruct most of the events that led to the\n\t\t\t creation and subsequent deployment and acception of HTML.");
            System.out.println ("\t\t\tTim Berners-Lee first started to come up with code for his WWW project\n\t\t\t in 1990. The first mention of him working on code for processing\n\t\t\t HyperText can be found in the original HyperText.m file that Tim worked\n\t\t\t on, dated 25th September 90. From the 27th to the 30th November 1990,\n\t\t\t Tim and Robert Cailliau attended ECHT '90 - the European HyperText Convention. After\n\t\t\t ECHT '90, it appears that he had some more ideas about the\n\t\t\t (probably as yet unnamed) World Wide Web, and in the last few\n\t\t\t months of 1990, he started to produce more code, and also the\n\t\t\t first recorded HTML documents.In fact, the earliest HTML document on the WWW\n\t\t\t at the moment dates from 13th November - a couple of weeks before\n\t\t\t the conference - as evidenced a HTTP HEAD request, which returns");
            System.out.println ("\t\t\tTue, 13 Nov 1990 15:1700 GMT ");
            System.out.println ("\t\t\tThe page is still functional in most modern Web browsers, and even\n\t\t\t contains a functional HyperLink!");
            System.out.println ("\t\t\tSo, what was early HTML actually like? The following is the code used in the oldest HTML document referenced above:-");

            System.out.println ("\t\t\t\t<title>Hypertext Links</title>");
            System.out.println ("\t\t\t\t<h1>Links and Anchors</h1>");
            System.out.println ("\t\t\t\tA link is the connection between one piece of");
            System.out.println ("\t\t\t\t<a href=WhatIs.html>hypertext</a> and another.");

            System.out.println ("These are the tags and attributes evident from the first five days\n\t\t\t of Dec 1990:- Surprisingly enough you can still create a decent webpage\n\t\t\t using only these codes");
        }
        else if (input.equals (menuArray [2]))
        {
            //basic coding information
            System.out.println ("\t\t\t\tBasic Codes\n");
            System.out.println ("\t\t\t\tBold\t<b>TEXT HERE</b>");
            System.out.println ("\t\t\t\tItalic\t<i>TEXT HERE</i>");
            System.out.println ("\t\t\tUnderline\t<u>TEXT HERE</u>");
            System.out.println ("\t\t\tRemember when using these codes that you MUST close the code at the end,\n\t\t\texample; if you're using a 'bold' tag, <b> <--- goes at the beginning,\n\t\t\tand to close it after you've written your text to be bolded\n\t\t\tyou would type </b> <--- to close the tag (the slash MUST be there)\n");



        }
        else if (input.equals (menuArray [3]))
        {
            //tutorials page
            System.out.println ("\t\t\t\tTutorials");

        }
        else if (input.equals (menuArray [5]))
        {
            //quiz goes here
            System.out.println ("\t\t\t\tQuiz");
            System.out.println ("\t\t\tThe following quiz will test your knowledge of HTML\n\n");




        }
        else if (input.equals (menuArray [4]))
        {

            System.out.println ("Choose a menu option\n");
            System.out.println ("Test your skills with color codes A");
            System.out.println ("Make a photo page B");
            System.out.println ("Create a basic page (header, text, one link) C");
            System.out.println ("Create a full working page with background image D");
            System.out.println ("Your Choice");
            input = br.readLine ();


        }
        else if (input.equals (menuArray [1]))
        {
            //page builder goes here
            //Header
            System.out.println ("\t\t\t\tBuild your own page\n");
            //Insert 'html' tag
            System.out.println ("Please type your html tag: ");
            builder = br.readLine ();
            //Insert 'head' tag
            System.out.println ("Please type your head tag: ");
            builder = br.readLine ();
            //Insert '/head' or 'title' tag
            System.out.println ("Please type your title tag, or end your head tag now: ");
            builder = br.readLine ();
            //Insert end '/head' tag, or press enter if already done
            System.out.println ("Please enter your closing head tag if you have not already done so, if you have press enter to go onto the next code: ");
            builder = br.readLine ();
            //Insert 'body' tag
            System.out.println ("Please enter your beginning body tag: ");
            builder = br.readLine ();
            //Insert text color code
            System.out.println ("Enter the color change tag, and a color (ex. blue, red, green, black, grey) and put between the two tags 'hello' (remember this is just a test): ");
            builder = br.readLine ();
            //Insert line break code
            System.out.println ("Since we want spaces (or a free line) between each text example, enter a linebreak code now: ");
            builder = br.readLine ();
            //Change the size of a font/text
            System.out.println ("Now, enter the font size change code, we want to show an example of how to change the sizing of lettering (adjust the size to whatever you like =]): ");
            builder = br.readLine ();
            //Insert line break code
            System.out.println ("Since we want spaces (or a free line) between each text example, enter a linebreak code now: ");
            builder = br.readLine ();
            //Font face change
            System.out.println ("To change the font face (or which font we're using, ex. verdana, tahoma, comic sans etc.) enter the font face code, and whatever font you'd like it to be (remember to keep putting text between the opening and closing codes!: ");
            builder = br.readLine ();
            //Insert line break code
            System.out.println ("Since we want spaces (or a free line) between each text example, enter a linebreak code now: ");
            builder = br.readLine ();
            //Adding it all together in one neat package
            System.out.println ("And finally so you dont have to keep typing all that code, enter the 'whole shebang' font face, color, and size in one (remember words between opening and closing!): ");
            builder = br.readLine ();
            //Close body tag
            System.out.println ("Close the body tag: ");
            builder = br.readLine ();
            //Close the html tag
            System.out.println ("Close the html tag: ");
            builder = br.readLine ();

            System.out.println ("Now you're all done, open your text file (remember it's an html document) in internet explorer (or mozilla), and check out what you did!");
            fw.write (builder + "\r\n");
        }
        else if (input.equals (menuArray [2]))
        {
            System.out.println ("Please type your html tag: ");
            builder = br.readLine ();
            //Insert 'head' tag
            System.out.println ("Please type your head tag: ");
            builder = br.readLine ();
            //Insert '/head' or 'title' tag
            System.out.println ("Please type your title tag, or end your head tag now: ");
            builder = br.readLine ();
            //Insert end '/head' tag, or press enter if already done
            System.out.println ("Please enter your closing head tag if you have not already done so, if you have press enter to go onto the next code: ");
            builder = br.readLine ();
            //Insert 'body' tag
            System.out.println ("Please enter your beginning body tag: ");
            builder = br.readLine ();



        }








        fw.close ();
    } // main method


    public void paint (Graphics g)
    {
        
    } // paint method
} // ISUPROJECT class
obviously some things aren't finished like my sections, however one more problem... a) can i define two txt files to save seperate things to? ex. save the name of the user to name.txt and say the webpage they build in my nifty building thingy to 'builder.html' or is this not possible? because it's not even saving period right now, and i couldn't figure out why..it's probably something really simple lol. AND when i go to my menu option (from the main menu) 'E' and select menu option 'A' it goes nowhere, the program stops.

HELP?!

-steph
 
Old 06-13-2006, 05:41 PM   #2
ohfaney
LQ Newbie
 
Registered: Apr 2006
Location: Harlow, Essex, England
Posts: 28

Original Poster
Rep: Reputation: 15
okay, forget the thing about the not saving and so on and so forth, because...i figured that out..really all i need is help with images now!
 
Old 06-14-2006, 08:26 AM   #3
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Tripple post. Closing thread.
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
java + arrays dilberim82 Programming 3 02-12-2005 02:33 PM
Importing java files in a directory ?? the_c Programming 5 04-09-2004 01:56 AM
Java arrays and dimensions pycoucou Programming 5 04-07-2004 01:59 PM
java arrays and objects titanium_geek Programming 13 03-07-2004 01:21 PM
importing my own classes in Java vanquisher Programming 9 10-02-2003 03:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration