Event model for multiple components

Hi
For some time now I have been searching on the net for a proper way to do following:
I have a class that extends a JFrame. In it I instantiate and add two more classes ControlPanel and CanavasPanel which extend from JPanel...
All these are in SEPARATE files...My ControlPanel class has buttons that when clicked are supposed to draw different objects on the CanavasPanel...
How do I fire a method in my CanavasPanel class when a button is clicked in ControlPanel class??? These are all in separate files and I am looking for a solution that does not uses inner and anonymous classes..If I implement ActionListener in ControlPanel class I know a way of referencing CanavasPanel class so I can fire its methods...
Is it doable? And if so can someone explain to me what needs to be done.

Try out this way:
The below code is not complete code (where ever is ... it is fill in blanks):
public class MyFrame extends JFrame{
protected ControlPanel buttonPanel;
protected CanvasPanel canvasPanel;
public MyFrame(){  
// Initialize panels
canvasPanel = new CanvasPanel(...);
buttonPanel = new ButtonPanel(...);
// Set layout
this.getContentPane().setLayout(new BorderLayout())
/*----------- CHECK THIS --------*/
// Assuming Control Panel has some method used to add listener
// to draw button
// ex: setDrawButtonActionListener(ActionListener al){}
buttonPanel.setDrawButtonActionListener(new MyDrawActionListener());
// Now add panels
this.getContentPane().add(buttonPanel,BorderLayout.SOUTH);
this.getContentPane().add(canvasPanel,BorderLayout.CENTER);\
} // Constructor MyFrame
class MyDrawActionListener implements ActionListener{
public void actionPerformed(ActionEvent ae){
// Make sure that the canvas panel is initialized
if (canvasPanel != null){
canvasPanel.drawSomething();
}else{
// Your error message display here
} // Class MyDrawActionListener
} // Class MyFrame
Hope this helps.

Similar Messages

  • Logging same NC code for multiple components

    Hi,
    When logging NC codes in SAP ME 6.0 it is possible to log the same NC Code (defect) against many ref-des for
    multiple components.
    However when logging a secondary code (Action) for the previous primary NC Code all the choosen ref-des and components
    don't get copied..
    Is this how it is supposed to work or is there a setting somewhere so that all ref-des and components gets copied?
    Best Regards,
    Johan Nordebrink

    Hi Johan,
    The matter of your question is related to Ref Des List re-desinged for 6.0.
    Overall situation looks like a design gap because:
    - no explicit statement in the documentation describing the case of copying multiple Ref Des'es;
    - the case of 1-to-1 relation between Component and Ref Des is mentioned in the context of auto-population of these feilds on tabbing out if one of the field is populated;
    - the case of single Ref Des is widely referenced in the context of VTR that is a new feature in 6.0.
    So, if you need this to be reviewed by Product Mgmt (maybe they agreed to identify this as a bug), as usually you should either ask your SAP ME Consulting representative or submit a support ticket (depending on whom you pefer to talk with ).
    Regards,
    Sergiy

  • Using models for multiple one-to-many table relationships

    Hi there!
    I have a database with tables that have one-to-many relationships. They
    are laid out with a standard join tables:
    A     A_B     B     B_C     C
    a_id     a_id     b_id     b_id     c_id
    b_id     c_id
    and has 1 A for n of B. In some cases, the B table also joins with
    another table for yet more information.
    My question: what technique should I use to organize a database of this
    type into JATO Models?
    I could create an AModel, for example, that would have a set of query
    field descriptors for the information relevant from tables A and B. But
    then how do I query table C when that information is necessary? Or,
    more to the point, create information in C when a new entry in B is created.
    Do the models use each other, or is that left up to the view bean (seems
    incorrect for data isolation).
    Any pointers appreciated,
    Byron

