Create menus in an applet

I'm just starting to use applets. I'd like to create an applet menu for my web page. I'd like to use the MenuBar object but I guess you need to add that to a Frame. Of course, applets are panels so how I can accomplish this?
Do I need to add a frame to me applet?
Thanks for the help!

in the init section of your code try:
JMenu Section = new JMenu("Section");
JMenuBar mb = new JMenuBar();
mb.add(Section);
setJMenuBar(mb);
This should give you a bar with Section as an option

Similar Messages

  • Help with creating an animated java applet...

    Hello, everyone! I'm working on a homework assignment for my Intro to Java class, and I'm having a problem I've never run into before. My assignment is to create a animated Java applet which displays an image of an alien spaceship which travels in diagonal lines across the applet area. My main problem is that when I try to compile my code, I get three "cannot find symbol" errors about my variable "alien." I can't figure out why declaring it as a class variable hasn't solved my problem. The errors pop up for the repaint() method, as well as the pane.add and the paintIcon. Here's my code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.Timer;
    class DrawAlien extends JPanel
    public class Alien extends JApplet implements ActionListener
      ImageIcon alien;
      public void init()
        Container pane = getContentPane();
        alien = new ImageIcon(getClass().getResource("alien.gif"));
        pane.setBackground(Color.black);
        pane.add(alien);
        Timer timer = new Timer(30, this);
        timer.start();
      public void actionPerformed(ActionEvent e)
        alien.repaint();
    }I've only posted the section which I think is relevant to my problem, but I can post the rest if anyone thinks it's necessary.
    I'm aware that the code isn't ready yet in several other ways, but I don't think I can move on until I figure out what's up with the "alien" variable. I don't need anyone to write code for me or anything like that, I just lack perspective here. A couple hints in the right direction would be invaluable. Thanks!
    Edited by: springer on Nov 25, 2007 10:46 PM

    You can?t add ImageIcon into pane, you can do like below.
    alien = new ImageIcon(getClass().getResource("alien.gif"));
        pane.setBackground(Color.black);
        JLabel label = new JLabel(alien);
        pane.add(label);

  • How to create menus in oracle forms6i?

    hello all,
    I want to create menu option in oracle forms6i..Is it possible? then how to create menus in a frame? pls help me..
    USER MANAGEMENT-------------->this is main menu.under this i want following
    --------->1.ADD USER
    ---------->2.EDIT USER
    ----------->3.DROP USER

    Hi Balraj
    Try to read this & implement it
    http://dbaforums.org/oracle/index.php?showtopic=2031
    u have also menu FREE sample as Demo Forms6i pls down load
    http://www.oracle.com/technology/sample_code/products/forms/6idemos.html
    Or download it directly as in this Thread Francois posted Directly...
    Forms6 : default menus menudef.mmb and menudefs.mmb
    Regards,
    Abdetu...
    Edited by: Abdetu on Jan 23, 2011 11:31 PM

  • Best way to create menus [was: Queston]

    What technique or is a template used to create the menu for this Adobe page? I have been studying web development (reading and tutorials) and the sections are always short on creating menus.  Mostly, covers creating buttons with behaviors in Fireworks and inserting them into Navigation Bars and Tables?  What are the best ways to create menus?
    [Subject line edited by moderator]

    Howdy,
    The best way is definately not the Fireworks way. Never has been.
    Take RJweb's advise and check out the PVII Menu Magic. I use that all the time and its very easy to customize with its well laid out CSS files. I havn't found anything easier to use and customize yet.
    Brad Lawryk
    Community Expert: Dreamweaver
    Usergroup Manager: Northern British Columbia Adobe Usersgroup

  • Any way to Create Menus in version 4?

    Dear fellow Premier Elements users -- I'm running version 4.0 of Premier Elements, and no matter what I try it crashes when I try to Create Menus (using a template).  I've created many DVDs using this great tool, but I now I need to make a DVD with scene menus.  The crash I get is in:
        adobe premier elements.exe  AppVer 4.0.0.0   MonName dvdcreator.dll ModVer 4.0.0.0   Offset 0006d14d
    I would be happy to create scene menus in any way. My movie timeline has both video and stills, and I've defined two scene markers (but no menu markers).  It seems that Adobe must have tested this function before they shipped the code, so I suspect there is a procedure that works.  Has anyone successfully done this?   I'd very much appreciate knowing how you did it!
    I updated the Adobe software using the Adobe updater, so I do not think there is a released fix for my problem.  Since my version isn't the current one, I don't think that that Adobe support will help.  I had a similar experience with my previous vendor of moving-making software.  That time I purchased the current version only to discover that the show-stopping bug was present in the new version.  I felt silly for investing in the upgrate, and I switched to Adobe's products because I thought that they were a more reputable company.  Up to now, their software has worked pretty well.  If I can not find a way around this problem however, I fear that I'll have to abondon Adobe and start using Apple's products.  I have a soft spot in my heart (for PC-based software) but not a soft spot in my head!
    Thanks in advance for any light you can shed on this vexing problem
    Jim

    Hey Steve -- Brilliant.  I think you nailed it.  I'm working on a older PC.  It's a 2.4 GHz Pentium 4 with 2 GB or RAM running Windows XP SP 3.  There are 17 GB of defragmented free disk space (which took hours to defragment).  Although Premier Elements is the only program running, it still can crashes as soon as I select a menu template and click Apply.
    The reason that I think your answer is correct is that I ran the same version of Premier Elements on my office laptop: 2.2 GHz Duo core T7500 with 2 GM of RAM and 72 GB free disk.  I was able to apply a menu template on a much more complicated DVD project without any problems.  It appears that my older home PC does not have the horsepower for this feature.
    So you not only diagnosed my problem, you renewed my faith in Adobe.  Now I'll upgrade to a hotter PC instead of jumping to a Mac.  I've never liked the proprietary HW and SW strategy that Apple rams down our throats.  I bought my first Apple device this year:  an iPod Touch.  Lovely little device, but I was flabbergasted that I would have to jailbreak the SW to be able to copy MP3 files onto it with anything other than Apple's own iTunes program.  And they've jiggered it somehow to prevent tethering it in the States with a cell phone via Bluetooth.  Makes me think that my ex-wife must be on the board... a chilling thought to be sure.
    But Adobe makes great photograhic SW for both PC and Mac.  The reason my home PC has only 17 GB free is that I have more than 12,000 digital photos online.  All taged and deftly managed and optimized with Photoshop Elements.  Nice.
    Thanks for your help Steve -- Jim

  • How to create menus for a particular file

    Hello all,
    can anyone solve my problem really i am totally fed up for writing logic for the following file ,
    what iam doing is i have a file like this
    aaa.mmm.ggg=/aaa/bbb
    aaa.clock=/usr/sbin/clock
    sss.jot=/user/pmsdev/bin/jot
    sss.netscape=/usr/BIN/netscape
    sss.nnn.gg=/gg/ss
    sss.nnn.yy=/usr/sbin/clock
    bbb.xclock=/usr/bin/X11/xclock
    bbb.ggg.mmm=/usr/sbin/clock
    bbb.ggg.kkk=/jjj/jjj
    bbb.ggg.kkk.xxx=/ggg/mmm
    bbb.hhh.pp=/ss/a
    bbb.zz=/Zmm/vvv
    vvv=/ddd/ddd
    for this i have to create menus and coresponding submenus,
    means for ex: *bbb.ggg.mmm=/usr/sbin/clock[*[B]bbb is the submenu of ggg which is the submenu of mmm ,so when i click on mmm i will get the value usr/sbin/clockso i have splitted on *"="* and i have used maps to store key value,this is ok,but how to create the menu structure for all how to compare one with other,please help me iam using swings for this.please help me.
    Edited by: 1-ewqsfd on Sep 30, 2007 2:11 AM

    Hello all,
    can anyone solve my problem really i am totally fed up for writing logic for the following file ,
    what iam doing is i have a file like this
    aaa.mmm.ggg=/aaa/bbb
    aaa.clock=/usr/sbin/clock
    sss.jot=/user/pmsdev/bin/jot
    sss.netscape=/usr/BIN/netscape
    sss.nnn.gg=/gg/ss
    sss.nnn.yy=/usr/sbin/clock
    bbb.xclock=/usr/bin/X11/xclock
    bbb.ggg.mmm=/usr/sbin/clock
    bbb.ggg.kkk=/jjj/jjj
    bbb.ggg.kkk.xxx=/ggg/mmm
    bbb.hhh.pp=/ss/a
    bbb.zz=/Zmm/vvv
    vvv=/ddd/ddd
    for this i have to create menus and coresponding submenus,
    means for ex: *bbb.ggg.mmm=/usr/sbin/clock[*[B]bbb is the submenu of ggg which is the submenu of mmm ,so when i click on mmm i will get the value usr/sbin/clockso i have splitted on *"="* and i have used maps to store key value,this is ok,but how to create the menu structure for all how to compare one with other,please help me iam using swings for this.please help me.
    Edited by: 1-ewqsfd on Sep 30, 2007 2:11 AM

  • Creating Menus

    Creating Menus
    hi,
    having problems creating menus in j2me.
    Found alot of code around using MenuElements, lists and all sorts of things.
    my code for the list is roughly like this:
    List menu=new List("MainMenu",List.IMPLICIT);
    int num1, num2, num3,num4,num5;
    private Command cmd = new Command("Select", Command.OK, 1);
    Displayable display1;
    public void options()
    num1 = 0;
    num2 = 1;
    num3 = 2;
    num4 = 3;
    num5 = 4;
    menu.append("Start Game", null);
    menu.append("High Scores", null);
    menu.append("Instructions", null);
    menu.append("About", null);
    menu.append("Exit", null);
    menu.addCommand(cmd);
    menu.setCommandListener(this);
    display1.setCommandListener(this);
    The problem now is how to i check which one is pressed?
    Or is there a better way to do this?
    Is will be quick a simple menu as you can see.
    Any advice is appreciated

    Will look through the tech tips
    Just one more question. The menu itself doesnt need to be drawn to the screen at all? i am using the getSelectedIndex now anyway need to integrate it into our current program get it to run either the menu or the game from the main.
    Should of done the menu earlier alot of hassle at this late stage.
    Thanks for answering.

  • Creating multiple Threads in applets

    Hi, I need some help creating multiple threads in applets. If you look at the simple code example below you�ll see that it uses one thread that calls the findTarg() method that gives its sleep() a value and makes the oval find its new target.
    What I want to know is how do I create a new thread in this applet? � So for example I could call a findTarg2() method from within a new thread that sets its sleep() to a faster or slower value and starts at the same time as findTarg().
    Hope that makes sense.
    <applet code="thread.class" height=400 width=400>
    </applet>
    import java.awt.Graphics;
    import java.awt.*;
    import java.awt.event.*;
    public class thread extends java.applet.Applet implements Runnable {
    int x = 200;
    int y = 200;
    int xTarg;
    int yTarg;
    int sleeper;
    boolean go;
    Thread first;
    public void start(){
    if(first == null); {
    first = new Thread(this);
    first.start();
    public void run(){
    while (first != null) {
    findTarg();
    try {
    Thread.sleep(sleeper);
    } catch (InterruptedException e) { }
    public void findTarg(){    
    if(go == true){
    sleeper = 10;
    if(x < xTarg)x++;
    if(x > xTarg)x--;
    if(y < yTarg)y++;
    if(y > yTarg)y--;
    repaint();
    if((x == xTarg)&&(y == yTarg))go = false;
    public boolean mouseDown(Event evt, int x, int y) {
    xTarg= x;
    yTarg= y;
    go = true;
    return true;
    public void paint(Graphics g) {
    g.setColor(Color.black);
    g.fillOval(x,y,20,20);
    }

    I've found another example and this time it extends JApplet. I'm sorry I can't help you more, but I'm new as well.
    // Fig. 15.7: RandomCharacters.java
    // Demonstrating the Runnableinterface
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class RandomCharacters extends JApplet
    implements Runnable,
    ActionListener {
    private String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    private JLabel outputs[];
    private JCheckBox checkboxes[];
    private final static int SIZE = 3;
    private Thread threads[];
    private boolean suspended[];
    public void init()
    outputs = new JLabel[ SIZE ];
    checkboxes = new JCheckBox[ SIZE ];
    threads = new Thread[ SIZE ];
    suspended = new boolean[ SIZE ];
    Container c = getContentPane();
    c.setLayout( new GridLayout( SIZE, 2, 5, 5 ) );
    for ( int i = 0; i < SIZE; i++ ) {
    outputs[ i ] = new JLabel();
    outputs[ i ].setBackground( Color.green );
    outputs[ i ].setOpaque( true );
    c.add( outputs[ i ] );
    checkboxes[ i ] = new JCheckBox( "Suspended" );
    checkboxes[ i ].addActionListener( this );
    c.add( checkboxes[ i ] );
    public void start()
    // create threads and start every time start is called
    for ( int i = 0; i < threads.length; i++ ) {
    threads[ i ] =
    new Thread( this, "Thread " + (i + 1) );
    threads[ i ].start();
    public void run()
    Thread currentThread = Thread.currentThread();
    int index = getIndex( currentThread );
    char displayChar;
    while ( threads[ index ] == currentThread ) {
    // sleep from 0 to 1 second
    try {
    Thread.sleep( (int) ( Math.random() * 1000 ) );
    synchronized( this ) {
    while ( suspended[ index ] &&
    threads[ index ] == currentThread )
    wait();
    catch ( InterruptedException e ) {
    System.err.println( "sleep interrupted" );
    displayChar = alphabet.charAt(
    (int) ( Math.random() * 26 ) );
    outputs[ index ].setText( currentThread.getName() +
    ": " + displayChar );
    System.err.println(
    currentThread.getName() + " terminating" );
    private int getIndex( Thread current )
    for ( int i = 0; i < threads.length; i++ )
    if ( current == threads[ i ] )
    return i;
    return -1;
    public synchronized void stop()
    // stop threads every time stop is called
    // as the user browses another Web page
    for ( int i = 0; i < threads.length; i++ )
    threads[ i ] = null;
    notifyAll();
    public synchronized void actionPerformed( ActionEvent e )
    for ( int i = 0; i < checkboxes.length; i++ ) {
    if ( e.getSource() == checkboxes[ i ] ) {
    suspended[ i ] = !suspended[ i ];
    outputs[ i ].setBackground(
    !suspended[ i ] ? Color.green : Color.red );
    if ( !suspended[ i ] )
    notify();
    return;
    }

  • Creating methods in an applet

    I am confused on how to create methods in an applet. I know how to create them in an application. However, if an applet, do you create the methods in the Class Header, after the init() method, or the paint (Graphics g) method.
    I am trying to create a method called StudentName where the Student name and class.
    I originally had the method in the class body but I received error messages -- mainly because I hadn't started the paint method yet.
    thanks for your help.
    Here is a sample of the code I am using:
    import javax.swing.*;
    import java.awt.Graphics;
    public class ClassAverageApplet extends JApplet
          String first,second, third, fourth,fifth, name, className;
          double a,b,c,d,e,f, sum;
        public void init() 
          ClassAverageApplet student = new ClassAverageApplet();
          name = JOptionPane.showInputDialog("Student's name please");
          className = JOptionPane.showInputDialog("Class");
          first = JOptionPane.showInputDialog("Please enter first Grade");
          a = Double.parseDouble(first);
          second = JOptionPane.showInputDialog("please enter second Grade");
          b = Double.parseDouble(second);
          third = JOptionPane.showInputDialog("please enter Third Grade");
          c = Double.parseDouble(third);
          fourth = JOptionPane.showInputDialog("please enter Fourth Grade");
          d = Double.parseDouble(fourth);
          fifth= JOptionPane.showInputDialog("please enter Fifth Grade");
          e = Double.parseDouble(fifth);
          f = (a + b + c + d + e)/5;
          sum = a + b + c + d + e;
       public void paint(Graphics g)
          public void StudentName()
             g.drawString("Student:    " + name,25,25);
             g.drawLine(25,25,70,25);
             g.drawString("Class:      " + className,25,40);
             g.drawLine(25,40,60,40);
           g.drawRect(15,10,300,150);
       if(f  > 89)
         student.StudentName();
    //I am replacing these next four statements with the StudentName method
       // g.drawString("Student:    " + name,25,25);
       // g.drawLine(25,25,70,25);
       // g.drawString("Class:      " + className,25,40);
       // g.drawLine(25,40,60,40);
        g.drawString("Your final grade is an A ",25,50);
        g.drawString("The sum of your grades out of 500 points is " + sum ,25,60);
        g.drawString("The grade average is " + f,25,70);
        g.drawString("Here are your grades for the class",70,90);
        g.drawLine(70,90,255,90);
        g.drawString("First Grade:    " + a,25,110);
        g.drawLine(25,110,90,110);
        g.drawString("Second Grade:   " + b ,25,120);
        g.drawLine(25,120,90,120);
        g.drawString("Third Grade:    " + c,25,130);
        g.drawLine(25,130,90,130);
        g.drawString("Fourth Grade:   " + d ,25,140);
        g.drawLine(25,140,90,140);
        g.drawString("Fifth Grade:    " + e,25,150);
        g.drawLine(25,150,90,150);
        }

    i don't think you know what you're talking about. there's no difference between the way you write an applet or application. one has an init() method one has main(String[] args) method. one extends applet, but i won't tell you which.
    i'm sure you need to define half of your methods inside the paint() method and the other half inside the init() method. it does matter what goes where as long as it's half and half. the important thing is to make sure you have an even number of methods, otherwise your applet will behave oddly.

  • Blu Ray Advice - Creating Menus

    Hi everyone,
    I am getting a new external Blu Ray burner for my mac pro. I want to also get a program that would help create menus. Need some advice for both purchases.
    Thanks so much,
    kennyjoey.

    How about Encore for authoring? And very nice integration to the rest of the Adobe Suite.

  • Create menus to run projects (4-8 in a menu)

    What feature in Captivate allows you to organize your
    projects (SWFs) into a menu so users can step through the related
    recordings one at a time (view, back, next). Please tell me it's
    not Menu Builder. ;-)
    I am evaluating Captivate 3 and am looking for something like
    Camtasia Theater where you drop your projects into a menu builder,
    sort them, title them, identify the links, and you are basically
    done.
    Surely there is has to be something like this for Captivate
    projects. I've seen menus like this online using Captivate
    projects, but they were definitely not made with Menu Builder. Is
    there a 3rd party tool or other Adobe application that does this?
    Captivate earns high marks for ease of use and generation of
    recorded demos, but I don't want to get stuck creating clinky
    website menus when a companion tool should do this in minutes with
    polished results.
    Thanks for any info.

    The way I've been doing it is with hyperlinks in an HTML
    page.
    Here's what I do:
    1) Publish your Captivate movies, and have Captivate produce
    a HTML page for each movie.
    2) Create a blank HTML page (i.e. in Dreamweaver).
    3) Create a menu in the HTML page. Each menu item is a
    hyperlink to each Capitvate HTML page.
    4) Edit the style of the HTML page menu. I usually do all
    edits in CSS, but you can use DHTML, images, etc.
    I've created some menus that look really good using CSS,
    borders, margins, backgrounds colors, etc. I've sometimes created a
    <frameset> - so I do not have to reproduce the menu on each
    page, and I load all the Captivate movies in one designated
    frameset page.
    You could also easily do this within Flash - and just link
    Flash buttons to the Captivate HTML pages.
    For navigation within one Captivate movie between slides - I
    have a product called the .
    Menu
    Wizard.

  • Problem with Photoshop created Menus

    One of the great features of Encore is that you can bring in HD content and create both a Blu-ray and a DVD from the same project. Unfortunatley this doesn't always work.
    I create most of my menus in photoshop and use text or round circles for navigation. If I create a menu that is sized for blu-ray (1440x1080) and then burn a standard widescreen DVD, the buttons or text sub-picture will be cut off. This problem exists in CS4 and is still there in CS5. I would often create HD sized DVD menus even for my DVDs in case the client would later want Blu-ray. For the longest time, I couldn't figure out why my circle buttons would be cut off. You really don't see the issue until the DVD is burned and it's played back in a DVD player. Once I re-sized the menu to standard def wide screen, everything comes out ok but I would like to be able to just create one size menu and use it for both DVD and Blu-ray. Anyone know a work-around?
    Thanks
    Chris

    Chris,
    The Scaling algorithms in PS are very powerful and offer so very much control. Those in PrPro are merely OK, as it is not an image editing program. Encore is even less an image editing program, so does not even have those Scaling algorithms, that PrPro does.
    All one has to do is Edit in Photoshop, Scale (choosing the best algorithm) and Save - done.
    Until Adobe decides to marry Encore with PS, I doubt that we'll see things in one place, but that Edit in Photoshop is so very easy.
    Good luck,
    Hunt

  • Can you create menus in InDesign 5.5?

    Does anyone know if you can create drop-down menus in InDesign5.5? I imagine I could use text buttons and line them up, but is there an easier way or am I in a Dreamweaver state of mind?

    Another question, if you don’t mind. Do you know if I make a change to a folio will that change be reflected on the end user iPad automatically. In other words will a change from our database be reflected automatically for the users or would they have to update the app?

  • Creating lines in an applet

    Hi,
    I was wondering how would I use the mouse to create lines between two vertices (also drawn by the mouse) within a Java applet. I need to be able to click on two different vertices and this should result in a line being drawn between them.
    I use the mouseDown handler and need to somehow get the x and y positions when the mouse is clicked so I can draw a line between two points. I have created this in a JFrame but use the mousePressed handler and hence can type
    xPos = e.getX() and yPos = e.getY(). Is there any way of doing the same thing using mouseDown.
    Here is the code
    public boolean mouseDown(Event e, int x, int y)
    xPos = e.x;
    yPos = e.y;
    int i;
    if (inter < max_number_of_vertices) {//draws the vertices
    inter++;
    circle_points[inter] = x;
    circle_points2[inter] = y;
    repaint();
    else {
    if (first_time == 0) {
    JOptionPane.showMessageDialog(null, "now enter your edges");
    first_time = 1;
    else if (click_Second_boolean == true) {
    second_click(); // the code for this is below
    testing++;
    else {
    first_click(); //the code for this below
    number_of_lines++;
    return true;
    ///this is the code for the methods first click and second click.
    public void first_click()
    closest_point = 100000;
    for(int i =0; i<max_number_of_vertices;i++)
    int compare1a = circle_points;
    int compare1b = circle_points2[i];
    double compare1_phy = Math.sqrt(((compare1a - xPos) *( compare1a - xPos ))+ ((compare1b -yPos ) *( compare1b -yPos)));
    if(compare1_phy < closest_point)
    closest_point = compare1_phy;
    closest_point_PT1 = i;
    lines_array[0][testing] = circle_points[closest_point_PT1];
    click_Second_boolean = true;
    void second_click()
    closest_point =10000;
    for(int i =0; i<max_number_of_vertices;i++)
    int compare2a = circle_points[i];
    int compare2b = circle_points2[i];
    double compare2_phy = Math.sqrt(((compare2a - xPos) *( compare2a - xPos ))+ ((compare2b -yPos ) *( compare2b -yPos)));
    if(compare2_phy < closest_point)
    closest_point = compare2_phy;
    closest_point_PT2 = i;
    lines_array[1][testing] = circle_points[closest_point_PT2];
    click_Second_boolean = false;
    first_matrix[closest_point_PT1][closest_point_PT2] = true;
    repaint();
    I then need to be able to use this as a matrix to do calculatoins on. Any help on this matter would be good.
    Thanks
    KP

    No matter what mouse event you use, you should be able to get the X,Y of the hit. You can then feed that into your app and draw a line between the two.

  • How to create a popup form applet to create a new record

    Hi,
    I have a requirement where on button click a popup form applet should open in new record mode by default. I will then enter details in that popup applet & on clicking the "Submit" button on that applet, the data gets saved to the corresponding table.
    I tried following options:
    1. Created a new control(button) on parent applet & specified the popup applet detail in its user property.
    Mode - Edit
    Popup - <name of the new popup applet>
    Popup Dimension - 500*300
    This configuration opens the new popup applet on button click but its in edit mode with the data of parent applet showing in it.
    2. modified the configuration to -
    changed the mode to "New".
    In the applet definition web template for the Edit web template,chosen mode type as New and for Edit list web template chosen the mode type as edit list.
    However, couldn't achieve what is intended. pls help.
    Thanks

    On Click on New button , you can invoke an applet based on VBC using showpopup and when the ok button is pressed , you can insert the record to the base bc.
    Regards,
    Vinod Nair

Maybe you are looking for