Destroying component

I have a class that spawns a thread, searching for the existence of a file in a certain directory. Once the file is dropped in to the directory, I get the name of the file dropped in, and a new instance of a separate class is created, to do further work with the file. Creation is pretty simple:
MyClass cl = new MyClass();
Once I am done using cl, I set a boolean in MyClass to true, which the parent class is constantly checking for this state. At this point, then, I want to get rid of the instance of MyClass, but keep the parent class instance running.
I cannot use System.exit() since I don't want to close the JVM completely. I tried cl.dispose(), but this appears to close down everything, as opposed to just getting rid of cl. Using cl.setEnabled(false) or cl.removeNotify() doesn't really seem to do much of anything. Is there another function I can call that will destroy the instance cl I have created, but allow the original to keep running? Thanks!

Hello,
Thank you mcuh for responding! Yes, that does indeed get rid of the class instance, as I can no longer make calls to the class functions...however, the window in which I was using to display the visual elements (menu items, buttons, etc.) is still hanging around. Tried using dispose() next, but again, both of the windows (the original parent, and the spawned class) close down. I need to still destroy window #2 (from cl), but keep around running the original. Thanks!

Similar Messages

  • Dynamic component interface context mapping

    Hi all,
      I got 2 component A and B. Component A use component B.
      I would like to know how to set interface context attribute value of comonent B within a view of component A in programatic mode.
      It should be something like this:
    wdThis.wdGetCompBInterface().wdGetContext.setAttr1("OK");
    is it possible???
    thank u in advance,
    Stefano

    Hi
    In your query consider B has BA Context which you want to fill from main componetn A
    Yes it is possible to add values from A to B but I did it only through context mapping instead of direct refrence of interface controller .
    For that you need to do context mapping .
    1) Add  B into A as used Web dynpro component .
    2) Add controller refrence in Component controller using properties of WDC.
    3) Map the context element from Interface controller to Component controller
        Set values of context of component controller which will set values for context 
        of A
    4) Only issue here is if you want to refresh values frequently you might need to create and destroy component each time . Not sure about it . In my case I m intitalising all context of B in  init of A itself.
    Regards
    Srushti

  • 3D environment in pure java programming

    hi all,
    my problem is dat...
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    </applet code="project1" width=1024 height=768>
    </applet>
    public class project1 extends Frame implements ActionListener , MouseListener {
         deathscreen screen=new deathscreen();
         int choice;
         project1(){
              super("3D-Image Processor");
              setSize(1026,768);
              setVisible(true);
              setResizable(true);
              addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent we){System.exit(0);}});
              addMouseListener(this);
    //MENU BAR----------------------------------------------------------------------------------------------------------
              MenuBar mbar=new MenuBar();
              setMenuBar(mbar);
              Menu file=new Menu("File");
              MenuItem item1,item2,item3,item4;
              file.add(item1=new MenuItem("New...."));
              file.add(item2=new MenuItem("Open..."));
              file.add(item3=new MenuItem("-"));
              file.add(item4=new MenuItem("Close.."));
              mbar.add(file);
              Menu edit=new Menu("Edit");
              MenuItem item5,item6,item7;
              edit.add(item5=new MenuItem("Cut...."));
              edit.add(item6=new MenuItem("Copy..."));
              edit.add(item7=new MenuItem("Paste.."));
              mbar.add(edit);
              Menu components=new Menu("Components");
              MenuItem item9,item10;
              components.add(item9=new MenuItem("Canvas............"));
              components.add(item10=new MenuItem("General Properties"));
              mbar.add(components);
              Menu help=new Menu("Help");
              MenuItem item11=new MenuItem("Help...");
              help.add(item11);
              mbar.add(help);
              //MyMenuHandler handler=new MyMenuHandler(this);
              item1.addActionListener(this);
              item2.addActionListener(this);
              item3.addActionListener(this);
              item4.addActionListener(this);
              item5.addActionListener(this);
              item6.addActionListener(this);
              item7.addActionListener(this);
    //Item8 destroyed(Component class removed)
              item9.addActionListener(this);
              item10.addActionListener(this);
              item11.addActionListener(this);
    //CALL OF INDIVIDUAL COMPONENTS------------------------------------------------------------------------------          
              screen.setVisible(true);
              screen.setResizable(true);
         public static void main(String args[]){
              new project1();
         public void paint(Graphics g){
              setBackground(Color.gray);
         public void actionPerformed(ActionEvent e){
              if(e.getActionCommand()=="Close.."){
                   System.exit(0);
              if(e.getActionCommand()=="Canvas............"){
                   screen.setVisible(true);
              if(e.getActionCommand()=="General Properties"){
                   screen.gen.setVisible(true);
    //MOUSE COMPONENTS---------------------------------------------------------------------------------------------
         public void mouseClicked(MouseEvent me){
              screen.setVisible(true);
              screen.gen.setVisible(true);
         public void mouseEntered(MouseEvent me){}
         public void mouseExited(MouseEvent me){}
         public void mousePressed(MouseEvent me){}
         public void mouseReleased(MouseEvent me){}
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.io.*;
    class genproperties extends Frame implements AdjustmentListener,ActionListener{
         Scrollbar red;
         Scrollbar blue;
         Scrollbar green;
         Canvas colour;
         Label r;
         Label g;
         Label b;
         Scrollbar thickness;
         Scrollbar height;
         Label th;
         Label he;
         Button SelectRect;
         Button SelectPoly;
         Button DrawRect;
         Button DrawPoly;
         Button DrawCircle;
         Button DrawLine;
         Button Pencil;
         Button Plotter;
         FileOutputStream temp;     
         int choice=0,i=0;
    int props[][]=new int[1000][40],fin;
    /*     props--->     0=choice of draw item
                   1=red
                   2=blue
                   3=green
                   4=thickness
                   5=height
                   6=x1     |
                   7=y1     | of the chosen
                   8=x2     | component
                   9=y2     |
         genproperties(){
              super("General Properties");
              try{
              temp = new FileOutputStream("Z:\temp.txt");
              }catch(FileNotFoundException _ex){}
              setSize(270,695);
              setLocation(10,45);
              setResizable(false);
              setLayout(null);//new FlowLayout());
              setBackground(Color.gray);
    //GENERAL PROPERTIES OF ALL DRAWING COMPONENTS <LOOKS>-------------------
    //Color of individual components
              red=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,256);
              blue=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,256);
              green=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,256);
              Label lc=new Label("CHOSEN COLOR",Label.CENTER);
    //thickness and height of individual components
              thickness=new Scrollbar(Scrollbar.HORIZONTAL,0,1,1,6);
              height=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,256);
              th=new Label("Thickness=0");
              he=new Label("Height=0");
    //Individual components
              SelectRect=new Button("Select Rectangle");
              SelectPoly=new Button("Select Polygon");
              DrawRect=new Button("Rectangle");
              DrawPoly=new Button("Polygon");
              DrawCircle=new Button("Circle");
              DrawLine=new Button("Line");
              Pencil=new Button("Pencil");
              Plotter=new Button("Plotter");
              r=new Label("RED=0");
              g=new Label("BLUE=0");
              b=new Label("GREEN=0");
              colour=new Canvas();
              red.setBounds(5,50,256,15);
              blue.setBounds(5,100,256,15);
              green.setBounds(5,150,256,15);
              colour.setBounds(50,210,170,100);
              lc.setBounds(50,330,170,30);
              r.setBounds(80,70,70,20);
              b.setBounds(77,120,70,20);
              g.setBounds(75,170,75,20);
              thickness.setBounds(30,380,200,15);
              height.setBounds(5,430,256,15);
              th.setBounds(80,400,100,20);
              he.setBounds(90,450,100,20);
    //Chosen color display
              colour.setBackground(Color.black);
              r.setBackground(Color.gray);
              b.setBackground(Color.gray);
              g.setBackground(Color.gray);
              SelectRect.setBounds(20,500,100,30);
              SelectPoly.setBounds(150,500,100,30);
              DrawLine.setBounds(20,530,100,30);
              DrawRect.setBounds(150,530,100,30);
              DrawPoly.setBounds(20,560,100,30);
              DrawCircle.setBounds(150,560,100,30);
              Pencil.setBounds(20,590,100,30);
              Plotter.setBounds(150,590,100,30);
              add(red);
              add(blue);
              add(green);
              add(colour);
              add(lc);
              add(r);
              add(g);
              add(b);
              add(thickness);
              add(th);
              add(height);
              add(he);
              add(SelectRect);
              add(SelectPoly);
              add(DrawLine);
              add(DrawRect);
              add(DrawPoly);
              add(DrawCircle);
              add(Pencil);
              add(Plotter);
              thickness.addAdjustmentListener(this);
              height.addAdjustmentListener(this);
              //colour.setBackground(Color.red);
              red.addAdjustmentListener(this);
              blue.addAdjustmentListener(this);
              green.addAdjustmentListener(this);
              SelectRect.addActionListener(this);
              SelectPoly.addActionListener(this);
              DrawLine.addActionListener(this);
              DrawRect.addActionListener(this);
              DrawPoly.addActionListener(this);
              DrawCircle.addActionListener(this);
              Pencil.addActionListener(this);
              Plotter.addActionListener(this);
    //To escape array from getting into nullpointer exception.....
              /*int j=0;
              for(i=0;i<1000;i++){
                   for(j=0;j<6;j++){
                        props[i][j]=0;
         public void paint(Graphics g){
              setBackground(Color.gray);
              g.setColor(Color.black);
              g.fillRect(40,200,190,120);
         public void adjustmentValueChanged(AdjustmentEvent ae){
              colour.setBackground(new Color(red.getValue(),green.getValue(),blue.getValue()));
              r.setText("RED="+new Integer(red.getValue()).toString());          
              b.setText("BLUE="+new Integer(blue.getValue()).toString());          
              g.setText("GREEN="+new Integer(green.getValue()).toString());     
              th.setText("Thickness="+new Integer(thickness.getValue()).toString());
              he.setText("Height="+new Integer(height.getValue()).toString());
    //Array props being initialized to store attribute values of
    //individual components to feed into file for later use......
              props[1]=red.getValue();
              props[i][2]=blue.getValue();
              props[i][3]=green.getValue();
              props[i][4]=thickness.getValue();
              props[i][5]=height.getValue();
              //System.out.println("Ch:"+props[i][0]+" R:"+props[i][1]+" B:"+props[i][2]+" G:"+props[i][3]+" Th:"+props[i][4]+" He:"+props[i][5]+" i:"+i);
         public void actionPerformed(ActionEvent e){
              if(e.getActionCommand()=="Pencil"){
                   i=++i;
                   choice=7;
              if(e.getActionCommand()=="Line"){
                   choice=6;
                   i=++i;
              if(e.getActionCommand()=="Circle"){
                   choice=5;
                   i=++i;
              if(e.getActionCommand()=="Polygon"){
                   choice=4;
                   i=++i;
              if(e.getActionCommand()=="Rectangle"){
                   choice=3;
                   i=++i;
              if(e.getActionCommand()=="Select Polygon"){
                   choice=2;
                   i=++i;
              if(e.getActionCommand()=="Select Rectangle"){
                   choice=1;
                   i=++i;
              if(e.getActionCommand()=="Plotter"){
                   choice=0;
                   i=++i;
              /*try{
                   temp.write(props[i][0]);
                   temp.write(props[i][1]);
                   temp.write(props[i][2]);
                   temp.write(props[i][3]);
                   temp.write(props[i][4]);
                   temp.write(props[i][5]);
                   temp.close();
              }catch(IOException _ex){}*/
              props[i][0]=choice;
              props[i][1]=red.getValue();
              props[i][2]=blue.getValue();
              props[i][3]=green.getValue();
              fin=i;
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.io.*;
    import java.lang.Math;
    public class deathscreen extends Frame implements MouseListener,MouseMotionListener{
         int x1=0,x2=0,y1=0,y2=0;
         genproperties gen=new genproperties();
         int xtemp=0,ytemp=0;
         //boolean flicker=true;
         Image buffer;
         Graphics gg;
         deathscreen(){
              super("Canvas");
              setSize(500,500);
              setResizable(true);
              setLocation(280,45);
              setLayout(new FlowLayout());
              setVisible(true);
              buffer=createImage(500,500);
              gg=buffer.getGraphics();
              gen.setResizable(false);
              gen.setVisible(true);
              addMouseListener(this);
              addMouseMotionListener(this);
         public void update(Graphics g)
              paint(g);
         public void paint(Graphics g){
              int rmin=1,gmin=0,bmin=0,thmin=0,hemin=0;
              setBackground(Color.black);          
              gg.setColor(Color.black);
              gg.fillRect(0,0,500,500);
              for(int i=0;i<=gen.i;i++){
                   rmin=(gen.props[i][1]/256)*(256-gen.props[i][5]);
                   bmin=(gen.props[i][2]/256)*(256-gen.props[i][5]);
                   gmin=(gen.props[i][3]/256)*(256-gen.props[i][5]);
                   gg.setColor(new Color(gen.props[i][1],gen.props[i][3],gen.props[i][2]));
                   gg.drawString("Nags Project1",20,30);
                   if(gen.props[i][0]==6){
                        gg.drawLine(gen.props[i][6],gen.props[i][7],gen.props[i][8],gen.props[i][9]);
                        for(int lc=0;lc<gen.props[i][4];lc++){
                             gg.setColor(new Color(gen.props[i][1]+rmin,gen.props[i][3]+gmin,gen.props[i][2]+bmin));
                             rmin=++rmin;
                             bmin=++bmin;
                             gmin=++gmin;
                             gg.drawLine(gen.props[i][6]+lc,gen.props[i][7]+lc,gen.props[i][8]+lc,gen.props[i][9]+lc);
                             gg.drawLine(gen.props[i][6]-lc,gen.props[i][7]-lc,gen.props[i][8]-lc,gen.props[i][9]-lc);
                   else if(gen.props[i][0]==3){
                        if(gen.props[i][6]>gen.props[i][8] && gen.props[i][7]<gen.props[i][9]){
                             gg.drawRect(gen.props[i][8],gen.props[i][7],gen.props[i][6]-gen.props[i][8],gen.props[i][9]-gen.props[i][7]);
                        else
                        if(gen.props[i][7]>gen.props[i][9] && gen.props[i][6]<gen.props[i][8]){
                             gg.drawRect(gen.props[i][6],gen.props[i][9],gen.props[i][8]-gen.props[i][6],gen.props[i][7]-gen.props[i][9]);
                        else
                        if(gen.props[i][6]<gen.props[i][8] && gen.props[i][7]<gen.props[i][9]){
                             gg.drawRect(gen.props[i][6],gen.props[i][7],gen.props[i][8]-gen.props[i][6],gen.props[i][9]-gen.props[i][7]);
                        else
                        if(gen.props[i][6]>gen.props[i][8] && gen.props[i][7]>gen.props[i][9]){
                             gg.drawRect(gen.props[i][8],gen.props[i][9],gen.props[i][6]-gen.props[i][8],gen.props[i][7]-gen.props[i][9]);
                   else if(gen.props[i][0]==5){     
                        if(gen.props[i][6]>gen.props[i][8] && gen.props[i][7]<gen.props[i][9]){
                             gg.drawOval(gen.props[i][8],gen.props[i][7],gen.props[i][6]-gen.props[i][8],gen.props[i][9]-gen.props[i][7]);
                        else
                        if(gen.props[i][7]>gen.props[i][9] && gen.props[i][6]<gen.props[i][8]){
                             gg.drawOval(gen.props[i][6],gen.props[i][9],gen.props[i][8]-gen.props[i][6],gen.props[i][7]-gen.props[i][9]);
                        else
                        if(gen.props[i][6]<gen.props[i][8] && gen.props[i][7]<gen.props[i][9]){
                             gg.drawOval(gen.props[i][6],gen.props[i][7],gen.props[i][8]-gen.props[i][6],gen.props[i][9]-gen.props[i][7]);
                        else
                        if(gen.props[i][6]>gen.props[i][8] && gen.props[i][7]>gen.props[i][9]){
                             gg.drawOval(gen.props[i][8],gen.props[i][9],gen.props[i][6]-gen.props[i][8],gen.props[i][7]-gen.props[i][9]);
                   else if(gen.props[i][0]==7){
                        //gg.drawLine(gen.props[i][6],gen.props[i][7],gen.props[i][6]+5,gen.props[i][7]+5);
              /*if(!flicker){
                   screengc.drawImage(buffer,0,0,null);
              g.drawImage(buffer,0,0,this);
    //MOUSE COMPONENTS--------------------------------------------------------------------------------------------------
         public void mouseClicked(MouseEvent me){
         public void mouseEntered(MouseEvent me){  }
         public void mouseExited(MouseEvent me){  }
         public void mousePressed(MouseEvent me){
              x1=me.getX();
              y1=me.getY();
              gen.props[gen.i][6]=me.getX();
              gen.props[gen.i][7]=me.getY();
              //repaint();
         public void mouseReleased(MouseEvent me){ 
              x2=me.getX();
              y2=me.getY();
              gen.props[gen.i][8]=me.getX();
              gen.props[gen.i][9]=me.getY();
              gen.i=++gen.i;
              gen.props[gen.i][0]=gen.props[gen.i-1][0];
              gen.props[gen.i][1]=gen.red.getValue();
              gen.props[gen.i][2]=gen.blue.getValue();
              gen.props[gen.i][3]=gen.green.getValue();
              repaint();
         public void mouseDragged(MouseEvent me){
              x2=me.getX();
              y2=me.getY();
              gen.props[gen.i][8]=me.getX();
              gen.props[gen.i][9]=me.getY();
              //flicker=false;
              repaint();
         public void mouseMoved(MouseEvent me){ 
              //flicker=true;
    im not able to have a 3D feel in the program where i draw the objects,
    when i try to use a loop and draw and redraw i am unable and i get a null pointer exception......wat do i do???

    im not able to have a 3D feel in the program where i draw the objects,What do you mean 'a 3D feel'? Nothing in your code seems to be doing anything other than using standard awt widgets, and drawing 2D shapes, so why would it be 3D?
    or do you mean it's using the Java look and feel rather than the platform one?
    when i try to use a loop and draw and redraw i am unable and i get a null pointer exception......wat do i do???repost the relevent code using [code] [[i]code] tags.
    Pete

  • Select-options are not destroyed while calling view of used component popup

    Hi Friends ,
    I'm facing a unique problem. I'm calling a view of a component within another component. the view that I'm calling has some select-options. When I close the popup window ( using close 'X' of popup ) and then try to reopen the popup system give me a dump. I debugged and found that select-options are not destroyed by system and once it tries to create the select-options again it dumps because they are already there.  
    This is the source code extract of that dump for your reference .
    1 method if_wd_select_options~add_selection_field.
    2
    3   data:
    4     lr_table_descr       type ref to cl_abap_tabledescr,
    5     lr_struct_descr      type ref to cl_abap_structdescr,
    6     lr_value_field_descr type ref to cl_abap_elemdescr,
    7     added_field          like line of mt_added_fields,
    8     dfies                type dfies,
    9     description          type string,
    10     complex_restrictions type if_wd_select_options=>t_complex_restrictions.
    11
    12   field-symbols:
    13     <it_result> type index table.
    14
    15 * check of someone wants to add a field that already exists
    16   read table mt_fields
    17        with key m_id = i_id
    18        transporting no fields.
    19   if sy-subrc = 0.
    20 *   might be deleted - recreating a field with different setting is of course allowed
    21     read table mt_all_removed_fields
    22          with key table_line = i_id
    23          transporting no fields.
    24     if sy-subrc <> 0.
    >>>       message x000(00).
    26     endif.
    27
    28 *   remove the existing field in order to avoid duplicates
    29     delete table mt_fields with table key m_id = i_id.
    30   endif.
    I've already tried using REMOVE_ALL_SEL_SCREEN_ITEMS( ) method of interface IF_WD_SELECT_OPTIONS before creating new elements ( select-options ). If any one can help me in this It would really help and I'll appreciate it.
    Thanks in advance,
    Laeeq

    I've sloved the problem

  • Component tree destroyed when it should not be

    I have a custom component which derives from UICommand, clicking on which pops up a new window ... i have a listener associated with this component ... within this listener I call the setAction(outcome) method on the associated UICommand component with an outcome string (whose navigation rule is defined in faces-config.xml) ... This works properly in that the new window opens with the correct JSP.
    However, in doing this, JSF destroys the component tree of my original page ... Hence when I perform some operation on the original page (after opening the new window), it constitutes a new tree instead of using the tree which was already created for this page ...
    How do I solve my problem? - I'd like the original component tree to not get destroyed as well as work with the new window.
    Thanks.

    Currently, JSF only saves the current tree (it does
    not save more than one tree). A new State Saving
    proposal is being developed which will
    address the problem you are having.
    -rogerWow, that's a pretty significant change. Can you give us any hints about other major differences currently under consideration for the next revision?
    Thanks,
    Jonathan

  • How to destroy the component

    Hi friends...
    How to destroy the componenet.....
    Is it possible?....
    Thanks& regards
    Mathi

    hi,
    How to destroy the window through coding....
    Because
    component1
    view1--Nameis v1
    view2--Nameis v2
    component2
    view1--Nameis v3
    view2Nameis v2
    The diagram flow is
    view1>view2>view3>view1>view2-->view3
    But my project is work Like
    view1>view2>view3>view1>not go to view2-->again and again view1 to view3...
    Is any Possiblilities to destroy the componenet through coding...
    Thanks & regards
    Mathi

  • Unable to Edit the View in Custom Component

    Hi Experts,
    Please help me to resolve this issue !
    I am unable to lock the BOL Entity in my custom component using BTAdminH. I have written the below code in the Edit event Handler for Edit Button. The lr_entity->lock( ) condition statement is getting false and it is skipping the "set_view_editable( me )." code statement. Why??
    This is code excerpt that I have taken from edit button of the BP_HEAD/AccountViewSet and altered to my component/View
    DATA: lr_entity     TYPE REF TO cl_crm_bol_entity,
            lr_controller TYPE REF TO cl_ZVKH8_bspwdcomponent_impl.
      TRY.
          lr_controller ?= me->comp_controller.
          lr_entity ?= lr_controller->typed_context->btadminh->collection_wrapper->get_current( ).
    IF lr_entity IS BOUND.
      IF lr_entity->IS_LOCKED EQ abap_false.
        IF le_entity->IS_CHANGEABLE EQ abap_true.
           IF lr_entity->lock( ) EQ abap_true.
            me->view_group_context->set_view_editable( me ).
           ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
    and when I directly executed the below code in the Edit event Handler for Edit Button I am receiving the dereferencing NULL value exception. Why in my custom component in many places this happening??
      me->view_group_context->set_view_editable( me ).
    Exception Details
    CX_SY_REF_IS_INITIAL - Dereferencing of the NULL reference
    Method: ZL_ZVKH8_DETAILSEF_IMPL=>EH_ONBACK
    Thanks,
    Bujji

    Hi Summit & NishaNC,
    Thanks for your responses !
    As suggested, I have debugged the code for ->lock( ) method and there are exceptions raised from some methods.
    Method GET_LOCK () -> Method GET_ROOT () ->Method GET_PARENT ()
    At GET_ROOT( ) method i have received an exception
    "Root entity BTAdminH could not be determined" and one more "Entity BTAdminH could not be locked"
    Later when I have checked in MODEL Browser, I found that the BOL object "BTAdminH" for my view is an Access object and not the Root Object.
    Hence, I have a question? Does the locking can be done only for ROOT Objects?
    If this is TRUE then I think this is the major problem with my custom component where even the cross component navigation is also not happening and in many places I am receiving "Dereferencing NULL Value" information.
    Also I have gone through some of the Threads and one information that I found from Sumit Mittal
    1. An access object is an independent entity, has primary keys of its own.
    2. A root object is a special access object that is at the top of the hierarchy based on business rules.
    3. A dependent object's primary keys are supplied by access objects and it's lifetime is bound to them. If the parent object is destroyed, the dependent object is also destroyed.
    4. Search objects are query objects useful for querying root objects
    5. Search result objects - Search objects return the results in the form of a result object together with a relation pointing to the root object.
    6. View objects - ?
    7. Dynamic search objects - Used in advanced search, supports ranges and operators
    Could you please specify in which scenarios we have to go for Access Objects and Root Objects
    Thanks,
    Bujji

  • Problem with the MenuBar and how can i delete a own component out of the storage

    Hello,
    I opened this thread in the category "Flex Builder 2", but
    under this category my questions fit better.
    I have a problem with the MenuBar and a question to delete a
    component out of storage.
    1. We have implemented the MenuBar, which was filled
    dynamically with XML data.
    Sporadically it will appear following fault, if we "mousover"
    the root layer.
    RangeError: Error #2006: Der angegebene Index liegt
    außerhalb des zulässigen Bereichs.
    at flash.display::DisplayObjectContainer/addChildAt()
    at mx.managers::SystemManager/
    http://www.adobe.com/2006/flex/mx/internal::rawChildren_addChildAt()
    at mx.managers::SystemManager/addChild()
    at mx.managers::PopUpManager$/addPopUp()
    at mx.controls::Menu/show()
    at mx.controls::MenuBar/::showMenu()
    at mx.controls::MenuBar/::mouseOverHandler()
    Here a abrid ged version of our XML to create the MenuBar:
    <Menuebar>
    <menu label="Artikel">
    <menu label="Artikel anlegen" data="new_article" />
    <menu label="Artikel bearbeiten" data="edit_article" />
    <menu label="Verpackung">
    <menu label="Verpackung anlegen" data="new_package" />
    <menu label="Verpackung bearbeiten" data="edit_package"
    />
    </menu>
    <menu label="Materialgruppe">
    <menu label="Materialgruppe anlegen"
    data="new_materialgroup" />
    <menu label="Materialgruppe bearbeiten"
    data="edit_materialgroup" />
    </menu>
    </menu>
    </Menuebar>
    It is a well-formed XML.
    2. Delete a component out of storage
    We have some own components (basically forms), which will be
    created and shown by an construct e.g.
    var myComponent : T_Component = new T_Component ;
    this.addChild(myComponent)
    Some of our forms will be created in an popup. On every call
    of the popup, we lost 5 mb or more, all childs on the windows will
    be removed by formname.removeAllChild();
    What cann we do, that the garbage collector will dispose this
    objects.
    Is there a way to show all objects with references (NOT
    NULL)?
    I have read in the Flex Help, that
    this.removeChild(myComponent) not delete the form and/or object out
    of the storage.
    Rather the object must be destroyed.
    It is sufficient to call delete(myComponent) about remove
    this object out of the storage as the case may be that the
    garbage-collector remove this object at any time?
    Or how can I destroy a component correctly. What happens with
    the widgets on this component e.g. input fields or datagrids?
    Are they also being deleted?
    Thanks for your help.
    Matze

    If you mena the "photo Library" then you cannot delete it.
    This is how iphone handles photos.  There are not two copies.  There a re simply two places from which to access the same photos.  ALL photos synced to iphone can be accessed via Photo Library.  Those same pics can be accessed via their individual folder.

  • Hide or destroy NonModalExternal Window

    Hi,
    I want to print the content of a popup window with the web dynpro print functionality. For this I created a non modal external window as an intermediate window for keeping the content. On the wdDoinit method of this external window view I am triggering the print functionality, that opens the print preview of this external window.
    After printing the view, have to close the print preview screen and the intermediate external window.
    How can I hide or destroy the intermediate external window, so that the user have to close only the print preview screen and go back to the real application.
    I tried to assign the window as a context variable to component controller and tried to hide this variable in wdDoInit of the external window. But its throwing me Null.PointerException. So I am not able to store the window variable in the context.
    please help me regarding this issue,
    Regards,
    Yasar

    Hi Ayyapparaj,
    Thanks for this information.
    I know that it is not possible to print the content of a popup window. The usage of non external window is a workaroung for this issue.
    My problem in this case is,I am creating and showing the non modal external window from the "onactionprint" method of the popup view. The content of the popup window will be mapped with the ContextMapper class that I found on the blog here:
    On the external window view, I am triggering the print functionality in wdDoInit of the external window view, which opens the print preview of this external window view. In this case after clicking on the print button of the popup windows, two separate windows will be openned (external window and print preview of external window). I want to hide or destroy the external window in the wdDoInit of the external window view.
    The Mapping of the IWDWindow variable between popup view and external window view over component controller is not working. While destroying the external window I get Null.pointer exception, because the mapping of the created nonmodal external window between popup view and external window view is not working.
    Is it also not possible to map an external window between two different views?
    Regards,
    Yasar

  • Disposed component in an applet

    an applet sometimes throws a NullPointerException. here is the tree:
    java.lang.NullPointerException: disposed component at
    sun.awt.windows.Win32SurfaceData.initOps(Native Method) at
    sun.awt.windows.Win32SurfaceData.<init>(Unknown Source) at
    sun.awt.windows.Win32SurfaceData.createData(Unknown Source) at
    sun.awt.windows.WComponentPeer.<init>(Unknown Source) at
    sun.awt.windows.WChoicePeer.<init>(Unknown Source) at
    sun.awt.windows.WToolkit.createChoice(Unknown Source) at
    java.awt.Choice.addNotify(Unknown Source) at
    java.awt.Container.addNotify(Unknown Source) at
    java.awt.Panel.addNotify(Unknown Source) at
    java.awt.Container.addNotify(Unknown Source) at
    java.awt.Panel.addNotify(Unknown Source) at
    java.awt.Container.addImpl(Unknown Source) at
    java.awt.Container.add(Unknown Source) at NewTable.init
    (NewTable.java:75) at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    as you see the exception is thrown in line 75.
    line 75 in my code looks like this: i add a panel
    to the appletwhich were relayouted earlier with borderlayout. it
    looks like this:
    74 Panel p=new Panel();
    75 this.add(p,BorderLayout.CENTER);
    now, the exception is probably thrown because i run the add() method
    on a component which containment hierarchy is made undisplayable.
    according the api it can happen when the component's ancestor window
    is disposed.
    the question is why it is getting disposed? i payed attention that
    the exception is thrown only on 2 specific win98 machines and it's
    never thrown when the user opens the applet in the first time.
    usually it happens when a number of users visit the same page which
    includes this applet and the browser is not closed between the user
    sessions...but! the users always press a button on applet which redirects them to another page, which means that the applet calls destroy() on itself ...
    i thought to add an isDisplayable() check , but it will only give me
    a control over the exception, not the no-problem-sollution.
    any ideas what can be fixed?
    thanX

    how do you run your applet - using applet viewr or a browser?
    anyway, when debugging, don't assume anything.
    in line 75 you may try System.err.println( this )
    if you don't get null, try:
    System.err.println this.GetXXX() and print as much as you can about your object.

  • HOW DO YOU SEND AN EVENT "OUT" TO A COMPONENT?

    I am writing an AIR app that has many components.  The main application has a "start" button to begin a new project, and when you exit a project, the application returns to the start page.  Even though you exit back to the start page, the major MXML components used in the application do not get destroyed because there is no way to destroy them so they just sit there idle in the background and not visible in the "start" state.  The problem is that when a user clicks the "start" button again to start a new project, the MXML components appear in the new project in the old state that they were in because there is no obvious way to reinitialize them.  If there was a way to destroy the components, then when they were recreated in a new project I could initialize them with a creationComplete handler.  But since you can't literally destroy an MXML component, I need a way for the components to be able to listen to the main program for a click event on the "start" button, and then each component initializes itself when it hears the event.  So instead of components passing an event up to the main application, I need the main application to send an event down to the components.  Is there a way to send an event from the main application out to the various components?  (or is there a way to destroy an MXML component so that you can recreate it later that I am unaware of?)

    Yes, that will do the job, though it's better to use a custom event and you don't need a property.
    I quickly made a tiny example in Flash using a static variable as a central dispatch hub..
    Create a class:
    package  {
        import flash.events.EventDispatcher;
        public class EventHub extends EventDispatcher {
            public static var dispatcher:EventHub = new EventHub();
            public function EventHub() {
                // constructor code
    // in the component add this
    EventHub.dispatcher.addEventListener("INIT_COMPONENT", _onInitComponent);
    // the handler for the event inside your component
    private function _onInitComponent(e:Event):void{
        trace("INIT_COMPONENT received");
    // wherever you need to trigger init, add this
    EventHub.dispatcher.dispatchEvent(new Event("INIT_COMPONENT"));
    Paul

  • What component Should I use?, Jpanel doesn't work

    Hi
    I need a program that has a window that can go fullscreen and windowed (I did that with a Jframe in fullscreen mode with a jpnale and a 800x600 Jpanel and destroying them with an object that maneges them), I did it with a jframe that contained a Jpanel, I used a Jpanel to avoid the flickering on the screen but I also need to change the font type and the font size, but the setFont on the Jpanel doesn't change the font (as I have realized and also read here [http://forum.java.sun.com/thread.jspa?forumID=257&threadID=150588] ), so I'm lost, I might have to redo the whole thing, but I just wanted to know what component should I use for a window that is going to have custom graphics and need diffrent fonts and diffrent font sizes and work in fullscreen without flickering
    Thank you for your attention, I would aprecciate any help given

    for example:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JSlider;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    public class JPanelFont extends JPanel
      private Font font = getFont();
      private String myString = "Fubars Rule";
      private int fontSize = font.getSize();
      private JSlider slider = new JSlider(0, 100, fontSize);
      public JPanelFont()
        setPreferredSize(new Dimension(620, 250));
        setLayout(new BorderLayout());
        JPanel inputPanel = createInputPanel();
        add(inputPanel, BorderLayout.SOUTH);
      private JPanel createInputPanel()
        JPanel ip = new JPanel();
        slider.setMajorTickSpacing(20);
        slider.setMinorTickSpacing(5);
        slider.setPaintTicks(true);
        slider.setPaintLabels(true);
        ip.add(slider);
        slider.addChangeListener(new ChangeListener()
          public void stateChanged(ChangeEvent evt)
            fontSize = (Integer)slider.getValue();
            repaint();
        return ip;
      @Override
      protected void paintComponent(Graphics g)
        Graphics2D g2 = (Graphics2D)g;
        Object originalHint = g2.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        super.paintComponent(g2);
        myPaint(g2);
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, originalHint);
      private void myPaint(Graphics2D g2)
        font = font.deriveFont(Font.BOLD, fontSize);
        g2.setFont(font);
        g2.drawString(myString, 20, 100);
      private static void createAndShowUI()
        JFrame frame = new JFrame("Dynamic JPanel Font");
        frame.getContentPane().add(new JPanelFont());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args)
        java.awt.EventQueue.invokeLater(new Runnable()
          public void run()
            createAndShowUI();
    }Edited by: Encephalopathic on May 21, 2008 9:18 PM

  • Word processing within a text component

    Although this is a potentially great application, I am at present prevented from using it to create a website due to the lack, as far as I can determine, of any form of processing individual text within the text components e.g. making individual words or word groups bold or italic or giving them COLORS.
    I have large informatory text areas on my pages which need this sort of processing in order to avoid client eyestrain as well as my own.
    Of course one can get around this to some extent by using multiple components but for long texts this quickly becomes very tedious and error prone, especially if one wants to copy from another source.
    The Static Text component, which I presume is meant for this sort of text, in it's present simple form allows word wrap but no line formatting. The basic Text Area component (multiple lines) has no word wrap but does allow line formatting. However when one sets the Read Only property, it seems that any self created line formatting is duly destroyed. This is strangely not the case with the old Standard Mutliline Text Area component.
    I may be missing something but if not I hope that these features may yet be incorporated.
    Regards,
    Dave

    You can use static text to render pure HTML, just set "escape" property to false.
    Note that the HTML text must be well former.
    Regards.

  • Upload file component in JSF 1.2

    Hi,
    I am developing an application with JSF 1.2 . I am using a custom component made with Apache Commons FileUpload 1.2.1 API which purpose is to upload files. This component work only if the form data is encoded with the “multipart/form-data” encoding instead of the usual “application x-www-form-urlencoded” encoding. From what I know JSF 1.2 doesn't handle this type of encoding. To overcome this issue, I install a servlet filter that intercepts a file upload and turns uploaded files into request attributes. The problem is that when the form data is encoded with the “multipart/form-data” encoding no characters are encoded. I have other JSF components in this form and in them I put different international characters which are lost when the form is submit because they are not encoded.
    Can somebody help me with this issue ?

    I have a filter
    import java.io.File;
    import java.io.IOException;
    import java.util.Collections;
    import java.util.Enumeration;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletRequestWrapper;
    import org.apache.commons.fileupload.FileItem;
    import org.apache.commons.fileupload.FileUploadException;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    public class UploadFilter implements Filter {
    private int sizeThreshold = -1;
    private String repositoryPath;
    public void init(FilterConfig config) throws ServletException {
    repositoryPath = config.getInitParameter(
    "com.corejsf.UploadFilter.repositoryPath");
    try {
    String paramValue = config.getInitParameter(
    "com.corejsf.UploadFilter.sizeThreshold");
    if (paramValue != null)
    sizeThreshold = Integer.parseInt(paramValue);
    catch (NumberFormatException ex) {
    ServletException servletEx = new ServletException();
    servletEx.initCause(ex);
    throw servletEx;
    public void destroy() {
    public void doFilter(ServletRequest request,
    ServletResponse response, FilterChain chain)
    throws IOException, ServletException {
    if (!(request instanceof HttpServletRequest)) {
    chain.doFilter(request, response);
    return;
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    boolean isMultipartContent
    = ServletFileUpload.isMultipartContent(httpRequest);
    if (!isMultipartContent) {
    chain.doFilter(request, response);
    return;
    DiskFileItemFactory factory = new DiskFileItemFactory();
    if (sizeThreshold >= 0)
    factory.setSizeThreshold(sizeThreshold);
    if (repositoryPath != null)
    factory.setRepository(new File(repositoryPath));
    ServletFileUpload upload = new ServletFileUpload(factory);
    try {
    List<FileItem> items = (List<FileItem>) upload.parseRequest(httpRequest);
    final Map<String, String[]> map = new HashMap<String, String[]>();
    for (FileItem item : items) {
    String str = item.getString();
    if (item.isFormField())
    map.put(item.getFieldName(), new String[] { str });
    else
    httpRequest.setAttribute(item.getFieldName(), item);
    chain.doFilter(new
    HttpServletRequestWrapper(httpRequest) {
    public Map<String, String[]> getParameterMap() {
    return map;
    // busywork follows ... should have been part of the wrapper
    public String[] getParameterValues(String name) {
    Map<String, String[]> map = getParameterMap();
    return (String[]) map.get(name);
    public String getParameter(String name) {
    String[] params = getParameterValues(name);
    if (params == null) return null;
    return params[0];
    public Enumeration<String> getParameterNames() {
    Map<String, String[]> map = getParameterMap();
    return Collections.enumeration(map.keySet());
    }, response);
    } catch (FileUploadException ex) {
    ServletException servletEx = new ServletException();
    servletEx.initCause(ex);
    throw servletEx;
    a render
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.UnsupportedEncodingException;
    import javax.el.ValueExpression;
    import javax.faces.FacesException;
    import javax.faces.component.EditableValueHolder;
    import javax.faces.component.UIComponent;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;
    import javax.faces.render.Renderer;
    import javax.servlet.ServletContext;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.commons.fileupload.FileItem;
    public class UploadRenderer extends Renderer {
    public void encodeBegin(FacesContext context, UIComponent component)
    throws IOException {
    if (!component.isRendered()) return;
    ResponseWriter writer = context.getResponseWriter();
    String clientId = component.getClientId(context);
    writer.startElement("input", component);
    writer.writeAttribute("type", "file", "type");
    writer.writeAttribute("name", clientId, "clientId");
    writer.endElement("input");
    writer.flush();
    public void decode(FacesContext context, UIComponent component) {
    ExternalContext external = context.getExternalContext();
    HttpServletRequest request = (HttpServletRequest) external.getRequest();
    String clientId = component.getClientId(context);
    FileItem item = (FileItem) request.getAttribute(clientId);
    Object newValue;
    ValueExpression valueExpr = component.getValueExpression("value");
    if (valueExpr != null) {
    Class valueType = valueExpr.getType(context.getELContext());
    if (valueType == byte[].class) {
    newValue = item.get();
    else if (valueType == InputStream.class) {
    try {
    newValue = item.getInputStream();
    } catch (IOException ex) {
    throw new FacesException(ex);
    else {
    String encoding = request.getCharacterEncoding();
    if (encoding != null)
    try {
    newValue = item.getString(encoding);
    } catch (UnsupportedEncodingException ex) {
    newValue = item.getString();
    else
    newValue = item.getString();
    ((EditableValueHolder) component).setSubmittedValue(newValue);
    ((EditableValueHolder) component).setValid(true);
    Object target = component.getAttributes().get("target");
    if (target != null) {
    File file;
    if (target instanceof File)
    file = (File) target;
    else {
    ServletContext servletContext
    = (ServletContext) external.getContext();
    String realPath = servletContext.getRealPath(target.toString());
    file = new File(realPath);
    try { // ugh--write is declared with "throws Exception"
    item.write(file);
    } catch (Exception ex) {
    throw new FacesException(ex);
    and a simple tag handler it is nothing special.
    This code is taken from an example in the book Core JavaServer Faces Second Edition 2007

  • Component Creation in Flex / Xcelsius

    Hi Experts,
    Although I've used Xcelsius fairly extensively over the past year or so, I haven't really had much interaction with Flex or designing my own components. I have a project coming up shortly where I will need to create a large map of their operations, with hundreds of control point 'hot-spots'. This can't be achieved in any scalable way via workarounds without absolutely destroying the performance.
    This implies that I will need to create my own component. Are there any resources out there that outline fairly clearly (read: simplistically) the steps in creating an Xcelsius component, or even the conversion of a Flex 2 component to Xcelsius (as I can likely find some Flex tutorials)?
    Thanks for the help!
    -Brian

    Sounds like a large XY or Bubble chart!
    My experience is that you cannot just download the Flex demo and expect to be able to build your own components.  It's a lot more involved than that, even if you do a Flex course it will not be geared towards an Xcelsius design process.  Although built in Flex the actual language used is ActionScript for the Components and MXML (with some Actionscript) for the Properties sheet.  So I would suggest a course in ActionScript first as the programming involved can be quite confusing and if you've been out of programming for a while (in my case a long while!) it will take time to understand fully what is happening.  Time which I cannot afford to put in, so I have done the courses so that I can talk to developers in their language and write accurate informed specifications for components. 
    For a basic overview of Flex take a look at the great Introduction to Flex videos over at Lee Brimlow's site www.gotoandlearn.com.  Also there are a lot of good learning resources from Adobe with their Flex in a Week videos: http://www.adobe.com/devnet/flex/videotraining/
    I'd would jump at the chance of attending a BO Xcelsius Component Development course though.
    Best of Luck
    Charles

Maybe you are looking for

  • Login Problem in OBIEE 11g.

    Hi Experts, I installed OBIEE 11g on XP. Did started BI Services and OBIEE Presentation Services login page appears and entered userid and password. It gives following error. Unable to Sign In An error occurred during authentication. Try again later

  • Wi-Fi not working with iPhone 4 and iPod 3

    We have 2 iPhone 4's and 1 iPod 3. We have never had a problem with Wi-Fi until the last 3 weeks. Now neither of our iPhones/iPods recognise Wi-Fi or have worked since then. Our iMac and laptops all connect to the Wi-Fi without any problems. When fri

  • System audit trail for FBL5N and Mass Change use

    Hello, My client carried out the foll actions yesterday. Called TCode FBL5N using a range of customers When the line items were displayed, they selected some of them and then went into Environment - Mass Change - New Values Here they input a new valu

  • The connection parameters file could not be found

    Hi, I`m receiving the message "The connection parameters file could not be found" every time I try to access my local sybase data base from dbisqlc.exe. I work with Sebel 78 and I have entered as parameters my ID, my password and the path to the .dbf

  • Tortoise and Hare Race

    Hello! I have the following code working on simulating the race of the "Tortoise and Hare." Now, I would like to use its output coordinates to actually draw the shape. What will be the best way to do that? Any new method, either separate of inner, wi