Delete scroller from other class

Hi.
I have FlashSite class where after clicking to button i see page with text and with scroll.
If i click to 'close' button i want removeChild this page, text and scroll.
But for scroll i use code from other class. (i insert this class like: import classes.Scroller.*;)
So, how i can remove this scroller?
code:
public function lilyContent():void
               // create a sample pane
               addChild(lilyPageScroll);
               lilyPageScroll.x = 360;
               lilyPageScroll.y = 400;
               // then attach a new scroller to the pane
               var lilyScroller = new Scroller(lilyPageScroll, lilyPageScroll.width, 540, new scrollerFace(),"vertical");
i use this line:
var lilyScroller = new Scroller(lilyPageScroll, lilyPageScroll.width, 540, new scrollerFace(),"vertical");
to add scroller.
all code for FlashSite class:
package
     import flash.display.*;
     import flash.text.*;
     import flash.events.*;
     import classes.Scroller.*;
     public class FlashSite extends MovieClip 
          var lilyDeskBack:LilyDescriptionBackground = new LilyDescriptionBackground();
          var lilyPageScroll = new LilyContent();
          //constructor
          public function FlashSite()
               stop();
               addEventListener(Event.ENTER_FRAME, flashSiteLoading);
          public function flashSiteLoading(event:Event)
               var mcBytesLoaded:int=this.root.loaderInfo.bytesLoaded;
               var mcBytesTotal:int=this.root.loaderInfo.bytesTotal;
               var mcKLoaded:int=mcBytesLoaded/1024;
               var mcKTotal:int=mcBytesTotal/1024;
               flashSiteLoading_txt.text="Loading: "+mcKLoaded+"Kb of "+mcKTotal+"Kb";
               if (mcBytesLoaded>=mcBytesTotal)
                    removeEventListener(Event.ENTER_FRAME, flashSiteLoading);
                    gotoAndPlay('welcomeSite');
                    lilyBtn.addEventListener(MouseEvent.CLICK, lilyDescription);
                    roseBtn.addEventListener(MouseEvent.CLICK, roseDescription);
                    jasmineBtn.addEventListener(MouseEvent.CLICK, jasmineDescription);
                    irisBtn.addEventListener(MouseEvent.CLICK, irisDescription);
          public function lilyDescription(event:MouseEvent):void
               trace("Lily description goes here.");
               roseBtn.visible = false;
               jasmineBtn.visible = false;
               irisBtn.visible = false;
               addChild(lilyDeskBack);
               lilyDeskBack.x = 350;
               lilyDeskBack.y = 330;
               lilyContent();
               lilyDeskBack.LilyDesckClose_btn.addEventListener(MouseEvent.CLICK, closeLilyDescription);
          public function closeLilyDescription(event:MouseEvent):void
               trace("close Lily description");
               removeChild(lilyDeskBack);
               removeChild(lilyPageScroll);
               lilyScroller.visible = false;
               roseBtn.visible = true;
               jasmineBtn.visible = true;
               irisBtn.visible = true;
          public function roseDescription(event:MouseEvent):void
               trace("Rose description goes here.");
          public function jasmineDescription(event:MouseEvent):void
               trace("Jasmine description goes here.");
          public function irisDescription(event:MouseEvent):void
               trace("Iris description goes here.");
          public function lilyContent():void
               // create a sample pane
               addChild(lilyPageScroll);
               lilyPageScroll.x = 360;
               lilyPageScroll.y = 400;
               // then attach a new scroller to the pane
               var lilyScroller = new Scroller(lilyPageScroll, lilyPageScroll.width, 540, new scrollerFace(),"vertical");
Thanks for help