    Byron,
    You can create a separate "modifying" model for each table and do
    inserts/deletes/updates in a transaction across the tables with the
    three models. That's really the easy part.
    The somewhat more tedious part is the "join" models, but not hard to do.
    You just have to decide what you need from the different tables and
    quite possibly create multiple join models for different select scenarios.
    So let's just run through a simple two table join model.
    Create a SQL model. I usually name them based on the table joins. Let's
    use a somewhat more real example:
    table = customer
    columns = custid, firstname, lastname, email
    table = address
    columns = addrid (seqid), custid (fk), type
    ('w'ork,'h'ome,'b'illing,'s'hipping,'o'ther), address1, address2, city,
    state, zip
    Suppose we want to select a customer and show a list of all his/her
    addresses.
    I would create a SQL model class (extending QueryModelBase of course)
    called CustomerAddressJoinModel (this naming convention gets tough with
    three or more tables, so you have to be creative).
    In that model, I would create the fields just like any single table
    model. You need only include the columns you need. Maybe you create one
    join model that only has custid, lastname, firstname, type, city, zip.
    OK, so we only cut out 2 columns, but you get the point. If you had a
    table with lots of columns with data you rarely need to display and/or
    update, then you can exclude them. Probably a slick way to exclude
    dynamically, but this is straight forward.
    Another join model could have all the columns of both tables.
    So the trick is to set the static where criteria (using the
    setStaticWhereCriteria method) in the model's constructor. I think the
    sql model template has this in it.
    setStaticWhereCriteria(customer.custid=address.custid);
    Now you just set your criteria like any other model, and execute it.
    For a 3 table join, you just set the static criteria like this:
    tableA.aid=tableB.aid AND tableB.bid=tableC.bid
    does that make sense?
    You can also set the "modifying table" (setModifyingTable(table) - i
    think that's right) in the model and inserts/updates/deletes will only
    operate on that table within the model. Problem is maybe in the the
    field binding in your views. You may want to select from one field, and
    modify using another field. Can be done though, just not directly supported.
    In the next release of JATO, you will be able to set a display fields
    binding for read and write using different fields and even different models.
    craig
    Byron Servies wrote:
    Hi there!
    I have a database with tables that have one-to-many relationships. They
    are laid out with a standard join tables:
         A     A_B     B     B_C     C
         a_id     a_id     b_id     b_id     c_id
         b_id     c_id
    and has 1 A for n of B. In some cases, the B table also joins with
    another table for yet more information.
    My question: what technique should I use to organize a database of this
    type into JATO Models?
    I could create an AModel, for example, that would have a set of query
    field descriptors for the information relevant from tables A and B. But
    then how do I query table C when that information is necessary? Or,
    more to the point, create information in C when a new entry in B is created.
    Do the models use each other, or is that left up to the view bean (seems
    incorrect for data isolation).
    Any pointers appreciated,
    Byron
    To download the latest version of JATO, please visit:
    http://www.sun.com/software/download/developer/5102.html
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp

  • TREX for multiple components

    Hello,
    we plan to deploy several NetWeaver Components (BW, EP, HR-e-recruitment, MDM), which all need TREX. The requirements for each system are relatively small, so we think about installing one TREX-system for all components. Is this feasible, does anybody have experience with this scenario? What if on of the connected components is upgraded or another component has to be added later on?
    thanks in advance for your input
    Richard

    Richard,
    We have deployed DEV and QA systems for e-recruitment V3.0 that share the same TREX 6.1 resource for candidate search functionality.  The only limitation that we experienced was that in the original planning, we were going to combine DEV / QA e-recruitment on a single server.  It was not able to be done based on a hard coded port used for communication between e-recruitment and TREX.
    Phil

  • Use event function for multiple events

    I've got several movieclip buttons on stage. For one of those buttons I've started of with:
    button1.buttonMode = true;
    button1.useHandCursor = true;
    button1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    function fl_ClickToDrag(event:MouseEvent):void
              button1.startDrag();
    stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
    function fl_ReleaseToDrop(event:MouseEvent):void
              button1.stopDrag();
    Which works. But I would like to have that fl_ClickToDrag function excuted for all my other buttons too, so I don't have to duplicate that several times for each button. So I thought I use something like:
    button1.buttonMode = true;
    button1.useHandCursor = true;
    button2.buttonMode = true;
    button2.useHandCursor = true;
    button1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    button2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    function fl_ClickToDrag(event:MouseEvent):void
      event.target.startDrag();
    stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
    function fl_ReleaseToDrop(event:MouseEvent):void
      event.target.stopDrag();
    But that gives an error. What's the correct way?

    Actually I got it working by using:
    button1.buttonMode = true;
    button1.useHandCursor = true;
    button2.buttonMode = true;
    button2.useHandCursor = true;
    button1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    button2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    function fl_ClickToDrag(event:MouseEvent):void
      event.currentTarget.startDrag();
    stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
    function fl_ReleaseToDrop(event:MouseEvent):void
      stopDrag();

  • Explicit Event Enabling for Swing Components

    Hi all swing-experts,
    I want to enable some events for an JInternalFrame explicitely,
    but I can't find the corresponding EVENT_MASK anywhere...
    Who knows??
    Anja

    Hello again,
    (besonderes HALLO an Stephen fuer die Muehe!!!)
    there exist two ways of handling an event, at least for awt events:
    1) writing an action listener and adding it to the component who will handle the event
    2) letting the component handle the event itself by "explicit event enabling"
    I am talking about no 2.
    This works so:
    a) Subclass component
    b) in the constructor of the subclass, call
    enableEvents(AWTEvent.XXX_EVENT_MASK)
    c) provide the subclass with a processXXXEvent() method (that should call the superclass' version of this method)
    An other version of my question: is this also possible with Swing?
    Where do I find the appropriate XXX_EVENT_MASK and processXXXEvent method?
    Seems to be an unusual problem...
    Anja
    PS: sieht so aus...

  • Determine event handler for swing components from the API browser

    Is there a way to determine what event handlers are assocaited with the different swing classes. For example JTextField is associated to ActionListener, and JCheckbox uses the event handle ItemListener. Is there a way to determine this by looking at the class via the Java API?

    Yes, there is. You'll observe that JTextField has an "addActionListener(ActionListener)" method, for a start. And JTextField is a subclass of JTextComponent, which has "addCaretListener(CaretListener)" and "addInputMethodListener(InputMethodListener)" methods. And JTextComponent is a subclass of JComponent, which has an "addAncestorListener(AncestorListener)" method. And so on... there are more. All of this can be found in the API documentation by looking for methods whose names start with "add".

  • Help to find 40107 model for Multisim 9

    Hello!
    can somebody help me to find 40107 Multisim model?
    or even though SPICE model.
    tnx

    I have searched the Web and I can't find any spice models for this component. It looks like you may have to use the datasheet and see if you can create it.  Sometimes the manufacturers just don't make spice models for certain components. I do not know if this is because they can't model it in spice or just do not wish to take the time to make one.
    Kittmaster's Component Database
    http://ni.kittmaster.com
    Have a Nice Day

  • Need help with EVENT BOOKING: option for multiple, payment (pay pal standard or pro only) add cost, etc

    Hello!
    I'm at my wits end: please help! It seems straight forward, and I sold my client on BC thinking this was doable in the events module, but it seems maybe not so without a ton of custom coding.
    1. Book an event online,
    with option for multiple (say 1-5 people at a fixed cost per person),
    and checkout using only Pay Pal (standard or pro, doesn't matter, but I think Standard won't work without shopping cart).
    2. The events are every day but Sunday all year long (just admission to an attraction), so is there a way to upload months in advance so they don't have to be manually entered?
    I'm so grateful for any assistance.

    This is all very achievable:
    • Events you can add multiple people to book.
    • PayPal you use use our APP that's in the BC Appstore (Liam to confirm is works with bookings)
    I'm sales and marketing at Pretty, so I'm not the person to advise on how all this fits together. But I'm sure Liam can point you in the right direction.
    If you need some consulting or us to do it for you just let me know [email protected]
    Brett
    www.prettydigital.com.au

  • Job not getting triggered for Multiple Scheduler Events

    hi,
    I would like a job to be triggered for multiple scheduler events, subscribing to a single event works fine. But, when I set multiple event condition, nothing works.
    My objective is to run a job, whenever job starts or restarts or exceeds max run duration.
    Note : Is it possible to trigger a job, when a job RESTARTS by subscribing to JOB_START ????????
    procedure sniffer_proc(p_message in sys.scheduler$_event_info)
    is
    --Code
    end sniffer_proc
    dbms_scheduler.create_program(program_name => 'PROG',
    program_action => 'sniffer_proc',
    program_type => 'stored_procedure',
    number_of_arguments => 1,
    enabled => false);
    -- Define the meta data on scheduler event to be passed.
    dbms_scheduler.define_metadata_argument('PROG',
    'event_message',1);
    dbms_scheduler.enable('PROG');
    dbms_scheduler.create_job
    ('JOB',
    program_name => 'PROG',
    * event_condition => 'tab.user_data.event_type = ''JOB_OVER_MAX_DUR''' ||*
    *' or tab.user_data.event_type = ''JOB_START''',*
    queue_spec => 'sys.scheduler$_event_queue,auagent',
    enabled => true);
    I tried this too...
    dbms_scheduler.create_job
    ('JOB',
    program_name => 'PROG',
    * event_condition => 'tab.user_data.event_type = ''JOB_OVER_MAX_DUR''' ||*
    *' and tab.user_data.event_type = ''JOB_START''',*
    queue_spec => 'sys.scheduler$_event_queue,auagent',
    enabled => true);
    Need help
    Thanks...
    Edited by: user602200 on Dec 28, 2009 3:00 AM
    Edited by: user602200 on Dec 28, 2009 3:03 AM

    Hi,
    Here is complete code which I tested on 10.2.0.4 which shows a second job that runs after a first job starts and also when it has exceeded its max run duration. It doesn't have the condition but just runs on every event raised, but the job only raises the 2 events.
    Hope this helps,
    Ravi.
    -- run a job when another starts and exceeds its max_run_duration
    set pagesize 200
    -- create a user just for this test
    drop user test_user cascade;
    grant connect, create job, create session, resource,
      create table to test_user identified by test_user ;
    connect test_user/test_user
    -- create a table for output
    create table job_output (log_date timestamp with time zone,
            output varchar2(4000));
    -- add an event queue subscriber for this user's messages
    exec dbms_scheduler.add_event_queue_subscriber('myagent')
    -- create the first job and have it raise an event whenever it completes
    -- (succeeds, fails or stops)
    begin
    dbms_scheduler.create_job
       ( 'first_job', job_action =>
         'insert into job_output values(systimestamp, ''first job runs'');'||
         'commit; dbms_lock.sleep(70);',
        job_type => 'plsql_block',
        enabled => false, repeat_interval=>'freq=secondly;interval=90' ) ;
    dbms_scheduler.set_attribute ( 'first_job' , 'max_runs' , 2);
    dbms_scheduler.set_attribute
        ( 'first_job' , 'raise_events' , dbms_scheduler.job_started);
    dbms_scheduler.set_attribute ( 'first_job' , 'max_run_duration' ,
        interval '60' second);
    end;
    -- create a simple second job that runs when the first starts and after
    -- it has exceeded its max_run_duration
    begin
      dbms_scheduler.create_job('second_job',
                                job_type=>'plsql_block',
                                job_action=>
        'insert into job_output values(systimestamp, ''second job runs'');',
                                event_condition =>
       'tab.user_data.object_name = ''FIRST_JOB''',
                                queue_spec =>'sys.scheduler$_event_queue,myagent',
                                enabled=>true);
    end;
    -- this allows multiple simultaneous runs of the second job on 11g and up
    begin
      $IF DBMS_DB_VERSION.VER_LE_10 $THEN
        null;
      $ELSE
        dbms_scheduler.set_attribute('second_job', 'parallel_instances',true);
      $END
    end;
    -- enable the first job so it starts running
    exec dbms_scheduler.enable('first_job')
    -- wait until the first job has run twice
    exec dbms_lock.sleep(180)
    select * from job_output;

  • Coalescing events from multiple components in a JPanel

    Hi,
    I've got a JPanel based form with several components (mostly JTextField) and I'd like to be able to have component events bubble up to the parent JPanel. By comparison to MFC, if I have a dialog box with several controls all of the control events will continue to percolate upwards until they are handled. Is there any such possibility with Swing?
    Ideally I would like it if all component events were routed to a single listener in the parent JPanel, all I really need to do (initially) is set a boolean to note that a change may have been made. Do I have to explicitly set a handler for each component or is there way to automagically have the parent to catch the events from its child components?
    Thanks!
    jam

    Thanks jvaudry, this is kinda what I suspected. It seems somewhat cumbersome to have to set up a listener for each of the many JTextField's in my form but definitely wrapping all of that up in a class is a good way to go. I'm pretty new to Swing and usually when something seems harder than it should it's a sure sign that I just don't know how to do it right :)
    I may try an altogether different approach just for curiousity's sake. I'm thinking of adding a method to the parent JPanel that will iterate all of its text fields and create a checksum of their combined contents. The idea is that I will compute the checksum once after populating the form and then later to see if any of the fields have changed. A simple notion that may not turn out to be so simple once I get to coding, but it's worth a try.
    Thanks!
    jam

  • Events cannot have multiple exceptions for the same date

    I just starting getting this message and could not sync to one of my Google calendars. I'm posting this for others who might get the same problem.
    I didn't find the answer on these forums but did find it on this thread on Google:
    http://www.google.com/support/forum/p/Calendar/thread?tid=241155f758d9e2a4&hl=en
    Here's the important excerpt:
    "I had a client, who just had this same issue, nothing to do with Google cals.
    It was apparently, in my best guess, a corruption of the subscribed cal.
    *I did a get info on the cal, copied the URL, deleted the cal, then re-subscribed to it by pasting in the URL, and now it's working fine*."

    I've been having the same problem with my iCal calendars and the "Events cannot have multiple exceptions for the same date" error. Once it gets going, it uses up a lot of the CPU and resources. After reinstalling iCal, all my calendars were missing and I could not even resubscribe to them.
    I took my MacBook Pro to the Apple Store, and they were able to solve the problem by moving some of the iCal files from their existing folders out to the desktop, and reopening the program. That got it working, however, now I'm having the same problem again. So back to square one. Anyone else having this issue and know the cause?
    My setup is my MacBook Pro uses Entourage, use that calendar in my iCal. And I subscribe to two calendars my wife publishes on her Macbook. We're both using Snow Leopard.

  • Drag and Drop of multiple components at once

    Hi everybody,
    I need to select and drag multiple components (Eg. JLabels) at once, it is quite simple to manage just one drag at a time but how can be managed a multiple drag?
    I mean something like Windows files selection mechanism : using Ctrl + Left mouse click to select the components and then start dragging them all to the drop target.
    Beneath the code I'm using for testing , clicking and dragging each JLabel to JTextField just cause the copy of JLabel text to the JTextField contents.
    In the sample a left click on each displayed label sets a border just to identify the selected status of the labels to drag but there's no implementation of the drop mechanism that should copy all the selected JLabels text to the drop target (the JTextField).
    import java.awt.Dimension;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.util.HashMap;
    import javax.swing.BorderFactory;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.TransferHandler;
    import javax.swing.UIManager;
    import javax.swing.border.Border;
    import javax.swing.border.CompoundBorder;
    import javax.swing.border.EmptyBorder;
    public class SelectableJLabel extends JPanel {
      MouseListener listener = new DragMouseAdapter();
      public Border getBorder(boolean getSelectedBorder) {
        Border outsideBorder = BorderFactory.createEmptyBorder(2,2,2,2);
        Border insideBorder = BorderFactory.createEmptyBorder(2,2,2,2);
        if (getSelectedBorder)
          insideBorder = BorderFactory.createEtchedBorder();
        return BorderFactory.createCompoundBorder(outsideBorder, insideBorder);
      private class DragMouseAdapter extends MouseAdapter {
        public void mousePressed(MouseEvent e) {
          System.out.println("Press!");
          JComponent c = (JComponent) e.getSource();
          JLabel lbl = (JLabel)c;     
          if (lbl.getBorder()==null || ((CompoundBorder)lbl.getBorder()).getInsideBorder() instanceof EmptyBorder) {
            lbl.setBorder(getBorder(true));
            TransferHandler handler = c.getTransferHandler();
            handler.exportAsDrag(c, e, TransferHandler.COPY);    
          } else
            lbl.setBorder(getBorder(false));        
        /* (non-Javadoc)
         * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
        @Override
        public void mouseClicked(MouseEvent e) {
      public JLabel getSelectableLabel() {
        JLabel selectableJLabel = new JLabel("You can't select me");
        selectableJLabel.setBorder(getBorder(false));
        selectableJLabel.setTransferHandler(new TransferHandler("text"));
        selectableJLabel.addMouseListener(listener);
        return selectableJLabel;
      public SelectableJLabel() {
        // a regular JLabel
        add(getSelectableLabel());
        add(getSelectableLabel());
        add(getSelectableLabel());
        // a look-alike JLabel
        JTextField f = new JTextField("You can select me........................");
        f.setDragEnabled(true);
        //f.setEditable(false);
        f.setBorder(null);
        f.setForeground(UIManager.getColor("Label.foreground"));
        f.setFont(UIManager.getFont("Label.font"));
        add(f);
      public Dimension getPreferredSize() {
        return new Dimension(100, 100);
      public static void main(String s[]) {
        JFrame frame = new JFrame("SelectableJLabel");
        SelectableJLabel panel = new SelectableJLabel();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(panel, "Center");
        frame.setSize(panel.getPreferredSize());
        frame.setVisible(true);
    }Tnx in advance for HELP
    Massimo
    Edited by: JKut on May 2, 2010 10:48 AM

    For multiple selections I recommend to use "JList". The "ListTransferHandler" provided in the "DropDemo" sample code supports multiple selections: [http://java.sun.com/docs/books/tutorial/uiswing/dnd/dropmodedemo.html]. To enable MULTIPLE_INTERVAL_SELECTION, simply remove the following statement in the "DropDemo" class:
            list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

  • Event dispatching to swing components

    Hi,
    I'm implementing an extension of JTextPane, and I would like to make it as much reusable as possible.
    In order to do this, the class don't have to know about the external world (components)..
    The class should notify events (e.g. an event could be that a specific string has been typed..) to the other components just sending a message (or event), and all the components registered to that specific event implement their behavior to react to it.. quite simple..
    which is the simplest solution in Java to do this?
    thanks in advance..

    You should implement event dispatching based on the listener model, for consistency. Since you are extending JTextPane, a lot of the event dispatching code is written for you. Look up JTextPane in the javadocs and check out all the classes it is derived from. To take advantage of the already written listener code, simply call the appropriate fireWhateverEvent method whenever something happens. That will cause the event to be dispatched to all listeners registered with that component. If you want to define some new events that aren't covered by any of the listener methods in any of the classes your new class is derived from, here's the general way to do it:
    1) Define a new listener interface that implements the EventListener interface (which contains no methods).
    2) In your new listener interface, include methods for specific events, such as keyPressed, actionPerformed, textTyped, etc...
    3) Each of these methods should take a single parameter describing the event. This parameter should be a class that extends EventObject and that contains data relevant to your event. For example, you may define a TextEvent class that extends EventObject. The only methods EventObject has is getSource() and toString(). You won't really need to override these as long as you call the EventObject(Object) constructor from your TextEvent constructors.
    4) In your JTextPane derived class, define methods that can add, remove, and get a list of all registered event listeners for your event (ex: void addTextListener(TextListener t), void removeTextListener(TextListener t), TextListener[] getTextListeners()).
    5) add*Listener should add the listener to an internal list of listeners (a LinkedList or a Vector are good ways to store the registered listener lists). remove*Listener should remove the listener from the list, and get*Listeners should return the list in array form.
    6) For ease-of-use, define a fire method like fireTextListener(params), which creates a new TextEvent (assuming you're doing the TextListener thing) holding the specified event data and iterates through the internal list of listeners, calling the appropriate method in each one and passing your TextEvent to it.
    7) Call your fire*Event functions wherever appropriate to fire events.
    It's simpler than it sounds. Here's a small example:
    // TextListener.java
    public class TextListener implements EventListener {
        public void textInserted (TextEvent e);
        public void textDeleted  (TextEvent e);
    // TextEvent.java
    public class TextEvent extends EventObject {
        protected int    pos0;
        protected int    pos1;
        protected String text;
        public TextEvent (Object source, int pos0, int pos1, String text) {
            super(source);
            this.pos0 = pos0;
            this.pos1 = pos1;
            this.text = (text != null) ? text : "";
        public TextEvent (Object source, int pos0, int pos1) {
            this(source, pos0, pos1, null);
        public int getPos0 () {
            return pos0;
        public int getPos1 () {
            return pos1;
        public String getText () {
            return text;
    // MyTextPane.java
    public class MyTextPane extends JTextPane {
        LinkedList textListeners = new LinkedList();
        // This is just some method you defined, can be anything.
        public void someMethodThatInsertsText () {
            fireTextInserted(pos0, pos1, textInserted);
        // Same with this, this can be anything.
        public void someOtherMethodThatDeletesText () {
            fireTextDeleted(pos0, pos1);
        public void addTextListener (TextListener t) {
            textListeners.add(t);
        public void removeTextListener (TextListener t) {
            textListeners.remove(t);
        public TextListener[] getTextListeners () {
            TextListener ts = new TextListener[textListeners.size()];
            Iterator     i;
            int          j;
            // Don't think toArray works good because I'm 99% sure you'll
            // have trouble casting an Object[] to a TextListener[].
            for (j = 0, i = textListeners.iterator(); i.hasNext(); j ++)
                ts[j] = (TextListener)i.next();
        protected fireTextInserted (int pos0, int pos1, String text) {
            TextEvent e = new TextEvent(this, pos0, pos1, text);
            Iterator  i = textListeners.iterator();
            while (i.hasNext())
                ((TextListener)i.next()).textInserted(e);
        protected void fireTextDeleted (int pos0, int pos1) {
            TextEvent e = new TextEvent(this, pos0, pos1);
            Iterator  i = textListeners.iterator();
            while (i.hasNext())
                ((TextListener)i.next()).textDeleted(e);
    };There. I just typed that there, didn't test or compile it, but you get the gist of it. Then, like you do with any listener stuff, when you want to set up a listener and register it with a MyTextPane instance, just create some class that extends TextListener and overrides textInserted and textDeleted to do whatever your application needs to do.
    Hope that makes sense.
    Jason

  • I using an event structure for an input box and also for hardware input

    Hi there!
    I have many input boxes and display boxes on my user interface and i have a case for it in the event structure. If the user changes the values of the input boxes, the particular event case writes this new value to the hardware. However, in the timeout section of the event structure, we read the inputs from the hardware and we set the value for its related display object.  Within the timeout section i set the value for the related user interface display component, by making use of the property node value.
    Furthermore, for most of the display components, i have a event case for a value change associated with it. In that event case, i check for range errors and so forth.
    My assumption was that when i read the value in from the hardware and set the property node value, the user interface component's value will change and it would then trigger the event of the value changed for that component. 
    My assumption worked to the point of updating the component's value, however, it did not trigger the event  for the value changed for this component.
    Please advise me on how to achieve what i wish to.
    Thanks.
    Regards,

    Local variables are actually much more efficient than property nodes as far as execution speed goes. Take that same VI and delete the property node and instead write to a local variable inside the loop. You'll see the speed nearly identical to writing directly to the indicator. But note that variables also cause a copy of the data to be created. So if you're just using the "Value" property, you're much better off using a local variable. But don't use both at the same time. If you are reading/writing other properties when you update/read the value, you might as well use the value property.
    Sometimes you can't get around using either variables or property nodes. Initializing controls to saved values from an ini file is one example. But in this case, they are only written to once as the application starts so the performance hit is negligible.
    One thing you can do is store values in a shift register as they are read and pass this through your application so the last value read can be accessed from anywhere. You can even create a cluster that runs through the shift register to hold several values in a single register. This can be expanded a bit farther to create what's called a Functional Global. This basically a subVI with a While loop that only runs once on each call. It has a shift register to store data and a Case structure to Read or Write data into the register. There's a pretty good example that ships with LabVIEW showing how these work. Open the Example finder and search for "Functional Global Communication". This example shows how to use them to pass data between two independent loops, but they work just as well in a single loop application.
    One of the big advantages of these Functional Globals over the standard LabVIEW Globals and local variables is that you can add cases to manipulate the data in addition to just storing it. Also, since it's a subVI, access to the data is protected to one caller at a time whereas variables can have multiple reads and/or writes at the same time. This can cause race conditions.
    Hope that helps a bit.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

Maybe you are looking for

  • To include  a  value '#' in users filter vaue selection

    Hi Gurus, Thanks a lot for the continuous help from all of you and Again I am looking for ur valuable suggestions for my follwing problem : In my query I have a characteristic RunID which is included in the Free Characteriostics. according to the Fun

  • Prsonalize Portal

    Hi, I have to make my table get sorted according to the user selection. I try the example provided with the PDK for personalization and after some searching I was able to add a field property to my system component which displays a list of choices fo

  • No Action Until Image Loads, Please

    Hi; For some reason the squares of color that are supposed to load behind the image that acts as a mask load first, momentarily showing while the image loads, which looks bad. Hre is the code: package     import flash.display.Sprite;     import flash

  • How to display client date in oracle

    Hi All, How to display client system date in oracle. When I try to display date & time oracle displays server date and time but I need to display client date & time. How can I achieve that? Thank you

  • Are there any free trials for ExportPDF?

    Is there anyway to get a free trial to use the ExportPDF?  If so, how do I get one?  I am interested in purchasing ExportPDF, but would like to try it out first.