Welcome to Dream.In.Code
Become a Java Expert!

Join 149,609 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,859 people online right now. Registration is fast and FREE... Join Now!




error while writing MenuFrame:MenuFrame.class<Access is denied>

 
Reply to this topicStart new topic

error while writing MenuFrame:MenuFrame.class<Access is denied>, A error while running java program

mrithula
17 Sep, 2007 - 07:01 PM
Post #1

New D.I.C Head
*

Joined: 16 Sep, 2007
Posts: 11


My Contributions
Hi,friends...

I hav a doubt in the following code....

if i run the code below...i get the following error
fullmenu.java:33:error while writing MenuFrame:MenuFrame.class<Access is denied>
class MenuFrame extends Frame implements ActionListener
^
1 error..
CODE

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class fullmenu extends Applet implements ActionListener
{
     Button button1,button2;
     MenuFrame fullmenuWindow;

     public void init(){
             button1=new Button("Show full menu window");
             add(button1);
             button1.addActionListener(this);

             button2=new Button("Hide full menu window");
             add(button2);
             button2.addActionListener(this);

             fullmenuWindow=new MenuFrame("Full menus");
             fullmenuWindow.setSize(100,100);
}
public void actionPerformed(ActionEvent event)
{
     if(event.getSource()==button1)
     {
        fullmenuWindow.setVisible(true);
     }
     if(event.getSource()==button2)
     {
        fullmenuWindow.setVisible(false);
     }
}
}
class MenuFrame extends Frame implements ActionListener
{
      Menu Menu1,SubMenu1;
      MenuBar Menubar1;
      TextField text1;
      MenuItem menuitem1,menuitem2,menuitem4;
      CheckboxMenuItem menuitem3;

      MenuFrame(String title){
             super(title);
             text1=new TextField("Full menu");
             setLayout(new GridLayout(1,1));
             add(text1);
             Menubar1=new MenuBar();
             Menu1=new Menu("File");
            
             menuitem1=new MenuItem("Item1");
             menuitem1.addActionListener(this);
             Menu1.add(menuitem1);
    
             menuitem2=new MenuItem("Item2");
             menuitem2.addActionListener(this);
             Menu1.add(menuitem2);

             Menu1.addSeparator();

             menuitem3=new CheckboxMenuItem("Check Item");
             menuitem3.addActionListener(this);
             Menu1.add(menuitem3);

             Menu1.addSeparator();

             SubMenu1=new Menu("Sub menus");
             SubMenu1.add(new MenuItem("Hello"));
             SubMenu1.add(new MenuItem("from"));
             SubMenu1.add(new MenuItem("java"));

             Menu1.add(SubMenu1);
             Menubar1.add(Menu1);
             setMenuBar(Menubar1);

             Menu1.addSeparator();

             menuitem4=new MenuItem("Exit");
             menuitem4.addActionListener(this);
             Menu1.add(menuitem4);
}
public void actionPerformed(ActionEvent event)
{
           if(event.getSource()==menuitem1)
           {
              text1.setText("Item1");
           }
           if(event.getSource()==menuitem2)
           {
              menuitem2.setEnabled(false);
              text1.setText("Item2");
           }
           if(event.getSource()==menuitem3)
           {
              ((CheckboxMenuItem)event.getSource()).setState(true);
           }
           if(event.getSource()==menuitem4)
           {
                setVisible(false);
}
}
}

User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Error While Writing MenuFrame:MenuFrame.class<Access Is Denied>
17 Sep, 2007 - 10:12 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Are you running this in some IDE? I have compiled your code and it is working fine for me. No errors. This would lead me to the conclusion that you are using an IDE and it is a problem with that IDE or you are not testing it properly in a browser and with the latest java virtual machine.

As I said before, this code works fine, no errors and presents me with a window which will show and hide a java window. If you can't seem to get it to work, drop the code into notepad and do a compile then and I am sure it will work for you after that.

Good luck to you. smile.gif
User is offlineProfile CardPM
+Quote Post

mrithula
RE: Error While Writing MenuFrame:MenuFrame.class<Access Is Denied>
18 Sep, 2007 - 07:04 PM
Post #3

New D.I.C Head
*

Joined: 16 Sep, 2007
Posts: 11


My Contributions
QUOTE(Martyr2 @ 17 Sep, 2007 - 11:12 PM) *

Are you running this in some IDE? I have compiled your code and it is working fine for me. No errors. This would lead me to the conclusion that you are using an IDE and it is a problem with that IDE or you are not testing it properly in a browser and with the latest java virtual machine.

As I said before, this code works fine, no errors and presents me with a window which will show and hide a java window. If you can't seem to get it to work, drop the code into notepad and do a compile then and I am sure it will work for you after that.

Good luck to you. smile.gif


Thank u....
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 12:14AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month