Make the lilyScroller object a class level object.
Add to 'closeLilyDescription' method 'removeChild(lilyScroller);'
package
     import flash.display.*;
     import flash.text.*;
     import flash.events.*;
     import classes.Scroller.*;
     public class FlashSite extends MovieClip 
          var lilyDeskBack:LilyDescriptionBackground = new LilyDescriptionBackground();
          var lilyPageScroll = new LilyContent();
          var lilyScroller;
          //constructor
          public function FlashSite()
               stop();
               addEventListener(Event.ENTER_FRAME, flashSiteLoading);
          public function flashSiteLoading(event:Event)
               var mcBytesLoaded:int=this.root.loaderInfo.bytesLoaded;
               var mcBytesTotal:int=this.root.loaderInfo.bytesTotal;
               var mcKLoaded:int=mcBytesLoaded/1024;
               var mcKTotal:int=mcBytesTotal/1024;
               flashSiteLoading_txt.text="Loading: "+mcKLoaded+"Kb of "+mcKTotal+"Kb";
               if (mcBytesLoaded>=mcBytesTotal)
                    removeEventListener(Event.ENTER_FRAME, flashSiteLoading);
                    gotoAndPlay('welcomeSite');
                    lilyBtn.addEventListener(MouseEvent.CLICK, lilyDescription);
                    roseBtn.addEventListener(MouseEvent.CLICK, roseDescription);
                    jasmineBtn.addEventListener(MouseEvent.CLICK, jasmineDescription);
                    irisBtn.addEventListener(MouseEvent.CLICK, irisDescription);
          public function lilyDescription(event:MouseEvent):void
               trace("Lily description goes here.");
               roseBtn.visible = false;
               jasmineBtn.visible = false;
               irisBtn.visible = false;
               addChild(lilyDeskBack);
               lilyDeskBack.x = 350;
               lilyDeskBack.y = 330;
               lilyContent();
               lilyDeskBack.LilyDesckClose_btn.addEventListener(MouseEvent.CLICK, closeLilyDescription);
          public function closeLilyDescription(event:MouseEvent):void
               trace("close Lily description");
               removeChild(lilyDeskBack);
               removeChild(lilyPageScroll);
               removeChild(lilyScroller);
               lilyScroller.visible = false;
               roseBtn.visible = true;
               jasmineBtn.visible = true;
               irisBtn.visible = true;
          public function roseDescription(event:MouseEvent):void
               trace("Rose description goes here.");
          public function jasmineDescription(event:MouseEvent):void
               trace("Jasmine description goes here.");
          public function irisDescription(event:MouseEvent):void
               trace("Iris description goes here.");
          public function lilyContent():void
               // create a sample pane
               addChild(lilyPageScroll);
               lilyPageScroll.x = 360;
               lilyPageScroll.y = 400;
               // then attach a new scroller to the pane
               lilyScroller = new Scroller(lilyPageScroll, lilyPageScroll.width, 540, new scrollerFace(),"vertical");

