★ wanayoo — archive 1999 http://java.webdeveloper.com/BMMenu/MenuLoaderJava.htmlNouvelle recherche | Portail wanayoo


Find a Web Host With:
CGI Access
DB Support
NT Servers
UNIX Servers
Telnet Access

advanced search
Internet News
Internet Investing
Internet Technology
Windows Internet Tech.
Linux/Open Source
Web Developer
ECommerce/ Marketing
ISP Resources
ASP Resources
Wireless Internet
Downloads
Internet Resources
Internet Lists
International
EarthWeb
Career Resources

Search internet.com
Advertise
Corporate Info
Newsletters
E-mail Offers
Be a Commerce Partner
Free Barter Account
Internet Jobs
Build Flash Online
Find a Consultant
Send a Press Release
Find a Web Host
Submit Your Site
Register Domains
Anti-Virus Software
Free Search Traffic
FlashKit
Gif.com
HierMenusCentral
JavaBoutique
JavaScript.com
JavaScriptSource
WebDev Jobs
JustSMIL
ScriptSearch
StreamingMediaWorld
Web Hosts
WebDevelopersJournal The WDVL
WebDeveloper.com
WebReference.com
XMLFiles.com
CGI
HTML
Java
JavaScript
Web Design and Promotion
Web Site Development
E-mail Address:


Can you receive
HTML e-mail?

Yes   No

Zip Code:



MenuLoader.java



import java.awt.*;
import java.awt.event.*;        // for ActionListener, ActionEvent
import java.lang.Thread;
import java.io.*;
import java.util.Stack;

public class MenuLoader extends Thread
{
    Menu           m;                // root menu to be loaded
    ActionListener l;                // will be called when a menu is clicked
    ActionListener doneListener;     // will be called when the loading is done
    BookmarkParser p;                // used to parse an HTML bookmark file

    public MenuLoader(Menu m, Reader r, ActionListener l)
        throws IOException
    {
        this.m = m;
        this.p = new BookmarkParser(r);
        this.l = l;
    }

    public void addActionListener(ActionListener l){
        this.doneListener = l;
    }

    public void run()
    {
        MenuBuilder b = new MenuBuilder(m, l);

        try{
        while( p.next() != BookmarkParser.EOF ){
            switch(p.getType()){
            case p.BOOKMARK:
                b.addBookmark(p.getName(), p.getLink());
                break;
            case p.FOLDER:
                b.startSubmenu(p.getName());
                break;
            case p.FOLDER_END:
                b.endSubmenu();
                break;
            case p.SEPARATOR:
                b.addSeparator();
                break;
            default:
                break;
            }
        }//while

        notifyListener("done");

        }catch(IOException e){
            notifyListener("error");
        }

    }

    void notifyListener(String command){
        if( doneListener != null ) {
            doneListener.actionPerformed(
                new ActionEvent(this, 0, command)
            );
        }
    }


};


class MenuBuilder{

    Stack s = new Stack();
    ActionListener l;

    public MenuBuilder(Menu m, ActionListener l){
        s.push(m);
        this.l = l;
    }

    public void addBookmark(String name, String link){
        MenuItem i = new MenuItem(name);
        i.setActionCommand(link);
        i.addActionListener(l);
        getCurrentMenu().add(i);
    }
    public void addSeparator(){    getCurrentMenu().addSeparator();    }
    public void startSubmenu(String name){
        Menu sub = new Menu(name);
        getCurrentMenu().add(sub);
        s.push(sub);
    }
    public void endSubmenu() {     s.pop();    }

    Menu    getCurrentMenu(){
        return (Menu)(s.peek());
    }

}

Return to Bookmark Menu Applet

internet.com logo










WebDev News

News Server Glitch Angers AOL Customers

Open Source Group Issues Top Ten Web Vulnerabilities

What's in a Name for Microsoft? Not .NET





FastParser
FastParser is an XML parser for non validating XML processing, it is based on a Turing finite state automaton.
Download of the Week
MagicTrick
MagicTrick is reminiscent of everyone's childhood. Just like Daddy's magic tricks, this applet is able to pick your card,(out of 21),every time! Source code included.

JB User Poll
Certification vs. experience--what's your opinion?
The JavaBoutique Top 15:
1. DJPopMenu
2. NavBar
3. PingPong
4. AnimLetters_anim
5. RushHour
6. 3DMaze
7. AScroll2
8. ChompText
9. AnimatedTreeControl
10. Distorter
11. Encyclo
12. Viewer
13. TypoToolMotion11
14. Nibbly
15. Tsukoban
Want more? Check out our Top 100!

Refer-It
Affiliate Program and Referral Directory.
New on internet.com
Capellas Lays Out 100 Day Plan for WorldCom
WorldCom's new chairman and CEO Michael Cappellas charges out of the gates with a 100-day plan aimed at laying the foundation for the company's climb out of the largest bankruptcy in U.S. history.

Competition Heats Up Between DBS, Cable
Digital television is attracting millions of consumers, and satellite and cable operators are racing to grab the market share.

Web Conferencing Choices on the Rise
While corporate travel budgets have all but evaporated over the last two years, the use of Web conferencing has grown by leaps and bounds. Jacqueline Emigh takes a look at the options currently available and explores what's on the horizon for the Web conferencing software and services market.


Copyright 2003 Jupitermedia Corporation All Rights Reserved.
Legal Notices,  Licensing, Reprints, & Permissions,  Privacy Policy.
http://www.internet.com/