JTextfield  listening for changes from other class

Hi,
Assuming I have a Jtextfield in one of the class1 extend Jframe,
how do I update the jtextfield so that it could up make accessible by other class and continuously updated to reflect the input for value rom another class2.
In other words very much similar to the observable model view concept
class 1 may be look like
private void initComponents() {
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextField1.setEditable(false);
class 2 may be look similar to the following
public void out_1(){
setStop1("N");
for (int i=1;i<100;i++){
class_1.getJTextField1().setText(String.valueOf(i)); // System.out.println(i);
setOuti(i);
setStop1("N");

HI,
I have attempted with the following coding , test 1 the source display generated using Netbeans GUI , t est2 the worker code ,and mybean the bean , so far nothing seems to work .
I have not try the threaded swing concept as I am not familar with the concurrency but i am not sure whether propertylistener will do the job or not
In summary , list of method employed are :
binding the jtextfield1 to a bean,
jtextfield add document listener ,
Coding objective
1. Test 1 defined jtexfield1 and jbutton
2 Jbutton added actionlistener , where upon click,
Execute Test 2 which will assign a series of integer to the bean , own setters & getters, Output is achieved via Test 1 jtextfield1 supposingly to display all the running number from 1 to 99 continuously until the test2 out_1 method finished the execution
Anyone could provide the assistance .
Thank
* Test_1.java
* Created on July 25, 2007, 9:23 PM
package sapcopa;
import java.beans.PropertyChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import sapcopa.MyBean.*;
public class Test_1 extends javax.swing.JFrame {
/** Creates new form Test_1 */
// private Test_2 t2=new Test_2();
private String input_txt;
public Test_1() {
myBean1=new MyBean();
myBean1.addPropertyChangeListener(new java.beans.PropertyChangeListener(){
public void propertyChange(java.beans.PropertyChangeEvent evt) {
bean_chg(evt);
initComponents();
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
myBean1 = new sapcopa.MyBean();
jTextField1 = new javax.swing.JTextField();
jTextField1.getDocument().addDocumentListener(new MyDocumentListener());
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextField1.setEditable(false);
jTextField1.setText(myBean1.getRecord_Process());
jTextField1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
txt1_chg(evt);
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
But1(evt);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(jButton1)))
.addContainerGap(131, Short.MAX_VALUE))
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(21, 21, 21)
.addComponent(jButton1)
.addContainerGap(216, Short.MAX_VALUE))
pack();
}// </editor-fold>//GEN-END:initComponents
private void txt1_chg(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_txt1_chg
// TODO add your handling code here:
//myBean1=new MyBean();
try {
jTextField1.setText(myBean1.getRecord_Process());
} catch (Exception e){
e.printStackTrace();
}//GEN-LAST:event_txt1_chg
private void bean_chg(java.beans.PropertyChangeEvent evt){
jTextField1.setText(myBean1.getRecord_Process());
private void But1(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_But1
//getJTextField1().getDocument().addDocumentListener(new MyDocumentListener());
Test_2 t2=new Test_2();
t2.out_1();
try{
System.out.println("Button 1 mybean->"+myBean1.getRecord_Process());
} catch (Exception e){
e.printStackTrace();
// TODO add your handling code here:
}//GEN-LAST:event_But1
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Test_1().setVisible(true);
public javax.swing.JTextField getJTextField1() {
return jTextField1;
public void setJTextField1(javax.swing.JTextField jTextField1) {
this.jTextField1 = jTextField1;
class MyDocumentListener implements DocumentListener {
final String newline = "\n";
public void insertUpdate(DocumentEvent e) {
// updateLog(e, "inserted into");
String vstr=myBean1.getRecord_Process().toString();
jTextField1.setText(vstr);
public void removeUpdate(DocumentEvent e) {
//updateLog(e, "removed from");
String vstr=myBean1.getRecord_Process().toString();
jTextField1.setText(vstr);
public void changedUpdate(DocumentEvent e) {
//Plain text components don't fire these events.
String vstr=myBean1.getRecord_Process().toString();
jTextField1.setText(vstr);
public void updateLog(DocumentEvent e, String action) {
Document doc = (Document)e.getDocument();
int changeLength = e.getLength();
// jTextField1.setText(String.valueOf(changeLength));
String vstr=myBean1.getRecord_Process().toString();
jTextField1.setText(vstr);
public String getInput_txt() {
return input_txt;
public void setInput_txt(String input_txt) {
this.input_txt = input_txt;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JTextField jTextField1;
private sapcopa.MyBean myBean1;
// End of variables declaration//GEN-END:variables
* Test_2.java
* Created on July 25, 2007, 9:26 PM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package sapcopa;
import sapcopa.MyBean.*;
public class Test_2 {
private Test_1 t1=new Test_1();
private int outi;
private String stop1;
MyBean mybean;
/** Creates a new instance of Test_2 */
public Test_2() {
public void out_1(){
setStop1("N");
mybean=new MyBean();
for (int i=1;i<100;i++){
mybean.setRecord_Process(String.valueOf(i));
setOuti(i);
setStop1("N");
setStop1("Y");
public int getOuti() {
return outi;
public void setOuti(int outi) {
this.outi = outi;
public String getStop1() {
return stop1;
public void setStop1(String stop1) {
this.stop1 = stop1;
* MyBean.java
* Created on July 24, 2007, 12:00 AM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package sapcopa;
import javax.swing.JTextField;
public class MyBean {
/** Creates a new instance of MyBean */
public MyBean() {
* Holds value of property record_Process.
private JTextField txt_rec_process;
private String record_Process;
* Utility field used by bound properties.
private java.beans.PropertyChangeSupport propertyChangeSupport = new java.beans.PropertyChangeSupport(this);
* Adds a PropertyChangeListener to the listener list.
* @param l The listener to add.
public void addPropertyChangeListener(java.beans.PropertyChangeListener l) {
propertyChangeSupport.addPropertyChangeListener(l);
* Removes a PropertyChangeListener from the listener list.
* @param l The listener to remove.
public void removePropertyChangeListener(java.beans.PropertyChangeListener l) {
propertyChangeSupport.removePropertyChangeListener(l);
* Getter for property record_Process.
* @return Value of property record_Process.
public String getRecord_Process() {
return this.record_Process;
* Setter for property record_Process.
* @param record_Process New value of property record_Process.
public void setRecord_Process(String record_Process) {
String oldRecord_Process = this.record_Process;
this.record_Process = record_Process;
propertyChangeSupport.firePropertyChange("record_Process", oldRecord_Process, record_Process);
* Holds value of property rec_Match.
private String rec_Match;
* Getter for property rec_Match.
* @return Value of property rec_Match.
public String getRec_Match() {
return this.rec_Match;
* Setter for property rec_Match.
* @param rec_Match New value of property rec_Match.
public void setRec_Match(String rec_Match) {
String oldRec_Match = this.rec_Match;
this.rec_Match = rec_Match;
propertyChangeSupport.firePropertyChange("rec_Match", oldRec_Match, rec_Match);
public JTextField getTxt_rec_process() {
return txt_rec_process;
public void setTxt_rec_process(JTextField txt_rec_process) {
JTextField oldTxt_rec_process=this.txt_rec_process;
this.txt_rec_process = txt_rec_process;
propertyChangeSupport.firePropertyChange("txt_rec_process", oldTxt_rec_process, txt_rec_process);
}

Similar Messages

  • How do I listen for changes in a container's components?

    I have a JScrollPane that contains a JTextPane. I want any Container that can possibly contain my JScrollPane to be able to listen for changes in the JTextPane's Document.
    For example, at the moment I'm using a JTabbedPane to hold a number of my JScrollPanes and I want to alter the tab title when any associated JScrollPane-JTextPane-Document is updated.
    Any suggestions on how best to handle this?

    I would use a controller object that manages all your gui components (tabs, scrolls, documents, text panes). Your controller object can register as a listener to the appropriate component, and when it changes, update the title of a tab (or do whatever else) as appropriate.
    Never put business logic like this stuff inside the actual gui components. Create, layout, etc. all the gui components (and related components like Document) from another controller like object instead. It makes handling the various listener stuff like this much easier. Read up on MVC (model view controller) stuff for more info.
    As for the actual mechanics, you could get the document that is used in the JTextPane and register as a DocumentListener. As a document listener, you get notified of all changes that are made to that document.

  • How do I listen for change in the global position of a Node

    Hi there,
    I want to create a Wire/Connection node between two scene nodes. I want this Wire node to be updated when one of the nodes is moving. In the common scenario I would listen for change events in the target nodes position and update the Wire :
    targetNode1.translateXProperty().addListener(new ChangeListener<Number>() {
    public void changed(ObservableValue value, Number oldValue, Number newValue) {             
    wire.setStartX(targetNode1.getTranslateX());
    wire.setStartX(targetNode1.getTranslateY());
    wire.setEndX(targetNode2.getTranslateX());
    wire.setEndY(targetNode2.getTranslateY());
    The problem is that the target nodes are children of another container nodes(that are actually moving). So listening for change events in the translate properties of the target nodes does not work(their parent nodes are actually moving)
    Is there way to listent for change in the global position of the target nodes relative to the Scene?

    It sounds very similar to a problem I posted about earlier...
    How to implement a UI similar to a UML Diagram with connections?
    I ended up making my own special bounds property, that updates when the parent's special bounds property changes.
    I also had to listen to the parentProperty change event to add/remove my listener on the parent node.
    All in all, a pain in the butt. There should be an easier way.
    The shortcoming of the solution is that all the nodes in the hierarchy must have my special bounds property implemented (ie. they're all classes under my codebase such that I can implement it), which for the moment is true... I'd like a cleaner solution however.

  • Listen for Events from anywhere

    Hello!
    I have an application with a rather complicated component hierarchy.
    How can I have it so that I can listen for events from any component in any component, regardless of who is who's child?
    Thank you!

    You need a broadcasting mechanism.
    Many architecture framework offers this facility, but as a quick hack you can try something like
    public class Broadcaster extends EventDispatcher  ( singleton anti pattern   )
    instance
    then just do Broadcaster.instance.addEventListener or removeEventListener. it's a crappy singleton, but at least it does not hold any global state.
    I've also seen people use Application.application to dispatch/listen globally but really don't like it.
    Note : Use weak references or your views will never be eligible for garbage collections.

  • Listening for Changes to JTextArea

    I am writing a program that listens for changes to the contents of a JTextArea to obtain input for its execution. But I have implemented DocumentListener, PropertyChangeListener to listen for changes to the JTextArea for deriving input without success. Please could anyone advice on what to do.
    My code is below.
       myListener implements DocumentListener{
       JTextArea txt = new JTextArea();
       txt.getDocument().addDocumentListener(this);
       public void changedUpdate(DocumentEvent e){}
       public void removeUpdate(DocumentEvent e){} 
       public void insertUpdate(DocumentEvent e){
        try{
         //my code for obtaining input from txt is here
         int start = e.getOffset();
         Document doc = e.getDocument();
        }catch(BadLocationException ble){
    }

    Here's a link to the Swing tutorial on "How to Write a Document Listener":
    http://java.sun.com/docs/books/tutorial/uiswing/events/documentlistener.html

  • Listening for UncaughtErrorEvents from SubApp loaded by SWFLoader

    I can't seem to get my uncaughtErrorEvents listener to fire when attached to the loader.uncaughtErrorEvents  or loaded content's loaderInfo.uncaughtErrorEvents when loading a swf via SWFLoader.
    I have a main Flex Application ('A.swf') loading a SubApplication  (defined in' B.swf') via a SWFLoader and I need to listen for  UncaughtErrorEvent from the SubApplication. I'm not able to get my event  listeners to be called when I throw an error from within the SubApp  ('B.swf').
    After reading the asDoc for UncaughtErrorEvent and  UncaughtErrorEvents It states that the UncaughtErrorEvent should go through the normal capture, target, and bubble phases through the loaderInfo hierarchy. This doesn't seem to be the case or I'm not understanding the documentation/usage.
    I have added an event listener to A.swf's loaderInfo  (The 'outter' main app) and also to B.swf's loaderInfo (though the Docs  say not to do it here it is part of the event sequence in the capture  and bubble phase...) as well as the SWFLoader internal  FlexLoader.uncaughtErrorEvent (per Docs) like so:
    SWFLoader's internal FlexLoader uncaughtErrorEvents
    swfLoader.content.loaderInfo.loader.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorFunction );
    and the loaded SWF's loaderInfo:
    swfLoader.content.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorFunction );
    When I throw an Error from the SubApplication (B.swf). Only the 'outter' main app's (A.swf) event listener gets called. Which you expect, at first, if it is in the capture phase, but it isn't in that eventPhase at all. When debugging the eventPhase is in the EventPhase.AT_TARGET phase while being handled by A.swf's LoaderInfo, howeever the ASDoc says the Target phase should be B.swf's LoaderInfo.
    Is this a bug between Flash player and Flex where the event isn't flowing correctly as stated in the ASDoc for UncaughtErrorEvent?

    Thanks for the reply Alex.
    The Outer main swf and the SubApp swf are in different ApplicationDomains (sibilings to each other) so they should not be sharing the class that is throwing the error. I should note that these two Applications are purely based on MX components, this is important later on.
    I was originally throwing the error from a Button click handler from B.swf:
    <mx:Button label="Throw Error" click="callLater( throwUncaughtError )" />
    I was wrapping the handler function in a callLater because without it the error is not caught at all and the default flash dialog console just appears with the error. The A.swf's loaderInfo.uncaughtErrorEvents handler was not even firing unless I wrapped it a callLater.
    I realized that Flash Builder's default to link the 4.1 SDK library via Runtime shared libraries was what was causing the A.swf's loaderInfo.uncaughtErrorEvent to fire in the AT_TARGET phase when using callLater. This is because the UIComponent's callLater method queue structure is shared between the two SWFs and therefore inside a function executing off the method queue A.swf's loaderInfo IS the TARGET... explainable, but at first thought that isn't how I'd expect this to work.
    I then decided to test this out by setting the SDK library to merge into the code for both A.swf and B.swf and removing the  callLater. IT WORKS!  B.swf's (the SubApp) loaderInfo.uncaughtErrorEvents handler fires and I prevent the default (flash error console from appearing) and can stopImmediatePropagation so A.swf's loaderInfo.uncaughtErrorEvents handler doesn't fire.
    Perfect besides having to merge the SDK libraries into each swf independently.... size killer.
    In summary, using the same exact code for A.swf and B.swf:
    1. When the SDK libraries are RSL - no UncaughtErrorEvents, neither A.swf's or B.swf's, is called. Instead the default flash error console appears with no chance to handle the uncaught error.
    2. When the SDK libraries are Merged into the code - both A.swf's and B.swf's uncaughtErrorEvents  will be called, according to the asDoc documented sequence; B.swf's uncaughtErrorEvents in the AT_TARGET phase and A.swf's uncaughtErrorEvents in the BUBBLE phase.
    Moreover, if I build a pure Spark implementation everything works even when referencing the SDK libraries as RSL.
    Does this indicate a bug in the globalplayer (flash player code)'s logic for handling UncaughtErrorEvents listeners within the loaderInfo hierarchy when the Flex SDK is Shared code between the SWFs?
    OR
    Since it works in Spark, is it an issue with how the flex2.compiler.mxml.Compiler turns MX based mxml components into generated AS classes (it hooks up the inline event listeners of child UIComponentDescriptor using a generic object and the click function is specified as a STRING and has to use untyped bracket notation to lookup on the UICompoent when adding it as a listener:
    new mx.core.UIComponentDescriptor({
                  type: mx.controls.Button
                  events: {
                    click: "___B_Button1_click"
                  propertiesFactory: function():Object { return {
                    label: "Throw Error"
    Where as Spark does this correctly and generates Factory functions for setting up child UIComponents when converting Spark component mxml to AS:
    private function _B_Button1_c() : spark.components.Button
        var temp : spark.components.Button = new spark.components.Button();
        temp.label = "Throw Error";
       temp.addEventListener("click", ___B_Button1_click);
        if (!temp.document) temp.document = this;
        mx.binding.BindingManager.executeBindings(this, "temp", temp);
        return temp;
    * @private
    public function ___B_Button1_click(event:flash.events.MouseEvent):void
        throwUncaughtError()
    Sadly, moving to pure Spark would be a big hit is my project's schedule and at this point and likely isn't feasible. I have examples (with view source) built in MX for both the RSL and MERGE cases, I just don't know how to attach them here.
    Sorry for the long comments and thanks again!

  • Any way to listen for changes in Spark TextArea?

    Hello,
    What is the best way to listen for changes in a Spark TextArea? My scenario is simple: I need to know when some text is added or deleted (with from/to index).
    Regards,
    Dinko

    s:TextArea does have a chang event - http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/TextAr ea.html.

  • 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.
    ¦ {Þ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • 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");

  • 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.

  • ProgressMonitor in thred, call from other class

    Hi all
    I have a problem using the ProgressMonitor... I just want to update the progress from another class.
    So what i was thinking was:
    I could implement a method that invoked the thread, and thereby updating the progress.
    The problem occurs when the calculating steps is going. The parent class calls ProgressDiff fine but it doesn't update it, it doesn't even show anything. Just when the task is finished it says, simulation done!!
    I have tried searching alot on these forums, and on google, but all methods implementing progressmonitor uses a call from within the class. <- Not what I want. :=)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.beans.*;
    public class ProgressDiff extends JFrame {
        public ProgressMonitor progressMonitor;
         public int tll;
        public ProgressDiff(int maks, String set) {
              super("Progress");
              setSize(250, 100);
            progressMonitor = new ProgressMonitor(null,
                                      "Differentiere og l�ser\n" + set,
                                      "", 0, maks);
            progressMonitor.setProgress(0);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setProgressTal(0, false);
              setLocationRelativeTo(null);
              setVisible(true);
        public void setProgressTal(int fremGang, boolean done) {
              tll = fremGang;
              SwingUtilities.invokeLater(new Update());
              if (done) {
                   Toolkit.getDefaultToolkit().beep();
                   JOptionPane.showMessageDialog(null,
                        "Simuleringen er f�rdig."
                        , "F�rdig",
                        JOptionPane.INFORMATION_MESSAGE);
         class Update implements Runnable {
            public void run() {
                   if (progressMonitor.isCanceled()) {
                   Toolkit.getDefaultToolkit().beep();
                   JOptionPane.showMessageDialog(null,
                        "Simuleringen er f�rdig."
                        , "F�rdig",
                        JOptionPane.INFORMATION_MESSAGE);
                   } else {
                        progressMonitor.setProgress(tll);
                        progressMonitor.setNote(String.format("Completed %d%%.\n", tll));
    }Any help would be apreciable!!
    Thx.

    Thx for the reply, I now have a working Progressmonitor which i easily can control
    import java.awt.Toolkit;
    import javax.swing.ProgressMonitor;
    *  Use of a ProgressMonitor. This class implements an easy to use progressmonitor for use in other classes.
    * @author     Nick Andersen
    * @created    4. marts 2008
    * @version    1.00
    public class ProgressMonitorSetup {
         private ProgressMonitor progressMonitor;
         private String title;
         private int min;
         private int progress;
         private int max;
         private String note;
         private String complete;
         private String cancel;
         private String completeTotal;
          * Constructor af ProgressMonitorSetup
         public ProgressMonitorSetup() {
              title = "K�rsel af langt job";
              min = 0;
              max = 100;
              complete = "Fremgang: ";
              cancel = "Job afbrudt.";
              completeTotal = "Job f�rdigt.";
              note = "";
          * Constructor af ProgressMonitorSetup
          * @param  title          The title in Progressmonitor
          * @param  min            The minimum value in the progressmonitor
          * @param  max            The maximum value in the progressmonitor
          * @param  complete       Beskrivelse af Parameteren
          * @param  completeTotal  Beskrivelse af Parameteren
          * @param  cancel         Beskrivelse af Parameteren
         public ProgressMonitorSetup(String title, int min, int max, String complete, String completeTotal, String cancel) {
              this.title = title;
              this.min = min;
              this.progress = min;
              this.max = max;
              this.complete = complete;
              this.completeTotal = completeTotal;
              this.cancel = cancel;
              note = "";
          *  S�tter title attributten af ProgressMonitorSetup object
          * @param  title  Den nye title v�rdi
         public void setTitle(String title) {
              this.title = title;
          *  S�tter minimum attributten af ProgressMonitorSetup object
          * @param  min  Den nye minimum v�rdi
         public void setMinimum(int min) {
              this.min = min;
          *  S�tter maximum attributten af ProgressMonitorSetup object
          * @param  max  Den nye maximum v�rdi
         public void setMaximum(int max) {
              this.max = max;
          *  S�tter runningComplete attributten af ProgressMonitorSetup object
          * @param  complete  Den nye runningComplete v�rdi
         public void setRunningComplete(String complete) {
              this.complete = complete;
          *  S�tter complete attributten af ProgressMonitorSetup object
          * @param  completeTotal  Den nye complete v�rdi
         public void setComplete(String completeTotal) {
              this.completeTotal = completeTotal;
          *  S�tter cancel attributten af ProgressMonitorSetup object
          * @param  cancel  Den nye cancel v�rdi
         public void setCancel(String cancel) {
              this.cancel = cancel;
          *  Returnere cancel attributten af ProgressMonitorSetup object
          * @return    cancel v�rdi
         public String getCancel() {
              return cancel;
          *  Returnere done attributten af ProgressMonitorSetup object
          * @return    done v�rdi
         public boolean isDone() {
              if (progress >= max) {
                   progressMonitor.close();
                   return true;
              } else {
                   return false;
          *  METODEN
         public void close() {
              progressMonitor.close();
          *  METODEN
         public void initProgressMonitor() {
              progressMonitor = new ProgressMonitor(null,
                   title, note,
                   min, max);
              progressMonitor.setMillisToDecideToPopup(100);
              progressMonitor.setMillisToPopup(100);
              progressMonitor.setProgress(min);
          *  S�tter progress attributten af ProgressMonitorSetup object
          * @param  i  Den nye progress v�rdi
          * @return    Beskrivelse af den Returnerede V�rdi
         public String setProgressMessage(int i) {
              progress = i;
              progressMonitor.setProgress(progress);
              note = complete + progress + " af " + max;
              progressMonitor.setNote(note);
              if (progressMonitor.isCanceled() || isDone()) {
                   Toolkit.getDefaultToolkit().beep();
                   if (progressMonitor.isCanceled()) {
                        progress = max++;
                        return cancel;
                   } else {
                        return completeTotal;
              return note;
          *  S�tter progress attributten af ProgressMonitorSetup object
          * @param  i  Den nye progress v�rdi
         public void setProgress(int i) {
              progress = i;
              progressMonitor.setProgress(progress);
              note = complete + progress + " af " + max;
              progressMonitor.setNote(note);
              if (progressMonitor.isCanceled() || isDone() ) {
                   Toolkit.getDefaultToolkit().beep();
                   if (progressMonitor.isCanceled()) {
                        progress = max++;
                   } else {
    }Sry about the comment, and the danish... But this works really nice, if you place the swingworker around the method needing progressmonitor.

  • 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" );

  • Scope statement for Change From Prior Year

    Hello All,
    I have to create Current Year, Prior year  and change from Prior year for all the measures. I was able to creat current Year and Prior Year calcuation with scope statemnet. But I could not do the same for Change from Prior year.  I am getting 0 for
    all the months.
    Here is what i have:
    SCOPE([LABEL].[LABEL].&[ChangeFromPY])
    THIS=
    AGGREGATE(
    [DATE DT].[Date_Hierarchy].CURRENTMEMBER,
    [LABEL].[LABEL].&[Current Year]
    AGGREGATE(
    PARALLELPERIOD
    [DATE DT].[Date_Hierarchy].[Year], 1, [DATE DT].[Date_Hierarchy].CURRENTMEMBER),
    [LABEL].[LABEL].&[Prior Year]

    Hi Om25,
    According to your description, the Prior year calculation works on Excel, however, it not works when creating dashborad in performance Point, right? In this case, you can create separate measures for Prior Year in Cube, and use it in performance Point directly.
    Here is a link that might helpful for you, please see:
    http://www.bidn.com/blogs/cprice1979/ssas/2473/fun-with-mdx-ndash-part-3-ytd-and-prior-ytd-calculations
    Regards,
    Charlie Liao
    TechNet Community Support

  • 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

Maybe you are looking for