Similar Messages

  • How  add buttons to Jframe from other class

    Hi, a have a little problem;)
    I want make a JFrame, but i want to add JButtons from other class. Now I have something like that:
    My JFrame class:
    package windoow;
    import javax.swing.*;
    import java.awt.*;
    public class MyWindow extends JFrame {
           Butt buttons ;
            public Window(String s) {
                     super(s);
                    this.setSize(600, 600);
                    this.setVisible(true);
                    Buttons();
                public void Buttons(){
                    setLayout(null);            
                   buttons = new Butt();
                   buttons.mywindow =this;
    } My class with buttons:
    package windoow;
    import javax.swing.JButton;
    public class Butt {
            MyWindow mywindow;
            JButton b1;
            Butt(){
                      b1 = new JButton("Button");
                      b1.setBounds(100,100,100,20);
                      mywindow.add(b1);  
    } and i have NullPointerException.
    When i try to make new MyWindow in Butt clas i have something like StackOverFlow.
    what should i do?

    Your null pointer exception is occuring because, in your Butt() constructor, you are calling mywindow.add(b1), but you don't set mywindow until after you call the constructor in the MyWindow::Buttons() method.
    And, if you try to create a new MyWindow() in your Butt() constructor, and, assuming that you are calling the MyWindow::Window(String s) method from the MyWindow() constructor (which is not clear from the code fragment you posted), then Butt() calls new MyWindow() which calls Window(String s) which calls Butt() which calls ... and so on, until the stack overflows.
    One possible solution ... pass your MyWindow reference into your Butt() constructor as this, as so:
    public void Buttons()
       // stuff deleted
      buttons = new Butt( this );
       // stuff deleted
    // AND
    Butt( MyWindow mw )
       // stuff deleted
      mywindow = mw;
      mywindow.add( b1 ); // b1 created in stuff deleted section  
    }Also, I would call setVisible(true) as the last thing I did during the construction of the frame. This realizes the frame, and from that point forward, most changes to the frame should be made on the event thread.
    ¦ {Þ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Calling a object of class from other class's function with in a package

    Hello Sir,
    I have a package.package have two classes.I want to use object of one class in function of another class of this same package.
    Like that:
    one.java
    package co;
    public class one
    private String aa="Vijay";  //something like
    }main.java:
    package co;
    import java.util.Stack;
    public class main extends Stack
    public void show(one obj)
    push(obj);
    public static void main(String args[])
    main oo=new main();
    }when I compile main class, Its not compile.
    Its give error.can not resolve symbol:
    symbol: class one
    location: class co.main
    public void show(one obj)
                              ^Please help How that compile "Calling a object of class from other class's function with in a package" beacuse I want to use this funda in an application

    kumar.vijaydahiya wrote:
    .It is set in environment variable.path=C:\bea\jdk141_02\bin;.,C:\oraclexe\app\oracle\product\10.2.0\server\bin;. command is:
    c:\Core\co\javac one.javaIts compiled already.
    c:\Core\co\javac main.javaBut it give error.
    Both java classes in co package.Okay, open a command prompt and execute these two commands:
    // to compile both classes:
    javac -cp c:\Core c:\Core\co\*.java
    // to run your main-class:
    java -cp c:\Core co.main

  • Set JComponent from other class

    Hi, I have problem from set any JComponent (JButton,JTable, etc.)
    in class from other class.
    I have class A. In class I have JButton and JTable. In this class I have function, in that are I create new instance class B. Class B have function, that are set properties any item in class A.
    class A
    function createAnotherClass(){
    B bclass = new B();
    bclass.setItemInClassA(this);
    function setItem(){
    jTable.setBackground(Color.RED);
    etc.
    class B
    function setItemInClassA(A a){
    a.setItem();
    This is only example, but I need your hepl. Thank you

    hahaha, yeah right,
    i think we do not understand your problem.

  • Accesing from other classes to protected void

    Hy! I'm a newbie to java programming. So i am making a program in J2ME, and the problem is :
    I have an abstract class, wich i must extend. That class defines a procedure
    abstract protected void destroyApp(boolean unconditional), so in my extended class this void is protected. But i want to access to this procedure from other class, and do it somehow static.
    I have made a main program class (the extended class), and i want to send from other class a destroy message to it (to call destroyApp procedure).
    Kazhha.

    Your question has nothing to do with Native Methods.
    In the future, for novice questions, use the New To Java Technology forum.
    I have an abstract class, which i must extend. That
    class defines a procedure
    abstract protected void destroyApp(boolean
    unconditional), so in my extended class this void is
    protected.You can make the method public in your class.
    But i want to access to this procedure
    from other class, and do it somehow static.IIRC you cannot make a method static if it is not static in the class you extend.
    I have made a main program class (the extended class),
    and i want to send from other class a destroy message
    to it (to call destroyApp procedure).Huh?

  • Making object accesible from other class?

    hi all
    how can i have an object of class to be accesible from other class?
    thanks

    It's not clear what you mean by "object of class". Do you mean fields within an object. Do you mean using an object of one class within the code of another?
    For most named objectes in java, whether field, method or class, there are four levels of access.
    public means accessible from anywhere in the program
    private means accessible only from the same source file.
    protected means only from the class, or a class that extends it.
    or if you don't put any of these keywords it means accessible only from the same package, that is set of source files in a single directory.

  • Method not accessible from other classes

    Hi,
    I ve defined a class and would like to create an instance of it from another class. That works fine, I am also able to access class variables. However the class method "calcul" which is defined as following, is not accessible from other classes:
    class Server {
    static String name;
    public static void calcul (String inputS) {
    int length = inputS.length();
    for (int i = 0 ; i < length; i++) {
    System.out.println(newServer.name.charAt(i)); }
    If I create an instant of the class in the same class, the method is then available for the object.
    I am using JBuilder, so I can see, which methods and variables are available for an object. Thanks for your help

    calcul is a static method, that means you do not need an instance of server to run this method. This method is also public, but your class Server is not, your Server class is package protected. So only classes within the same package has Server can use its method. How to use the calcul method?// somewhere in the same package as the Server class
    Server.calcul( "toto" );

  • How do i delete icould from other devices

    how do i delete icould from other devices???

    Welcome to the user to User Technical Support Forum provided by Apple.
    Clearly state your Issue and the Troubleshooting Steps you have tried to Resolve it.

  • How to delete file from other system(LAN)

    Hello folks,
    Cud u plz help me out in finding code for deleting a file from other system i.e in LAN,assuming that the connection is already established to that system.

    > Cud u plz
    sigh
    Please make the extra effort to write out words such as "could", "you", and "please". The extra keystrokes won't cost much in the way of time, and the enhanced clarity will be appreciated by those communicating on a forum with international readership. Also, it will give the appearance that you take your question seriously, which will in turn make your question look more interesting to answer.
    Thanks!
    ~

  • Flash Vars is not working when we accessing from other class files

    Hi all, I'm currently developing a flex application where i
    need to pass the data from the flash vars to the other class files
    instead of the main actionscript class file.
    Does any body know how i should go about doing that?? you can
    see this below code : please help me out if u know how to solve
    testnew2.as file
    package {
    import flash.display.Sprite;
    import flash.display.LoaderInfo;
    public dynamic class testnew2 extends Sprite {
    public var
    xmlfile:String=String(root.loaderInfo.parameters.lists);
    public function testnew ():void{
    package {
    import flash.text.TextField;
    import flash.display.Sprite;
    import flash.display.LoaderInfo;
    public dynamic class testnew extends testnew2 {
    public function testnew () {
    var myText:TextField = new TextField();
    // this assumes that you are going to pass in an id variable
    // on the end of the myFile.swf?id=12345 or
    // use FlashVars in the HTML parameter list for instance
    // 'FlashVars', 'id=123456', 'width', '1024',
    myText.text = new testnew2().xmlfile;
    addChild(myText);
    but if we access in same file it is working fine:
    package {
    import flash.text.TextField;
    import flash.display.Sprite;
    import flash.display.LoaderInfo;
    public dynamic class testnew extends Sprite {
    public function testnew () {
    var myText:TextField = new TextField();
    myText.text = String(root.loaderInfo.parameters.lists);
    addChild(myText);

    Pass the data into the main app, then from there either pass
    it into the sub-components or use
    Application.application.parameters, or bind to the values.
    Tracy

  • Calling repaint from other Class file.

    Hi,
    First of all i am pretty new to Java so I hope you understand what I am trying to explain..
    I am trying to create an applet which draws some polygons on the screen. For the drawing of these polygons I have created another class which is located in another package but the same project. I plan to use this second package as some kind of library so that i can simple call 2 or 3 functions in future applets to draw these polygons (which always have the same shape). In the library file i have created a contructor, a draw function and some other functions to change some properties. I also created a function that created a popup window as soon as i click on one of the polygons i have created. In the popup some buttons are available which change the color of the polygon. All this works fine, but the problem i have is the following:
    When i click a button the main class (in package 1) needs to be repainted for the changes to be visable. But the main class can always be a different one. Is it possible to check in the class in the library package, which class from the main package called the class, and execute a repaint() on that class. So i have the following situation:
    Package 1 (Applets):
    package applets;
    class myApplet extends Applet implements .... {
    private Tank tank1 = new Tank(20, 20, 100, 200);
    private Tank tank2 = new Tank(250, 20, 100, 200);
    public void paint(Graphics g) {
    tank1.drawTank(g);
    tank2.drawTank(g);
    public void mouseClicked(MouseEvent e) {
    tank1.openWindow();
    tank2.openWindow();
    Package 2 (Library):
    package applets.library;
    class Tank {
    public Tank(int xPos, int yPos, int height, int width) {
    public void drawTank(Graphics g) {
    public void openWindow() {
    new myWindow("Window1");
    public class myWindow extends Frame {
    public myWindow(String name) {
    show();
    public boolean action(Event e, Object arg) {
    return true;
    So what i want to do is: In class Tank in the public class myWindow in the method action, i want to call the repaint() of the class myApplet
    I hope my problem is clear to you, as you may have noticed i have a little trouble explaining it clearly..

    First of all thanks a lot for your reply and sorry for my way of programming. Like i said i am pretty new to Java, i am actually only programming for about 2 weeks and trying to learn from some examples on the internet.
    I dont really understand what you want me to do, is it maybe possible to give a little bit of sample code? That would help me a lot.
    Maybe some background information about the project will help a bit too.
    I work at a company that develops automation solutions. We program PLC's and SCADA systems. Now Siemens has some PLC's that support Java applets which make it possible to visualize industrial processes. Now i am trying to figure out if it is possible to start developing own java applets for visualisation in the future. Since most programmers here have no experience in any higher programming language i want to keep it as simple as possible, by developing libraries that do the most of the programming work for them.
    Now i want to create the first part of this library by programming some kind of storage tank. This tank always has a valve. when i click on the valve a popup should open with the operation button to open of close that valve. When a valve is opened it should be colored green and when its closed it should be colored gray or something. The Tank class has a couple of methods:
    drawTank(); to draw the tank in my applet,
    openValve(); to open the Valve,
    closeValve(); to close the Valve,
    After all this is created i want to be able to use this class in all my other classes and create a tank by simple making a new Tank object, draw it on my applet using the drawTank() method and open or close the Valve using the other 2 methods, however when i open or close the Valve the color of the valve should change so i must be able to call the repaint of all the classes that use my Tank class, but i want to do that INSIDE my Tank class.
    If there is another way of doing this i would love to hear so, but i would help me a lot if you can explain in a little bit of sample code. It doesn't have to be really long or detailed.
    Thnx in advance

  • Accessing public variables from other classes

    Probably a simple questions, but how can I access a variable from another class. My exact situation is as follows.
    A class called WorldCalender has a variable which is defined: public int hour; (the value is given to it elsewhere).
    I want to access this variable and increase it by one in a subroutine in the class Hour. In this class I have put: WorldCalender.hour++; but it doesn't seem to work. How should I do it?

    don't expose the hour variable at all.
    have a method eg addToHourBy( int hrs )
    Probably a simple questions, but how can I access a
    variable from another class. My exact situation is as
    follows.
    A class called WorldCalender has a variable which is
    defined: public int hour; (the value is given to it
    elsewhere).
    I want to access this variable and increase it by one
    in a subroutine in the class Hour. In this class I
    have put: WorldCalender.hour++; but it doesn't seem to
    work. How should I do it?

  • Accessing string from other classes

    Sorry if this seems simple to you, but i'm having problems accessing four string that are declared and used in my public class from another class.
    I've tried declaring the strings public but it still says 'cannot resolve symbol' when i try to compile.
    Help much appreciated.
    fightspam

    Yep, heres my code(sorry if it's a bit untidy):
    //Zimmerman M3 email client.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    class where extends JFrame implements ActionListener
         private JLabel path;
         private JTextField pathText;
         private String pathFile;
         private JButton save;
         File outputFile = new File(pathFile);
         public where()
              super("Save Email");     
              Container f=getContentPane();
                   f.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
              f.setBackground(Color.lightGray);
              path = new JLabel("Path: ");
              f.add(path);
              pathText = new JTextField(20);
              f.add(pathText);
              save = new JButton("Save");
              f.add(save);
              this.setSize(300, 100);
         public void actionPerformed(ActionEvent q)
              pathFile = pathText.getText();
              try
                   FileWriter out = new FileWriter(outputFile);
                   out.write(zimmernorm.toFile);
                   out.write(zimmernorm.fromFile);
                   out.write(zimmernorm.subjectFile);
                   out.write(zimmernorm.bodyFile);
                   out.close();
              catch(IOException err)
                   System.exit(0);
    class about extends JFrame
         private JLabel title;
         public about()
              super("About Zimmerman M3");
              Container d=getContentPane();
                   d.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
              d.setBackground(Color.lightGray);
              title = new JLabel("Zimmerman M3 by Louis Goddard, 2003");
              d.add(title);
              this.setSize(246, 62);
    class newmail extends JFrame implements ActionListener
         public static String toFile, fromFile, subjectFile, bodyFile;
         public JTextField To, From, Subject;
         private String toBuffer, fromBuffer, subjectBuffer, bodyBuffer;
         private JButton send, clear;
         private JTextArea Body;
         private JLabel toLabel, fromLabel, subjectLabel;
         private JMenuBar mb;
         private JMenu File, Edit;
         private JMenuItem New, Sender, Copy, Paste, About;
         public newmail()
                    super("New Email");
              Container c=getContentPane();
                   c.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
              c.setBackground(Color.lightGray);
              //<MENU STUFF!!!>     
                   mb = new JMenuBar();
                   File = new JMenu("File");
                   Edit = new JMenu("Edit");
                   New = new JMenuItem("New");
                   Sender = new JMenuItem("Save");
                   Copy = new JMenuItem("Copy");
                   Paste = new JMenuItem("Paste");
                   File.add(New);
                   New.addActionListener(this);
                   New.setActionCommand("1");
                   File.add(Sender);
                   Sender.addActionListener(this);
                   Sender.setActionCommand("2");
                   Edit.add(Copy);
                   Copy.addActionListener(this);
                   Copy.setActionCommand("3");
                   Edit.add(Paste);
                   Paste.addActionListener(this);
                   Paste.setActionCommand("4");
                   mb.add(File);
                   mb.add(Edit);
                   setJMenuBar(mb);
              //</MENU STUFF!!!>     
              toLabel = new JLabel("To:          ");
              c.add(toLabel);
              To = new JTextField(35);
              c.add(To);
              fromLabel = new JLabel("From:     ");
              c.add(fromLabel);
              From = new JTextField(35);
              c.add(From);
              subjectLabel = new JLabel("Subject:");
              c.add(subjectLabel);
              Subject = new JTextField(35);
              c.add(Subject);
              Body = new JTextArea(12,40);
              c.add(Body);
              send = new JButton("Send");
                    c.add(send);
              clear = new JButton("Clear");
                    c.add(clear);
              clear.addActionListener(this);
              clear.setActionCommand("6");
              this.setSize(459, 364);
              public static void main(String []args)
                   JFrame.setDefaultLookAndFeelDecorated(true);
                   new newmail().show();
              public void actionPerformed(ActionEvent e)
                   String s = e.getActionCommand();
                   if (s == ("1"))
                   new newmail().show();
                   else if (s == ("2"))
                   new where().show();
                   toFile = To.getText();
                   fromFile = From.getText();
                   subjectFile = Subject.getText();
                   bodyFile = Body.getText();
                   else if (s == ("3"))
                   bodyBuffer = Body.getSelectedText();
                   toBuffer = To.getSelectedText();
                   fromBuffer = From.getSelectedText();
                   subjectBuffer = Subject.getSelectedText();
                   else if (s == ("4"))
                   Body.setText(bodyBuffer);
                   To.setText(toBuffer);
                   From.setText(fromBuffer);
                   Subject.setText(subjectBuffer);
                   else if (s == ("5"))
                   new about().show();
                   else if (s == ("6"))
                   To.setText("");
                   From.setText("");
                   Subject.setText("");
                   Body.setText("");
    public class zimmernorm extends JFrame implements ActionListener
         public String toFile, fromFile, subjectFile, bodyFile;
         private String toBuffer, fromBuffer, subjectBuffer, bodyBuffer;
         private JMenuBar mb;
         private JMenu File, Help, View;
         private JMenuItem New, About, Inboxmenu, Outboxmenu, Savedmenu;
         public zimmernorm()
                    super("Zimmerman M3");
              Container c=getContentPane();
                   c.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
              c.setBackground(Color.lightGray);
              //<MENU STUFF!!!>     
                   mb = new JMenuBar();
                   File = new JMenu("File");
                   View = new JMenu("View");
                   Help = new JMenu("Help");
                   New = new JMenuItem("New");
                   About = new JMenuItem("About");
                   Inboxmenu = new JMenuItem("Inbox");
                   Outboxmenu = new JMenuItem("Outbox");
                   Savedmenu = new JMenuItem("Saved");
                   File.add(New);
                   New.addActionListener(this);
                   New.setActionCommand("1");
                   Help.add(About);
                   About.addActionListener(this);
                   About.setActionCommand("5");
                   View.add(Inboxmenu);
                   Inboxmenu.addActionListener(this);
                   Inboxmenu.setActionCommand("7");
                   View.add(Outboxmenu);
                   Outboxmenu.addActionListener(this);
                   Outboxmenu.setActionCommand("8");
                   View.add(Savedmenu);
                   Savedmenu.addActionListener(this);
                   Savedmenu.setActionCommand("9");
                   mb.add(File);
                   mb.add(Help);
                   mb.add(View);
                   setJMenuBar(mb);
              //</MENU STUFF!!!>     
              this.setSize(1024, 768);
                    this.setDefaultCloseOperation( EXIT_ON_CLOSE );
              public static void main(String []args)
                   JFrame.setDefaultLookAndFeelDecorated(true);
                   new zimmernorm().show();
              public void actionPerformed(ActionEvent e)
                   String s = e.getActionCommand();
                   if (s == ("1"))
                   new newmail().show();
                   else if (s == ("5"))
                   new about().show();

  • Handeling EventListeners given from other classes...

    Hello again,
    I got the folloing Problem:
    I've got a Frame-Class, with calls a Class from jPanel, this Panel has a button.
    My Problem is this, Is there a way, to handle the button-event from the Parent-Frame?
    Means this:
    MyPanel mp = new MyPanel();
    this.add(mp);
    // Here to wait for the button event, and do something.
    If anybody has a solution, thx alot.

    don't expose the hour variable at all.
    have a method eg addToHourBy( int hrs )
    Probably a simple questions, but how can I access a
    variable from another class. My exact situation is as
    follows.
    A class called WorldCalender has a variable which is
    defined: public int hour; (the value is given to it
    elsewhere).
    I want to access this variable and increase it by one
    in a subroutine in the class Hour. In this class I
    have put: WorldCalender.hour++; but it doesn't seem to
    work. How should I do it?

  • Calling methods from other classes

    I have a bunch of little java files in a folder, do I need to make a package in order to access all the methods in all the classes, or can I just make an instance of any of the methods because all the classes are in the same folder?

    HI,
    If your methods have a "public" modifier (and the class does too) then you can instantiate your classes as objects from that (so-called) "default" package in any other class or object in any other package and then call the methods on those instantiated objects as you please.
    If that sounds confusing... I'd seriously try the excellent tutorials at this site, especially "the java tutorial".
    /k1

Maybe you are looking for