AbstactAction innner class

I need help with an AbstactAction innner class. I want to set a flag to indicate whether a JMenuItem has been accessed. Since I don't know how many "labels" there will be, I'm creating the JMenuItems and their AbstractActions in a loop. The problem is referencing the loop index "i" inside the inner class. Can anyone help?
Thanks,
Error:
local variable i is accessed from within inner class; needs to be declared final
Code snipet:
for(int i=0; i<labels.length; i++) {
  final String item = labels&#091;i&#093;
    menuItems&#091;i&#093; = loadMenu.add(new
      AbstractAction(item) {
        public void actionPerformed(ActionEvent event) {
          // load the item...
          // here's the problem:
          isBundleLoaded&#091;i&#093; = true; // *** error

for(int i=0; i<labels.length; i++) {
  final String item = labels;
final index = i;
menuItems[i] = loadMenu.add(new
AbstractAction(item) {
public void actionPerformed(ActionEvent event) {
// load the item...
// here's the problem:
isBundleLoaded[index] = true;

Similar Messages

  • Troubles with inner classes in swing-panel

    hi,
    I'm having troubles using innner classes as ActionListeners in my swing-panel. I keep getting compile-time errors:
    C:\Java programmer\DocGenerator\ListPanel.java:53: cannot resolve symbol
    symbol : class Actionlistener
    location: class ListPanel.RemoveListener
         class RemoveListener implements Actionlistener {
    ^
    C:\Java programmer\DocGenerator\ListPanel.java:33: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (ListPanel.RemoveListener)
              removeButton.addActionListener(new RemoveListener());
    ^
    2 errors
    Here is the source code:
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    class ListPanel extends JPanel implements ListSelectionListener{
         private JButton addButton = new JButton("add");     
         private JButton removeButton = new JButton("remove");
         private JButton resetButton = new JButton("reset");
         private JList list;
         private DefaultListModel listModel;
         public ListPanel(){
              listModel = new DefaultListModel();
              listModel.addElement("nummer1");
              listModel.addElement("nummer2");
              list = new JList(listModel);
              list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
              list.setSelectedIndex(0);
              list.addListSelectionListener(this);
              JScrollPane listScrollPane = new JScrollPane(list);
              setLayout(new GridLayout(1,2));
              JPanel buttons = new JPanel();
              buttons.setLayout(new GridLayout(3,1));
    //          addButton.addActionListener(this);
              removeButton.addActionListener(new RemoveListener());
    //          resetButton.addActionListener(this);
              buttons.add(addButton);
              buttons.add(removeButton);
              buttons.add(resetButton);
              list.setBorder(BorderFactory.createLineBorder(Color.black,3));
              add(buttons);
              add(list);
         public void actionPerformed(ActionEvent e){
              System.out.println(e);
         public void valueChanged(ListSelectionEvent e){
         class RemoveListener implements Actionlistener {
              public void actionPerformed(ActionEvent e){
                   int index = list.getSelectedIndex();
                   listModel.remove(index);
                   int size = listModel.getSize();
                   if(size==0){
                        addButton.setEnabled(false);
                   } else {
                        if (index==listModel.getSize())
                             index--;
                        list.setSelectedIndex(index);

    Both of the errors is because Actionlistener is not the same as ActionListener. Note the capital 'L' there!

  • Wscompile + xmlbeans: class does not have a public accessible empty constru

    Hi
    I have some schema files from 3gpp.org and created java files with xmlbeans.
    Now I try to use them but wscompile complains:
    error: class provider.VersionType$Enum does not have a public accessible empty constructor
    that class is generated by xmlbeans and I can't modify it...
    The class is an innner class of an interface, and looks like this:
    * Enumeration value class for provider.VersionType.
    * These enum values can be used as follows:
    * <pre>
    * enum.toString(); // returns the string value of the enum
    * enum.intValue(); // returns an int value, useful for switches
    * // e.g., case Enum.INT_X_5_3_0
    * Enum.forString(s); // returns the enum value for a string
    * Enum.forInt(i); // returns the enum value for an int
    * </pre>
    * Enumeration objects are immutable singleton objects that
    * can be compared using == object equality. They have no
    * public constructor. See the constants defined within this
    * class for all the valid values.
    static final class Enum extends org.apache.xmlbeans.StringEnumAbstractBase
    * Returns the enum value for a string, or null if none.
    public static Enum forString(java.lang.String s)
    { return (Enum)table.forString(s); }
    * Returns the enum value corresponding to an int, or null if none.
    public static Enum forInt(int i)
    { return (Enum)table.forInt(i); }
    private Enum(java.lang.String s, int i)
    { super(s, i); }
    static final int INT_X_5_3_0 = 1;
    public static final org.apache.xmlbeans.StringEnumAbstractBase.Table table =
    new org.apache.xmlbeans.StringEnumAbstractBase.Table
    new Enum[]
    new Enum("5.3.0", INT_X_5_3_0),
    private static final long serialVersionUID = 1L;
    private java.lang.Object readResolve() { return forInt(intValue()); }
    Can anyybody help me ?
    thanks
    Gabor

    Sorry, I think you are out-of-luck on this one. The JAXRPC spec mandates that an acceptable value type have a public empty constructor. The only work-around I can suggest is to write a wrapper bean around this one that has such a constructor and use that in you interface instead.

  • Doubt in Inner class

    hi ,
    i have a doubt. How we can access a Inner class name by the outer class name using the Dot(.) operator .
    For example if we want to refer to the Inner class in some other class
    then we must say "OuterClass.InnerClass".
    This type of syntex is ment for the static methods in a class.
    Thus can we assume that Inner class is also a type of static member.
    If not then please explain the syntex.
    i am also not getting the way we create object of the Inner class object in some other class . (i mean to say the logic behind the syntex)
    i.e
    OuterClass Ob1=new OuterClass();
    OuterClass.InnerClass InnOb=Ob1.new InnerClass();
    Cna any one please help me out.
    Regards
    Arunabh

    Hi,
    Inner classes are used to create some functionality in terms of OO way. Like you want to have event handling which will work only for designated GUI classes, then we can make use of Innner class.
    Within a outer classes we do not require any reference of outer object BUT, if you want to access Inner class object outside the class then only we need a reference of Outer object so that we instantitate Inner class object.
    thanks,
    Sandeep

  • JavaDebug Problem

    can anyone help me with the errors in this java prog
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    class Browser extends JFrame
         //declare all HCI elements
         private JLabel locLabel, responseLabel, statusLabel, typeLabel, sizeLabel, modifiedLabel;
         private JTextField locDisplay, response, status, contentType, size, modified;
         private JButton b;
         private JScrollPane displayHolder;
         private JTextArea display;
         private ActionListener l;
         public Browser()
              Container c = getContentPane();
              this.setTitle("Http Text Browser Made With Java by CJW");
              JPanel p = new JPanel();
              p.setLayout(new BorderLayout());
              JPanel pa = new JPanel();
              pa.setBackground(Color.lightGray);
              responseLabel = new JLabel("Pinged Server Response");
              response = new JTextField(20);
              response.setEditable(false);
              statusLabel = new JLabel("Status");
              pa.add(responseLabel);
              pa.add(response);
              pa.add(statusLabel);
              pa.add(status);
              JPanel pb = new JPanel();
              /*to handle pages of larger size were gonna need a scroll bar
              *use a text areato define the size of the viewable area an pass
              it to a scroll pane object this has its own layout manager which handles the scroll/
              display = new JTextArea(20,190);
              displayHolder = new JScrollPaneDisplay(display);
              Font f = new Font("Courier", Font.PLAIN, 12);
              display.setFont(f);
              display.setEditable(false);
              pb.add(displayHolder);
              p.add("North", pa);
              p.add("Center", pb);
              JPanel p1 = new Jpanel();
              b = new JButton("Load");
              l = new Loader();
              locLabel = newJLabel("Url to be loaded: ");
              locDisplay = new JTextField(45);
              p1.setBackground(Color.lightGray);
              p1.add(b);
              p1.add(locLabel);
              p1.add(locDisplay);
              JPanel p2 = new JPanel();
              typeLabel = new JLabel("Content type");
              contentType = new JTextField("File Size: ");
              contentType.setEditable(false);
              sizeLabel = new JLabel("Fle Size");
              size = new JTextField(6);size.setEditable(false);
              p2.setBackground(Color.lightGray);
              p2.add(typeLabel);
              p2.add(contentLabel);
              p2.add(sizeLabel);
              p2.add(size);
              p2.add(modifiedLabel);
              p2.add(modified);
              c.add("Center", p);
              c.add("North", p1);
              c.add("South", p2);
              this.addWindowListener(new WindowAdapter() {
              public void WindowClosing(WindowEvent e)
                   System.exit(0);
         }); //end innner class declaration
         public static void main(String[] args);
              JFrame f = new Browser();
              f.setSize(900,500);
              f.setVisible(true);
         //inner class definition substantial amount of code here
         class Loader implements ActionListener
              public void actionPerformed(ActionEvent e);
              URL target = null;
              String contents = null;
              String type = null;
              String server = null;
              Date date = null;
              int length = 0;
              //start the loop
              try
                   //read the users text from the location field
                   target = new URL(locDisplay.getText());
                   //lets the user know that we are working on the issue at hand
                   status.setText("Finding: " + target);
                   /* initialize an HttpURLCorrection object when
                   correction is made/
                   //use HttpURLCorrection to get response
                   server = fetch.setResponseMessage();     
                   //pass the response for display to the user
                   response.setText(server);
                   BufferedReader in = new BufferedReader(new InputStreamReader(fetch.getInputStream()));
                   //let the user know that " huston we hava data packets incoming"
                   status.setText("Loading....");
                   /*prepare a character array to hold 1kb of data from buffered reader*/
                   char[] buffer = new char[1024];
                   int charsRead;
                   //send data from the bufferd reader to th character array
                   while((charsRead = in.read(buffer, 0, 1024)) != -1);
                        //put character into a data string
                        contents = new String(buffer, 0, charsRead);
                        display.append(contents);
                   //leaving this loop requires in.read() to return to -1 wich assumes no more data is being transferred
                   status.setText("Done. Awaiting you Command");
                   //interrogate output stream headers
                   type = fetch.getContentType();
                   length = fetch.getContentLength();
                   date = new Date(fetch.getastModified());
                   //print information to the approiate feilds
                   contentType.setText(type);
                   size.setText(Interger.toString());
              }//end method
         }//end inner class
    }//end class}

    Working version:import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class Browser extends JFrame
        //declare all HCI elements
        private JLabel locLabel, responseLabel, statusLabel, typeLabel, sizeLabel, modifiedLabel;
        private JTextField locDisplay, response, status, contentType, size, modified;
        private JButton b;
        private JScrollPane displayHolder;
        private JTextArea display;
        private ActionListener l;
        public Browser() {
            Container c = getContentPane();
            this.setTitle("Http Text Browser Made With Java by CJW");
            JPanel p = new JPanel();
            p.setLayout(new BorderLayout());
            JPanel pa = new JPanel();
            pa.setBackground(Color.lightGray);
            responseLabel = new JLabel("Pinged Server Response");
            response = new JTextField(20);
            response.setEditable(false);
            statusLabel = new JLabel("Status");
            status = new JTextField(20);
            pa.add(responseLabel);
            pa.add(response);
            pa.add(statusLabel);
            pa.add(status);
            JPanel pb = new JPanel();
            /*to handle pages of larger size were gonna need a scroll bar
            *use a text areato define the size of the viewable area an pass
            *it to a scroll pane object this has its own layout manager which handles the scroll*/
            display = new JTextArea(20,190);
    //        displayHolder = new JScrollPaneDisplay(display);
            displayHolder = new JScrollPane(display);
            Font f = new Font("Courier", Font.PLAIN, 12);
            display.setFont(f);
            display.setEditable(false);
            pb.add(displayHolder);
            p.add("North", pa);
            p.add("Center", pb);
            JPanel p1 = new JPanel();
            b = new JButton("Load");
            l = new Loader();
            b.addActionListener(l);
            locLabel = new JLabel("Url to be loaded: ");
            locDisplay = new JTextField(45);
            p1.setBackground(Color.lightGray);
            p1.add(b);
            p1.add(locLabel);
            p1.add(locDisplay);
            JPanel p2 = new JPanel();
            typeLabel = new JLabel("Content type");
            contentType = new JTextField("File Size: ");
            contentType.setEditable(false);
            sizeLabel = new JLabel("Fle Size");
            size = new JTextField(6);size.setEditable(false);
            sizeLabel = new JLabel("Fle Size");
            p2.setBackground(Color.lightGray);
            p2.add(typeLabel);
            p2.add(contentType);
            p2.add(sizeLabel);
            p2.add(size);
    //        p2.add(modifiedLabel);
    //        p2.add(modified);
            c.add("Center", p);
            c.add("North", p1);
            c.add("South", p2);
            this.addWindowListener(new WindowAdapter() {
                public void WindowClosing(WindowEvent e) {
                    System.exit(0);
            }); //end innner class declaration
            public static void main(String[] args) {
                JFrame f = new Browser();
                f.setSize(900,500);
                f.setVisible(true);
            //inner class definition substantial amount of code here
            class Loader implements ActionListener
                public void actionPerformed(ActionEvent e) {
                    URL target = null;
                    String contents = null;
                    String type = null;
                    String server = null;
                    Date date = null;
                    int length = 0;
                    //start the loop
                    BufferedReader in=null;
                    HttpURLConnection fetch=null;
                    try
                        //read the users text from the location field
                        target = new URL(locDisplay.getText());
                        //lets the user know that we are working on the issue at hand
                        status.setText("Finding: " + target);
                        /* initialize an HttpURLCorrection object when
                        *correction is made*/
                        try {     
                            fetch = (HttpURLConnection) target.openConnection();     
                            fetch.connect();     
                        } catch(java.io.IOException ioe)    {     
                            ioe.printStackTrace();
                            fetch.disconnect();   
                        //use HttpURLCorrection to get response
                        server = fetch.getResponseMessage();
                        //pass the response for display to the user
                        response.setText(server);
                        in = new BufferedReader(new InputStreamReader(fetch.getInputStream()));
                        //let the user know that " huston we hava data packets incoming"
                        status.setText("Loading....");
                        /*prepare a character array to hold 1kb of data from buffered reader*/
                        char[] buffer = new char[1024];
                        int charsRead;
                        //send data from the bufferd reader to th character array
                        while( (charsRead = in.read(buffer, 0, 1024)) != -1 ) {
                            //put character into a data string
                            contents = new String(buffer, 0, charsRead);
                            display.append(contents);
                        //leaving this loop requires in.read() to return to -1 wich assumes no more data is being transferred
                        status.setText("Done. Awaiting you Command");
                        //interrogate output stream headers
                        type = fetch.getContentType();
                        length = fetch.getContentLength();
                        date = new Date(fetch.getLastModified());
                        //print information to the approiate feilds
                        contentType.setText(type);
    //                    size.setText(Integer.toString());
                        size.setText(String.valueOf(length));
                    }catch(Exception ex) {
                    }finally {
                    fetch.disconnect();   
                    try {in.close();
                    }catch(IOException ioe) {ioe.printStackTrace();
                }//end method
            }//end inner class
        }//end class

  • Quick question on potential Ti-4400 Problem

    Hi all,
    I think I am having some problems with my mobo and just wanted to ask a quick question...
    On my old box, I had major crashing problems when I put the Ti-4400 in while in the middle of 3D games.  I'm almost certain this was due to overheating.
    New rig...many fans!  Everything seems pretty cool.  However, among other problems I am having since putting this new setup together (onboard audio crashes, reboots while using IE, etc.), I am having crashes in the opening intro video to various games.  My recollection is that this is just crappy rez vids that don't tax the video card to nearly what the actual gaming should.  Does this sound right to every/anyone?  I don't seem to have any great problem during heavy 3D use (or 3dmark, etc.).
    Thanks.

    Currently I have actionPerformed method in the editor and an actionPerformed method attached to each button.Well, you should create an Action. The Action can be shared by both a menuItem or a button. Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/misc/action.html]How to Use Actions for more information.
    should the listener be an innner class of the Editor class or an external class.Whether the Action is an inner class or external class doesn't really matter as long as it is a separate class.
    If the Action is unique and will only be used by the parent class, then making it an inner class can simplify coding since it has access to the variables of the class.
    If the Action is more generic and might be able to be used by multiple applications then it should be a separate class so you have code reusability.

  • How do i open a web page with VeriSign Class 3 Extended Validation SSL SGC SS CA certfificate i can't open web pages with this, how do i open a web page with VeriSign Class 3 Extended Validation SSL SGC CA certfificate i can't open web pages with this

    how do i open a web page with VeriSign Class 3 Extended Validation SSL SGC SS CA ?

    Hi
    I am not suprised no one answered your questions, there are simply to many of them. Can I suggest you read the faq on 'how to get help quickly at - http://forums.adobe.com/thread/470404.
    Especially the section Don't which says -
    DON'T
    Don't post a series of questions in  a single post. Splitting them into separate threads increases your  chances of a quick answer.
    PZ
    www.pziecina.com

  • Previewing an image before uploading it using the FileReference class

    Previewing an image before uploading it using the FileReference class in flash player 3 not in SDK4

    Previewing an image before uploading it using the FileReference class in flash player 3 not in SDK4

  • Previewing an image before uploading it using the FileReference class in flex 3

    Previewing an image before uploading it using the FileReference class in flex 3 ?

    hai,
              when this code is used in my application ,i got the name of image and new frame is added each time .But image is not displayed.....
    The code  starts like this
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
                xmlns:mx="library://ns.adobe.com/flex/mx" initialize="init()"   backgroundColor="white" width="100%" height="100%">
        <fx:Script>
    <![CDATA[ 
                    import mx.controls.Alert;
                    import mx.messaging.Channel;
                    import mx.messaging.ChannelSet;
                    import mx.messaging.channels.AMFChannel;
                    import mx.rpc.events.ResultEvent;
                    import mx.controls.Image;
                    import spark.events.IndexChangeEvent;
                    import mx.managers.DragManager;
      <mx:DataGridColumn headerText="Dimension Value"  width="10" dataField="dimensionValue"/>
                                                   <mx:DataGridColumn headerText="Unit Nmae"  width="10" dataField="dimensionUnitName"/>
                                                   </mx:columns>
                                           </mx:DataGrid>
                                           <mx:Spacer width="2%"/>
                                       </mx:HDividedBox>
                                       </mx:VBox>
                   <mx:Spacer height="0"/>
                <mx:VBox width="100%">
                    <s:HGroup height="90" top="0" left="0" right="0" verticalAlign="justify" gap="10" paddingLeft="5" paddingRight="5" paddingTop="5" paddingBottom="5">
                        <s:Button id="btn_loader" top="5" bottom="24" width="100" label="load" click="loadImages()"/>
                        <s:Group width="100%">
                            <s:Group name="cl" top="0" left="0" bottom="0" width="20" mouseOver="//scroll_on(event)" mouseOut="//scroll_off(event)">
                                <s:BitmapImage source="@Embed('../assets/left.jpg')" top="0" left="0" bottom="0" right="0" fillMode="scale"/>   
                            </s:Group>
                            <s:List id="imgList" skinClass="skins.ListSkin" top="-3" left="27" right="28" bottom="10"
                                    dataProvider="{ImageCollection}" itemRenderer="Image_Render">
                                <s:layout>
                                    <s:HorizontalLayout gap="0"/>
                                </s:layout>
                            </s:List>
                            <s:Group name="cr" top="0" right="0" bottom="0" width="20" mouseOver="//scroll_on(event)" mouseOut="//scroll_off(event)">
                                <s:BitmapImage source="@Embed('../assets/right.jpg')" top="-1" left="0" bottom="0" right="0" fillMode="scale"/>
                            </s:Group>
                        </s:Group>
                    </s:HGroup>
                    <s:SkinnableContainer id="dropCanvas" top="100" left="5" right="5" bottom="5" backgroundAlpha="1.0" alpha="1.0"
                                          dragEnter="dropCanvas_dragEnterHandler(event)"
                                          dragDrop="dropCanvas_dragDropHandler(event)" contentBackgroundColor="#914E4E" backgroundColor="#F7F7F7">
                    </s:SkinnableContainer>
                </mx:VBox>
                <mx:Spacer height="5"/>
                                      </mx:VDividedBox>
        </mx:Panel>
    </mx:Canvas>

  • Get the values from the bean class?

    Hi Praveen and all can u please suggest in this,
    I have developped an application In that Create One java class that Extends PageProcesscomponenet and utilizing the Bean That have the Connetion method and retriving the query Based on the Logon customer and spoof customer.
    this functionality I have developped in Pageprocessor component.
    The same functinality I am utilizing another java Class that Extends AbstractPortalcomponent  and utilizing the same Bean.
    But the problem both java classes for I used one Jsp only Dynmic spoof customer will come from the JSP Input filed.
    In the new Java Class How can I capture the Event When I click the Buttong the InputField value capturing into the AbstractPortalcomponent Class.
    I tried like this but It comes as Null Value.
    Event event = myContext.getCurrentEvent();
                              if(event!=null)
                                  InputField ip= (InputField) myContext.getComponentForId("spoofCust");
                                  String spoofCust=ip.getValue().toString();
    Please suggest me in this.
    What is wrong with this.
    Thanks,
    Lohi.
    Message was edited by:
            Lohitha M

    Lohitha,
    Try replacing your two lines of code:
    InputField ip= (InputField) myContext.getComponentForId("spoofCust");
    String spoofCust=ip.getValue().toString();
    with:
    InputField ip = (InputField) getComponentByName("spoofCust");     
    String spoofCust = ip.getValueAsDataType().toString();
    Let me know how that works for you.
    -John

  • Get the values from Exception class

    Hi all ..
    In class i have raised one exception
    when i catch this exception in my program i m able to get the
    error message but i need to get all the parameters that i pass
    when i raise the exception ...
    i have raised like this
          RAISE EXCEPTION TYPE cx_bapi_error
            EXPORTING
              textid = cx_bapi_error=>cx_bo_error
              class_name = 'ZHS_'
              log_no = wa_bapi_return-log_no
              log_msg_no = wa_bapi_return-log_msg_no
              t100_msgid = wa_bapi_return-id
              t100_msgno = wa_bapi_return-number
              t100_msgv1 = wa_bapi_return-message_v1
              t100_msgv2 = wa_bapi_return-message_v2
              t100_msgv3 = wa_bapi_return-message_v3
              t100_msgv4 = wa_bapi_return-message_v4
              STATUS = lt_status
    and caught the exception like this in my program
        CATCH cx_bapi_error INTO go_error.
          gd_text = go_error->get_text( ).
          EXIT.
      ENDTRY.
    in this i m just getting the class name which i have passed in exception
    i need all other parameters that i have passed ..
    if u have any idea pls let me know ..
    Thanks in advance ...

    Hello Jayakumar
    Usually the attributes of standard exception classes are defines as <b>public</b> and <b>read-only</b>. Thus, you should be able to use the following coding:
    DATA:
      go_error   TYPE REF TO cx_bapi_error.  " specific exception class !!!
    TRY.
    RAISE EXCEPTION TYPE cx_bapi_error
    EXPORTING
    textid = cx_bapi_error=>cx_bo_error
    class_name = 'ZHS_'
    log_no = wa_bapi_return-log_no
    log_msg_no = wa_bapi_return-log_msg_no
    t100_msgid = wa_bapi_return-id
    t100_msgno = wa_bapi_return-number
    t100_msgv1 = wa_bapi_return-message_v1
    t100_msgv2 = wa_bapi_return-message_v2
    t100_msgv3 = wa_bapi_return-message_v3
    t100_msgv4 = wa_bapi_return-message_v4
    STATUS = lt_status.
    CATCH cx_bapi_error INTO go_error.
    gd_text = go_error->get_text( ).
    WRITE: go_error->t100_msgid,  " perhaps the attributes have different name
                go_error->t100_msgno, " check attribute names in SE24
    EXIT.
    ENDTRY.
    Regards
      Uwe

  • Problem with setContentPane() in JFrame class

    I recently discovered a problem with the setContentPane method in the JFrame class. When I use setContentPane(Container ..), the previously existing contentPane remains in the stack. I have tried nullifying getContentPane(), and all manner of things, but, each time I use setContentPane, I have another instance of a JPanel in the stack.
    I'm using code similar to setContentPane(new CustomJPanel()); and each time the user changes screens, and a similar call to that is made, the old CustomJPanel instance remains in the stack. Can anyone suggest a way around this? On their own the panels do not take up very much memory, but after several hours of usage, they will build up.

    I tried what you suggested; it only resulted in a huge performance decrease. The problem with memory allocation is still there.
    Here is the method I use to switch screens in my app:
    public static void changeScreen (JPanel panel){
              try{
                   appFrame.setTitle("Wordinary : \""+getTitle()+"\"");
                   appFrame.setContentPane(panel);
                   appFrame.setSize(appFrame.getContentPane().getPreferredSize());     
                   appFrame.getContentPane().setBackground(backColour);
                   for (int i = 0; i < appFrame.getContentPane().getComponents().length; i++)
                        appFrame.getContentPane().getComponents().setForeground(textColour);
                   //System.out.println("Background colour set to "+backColour+" text colour set to "+textColour);
                   appFrame.validate();
              catch (Exception e){
                   //System.out.println("change");
                   e.printStackTrace();
    And it is called like this:
    changeScreen(new AddWordPanel());The instantiation of the new instance is what is causing the memory problems, but I can't think of a way around it.

  • Problem with Outer and Inner Classes....or better way?

    Right now I'm trying to create an Inner class.
    My .java file compiles ok, and I create my jar file too.
    But when I try to instantiate the Inner class, it fails:
    java.lang.NoClassDefFoundError: com/myco/vlXML/vlXML$vlDocument.
    Here's the class code:
    public class vlXML{
        private ArrayList myDocList=new ArrayList(); //holds documents
        public vlXML(){
        private class vlDocument{
            public vlDocument(){
            //stuff goes here
        public vlDocument vlDOC(){
            return new vlDocument();
        public void addDocument(){
            vlXML xxx=new vlXML();
            vlDocument myDoc=xxx.vlDOC();
            myDocList.add(myDoc);
        public int getNumDocs(){
            return myDocList.size();
    }Then, from a jsp page, I call:
    vlXML junk1=new vlXML();
    junk1.addDocument();...and get the error...
    Can someone help me figure out why it's failing?
    Thanks....

    You nailed it - thanks....(duh!)
    While I have your attention, if you don't mind, I have another question.
    I'm creating a Class (outer) that allows my users to write a specific XML file (according to my own schema).
    Within the XML file, they can have multiple instances of certain tags, like "Document". "Document"s can have multiple fields.
    Since I don't know how many "Documents" they may want, I was planning on using an Inner Class of "Document", and then simply letting them "add" as many as necessary (thus the original code posted here).
    Does that seem like an efficient (logical/reasonable) methodology,
    or is there there something better?
    Thanks Again...

  • JBO:33001 bc4j.xcfg file not found in class path

    Hi,
    I am yet another victim of the age-old error JBO:33001 bc4j.xcfg file not found in class path, When i have my BC4JApp.jar in Tomcat Web-inf/lib directory. All the other jar files and class files in my webserver-application web-inf classes and lib directory works.
    But Tomcat server is not able to read this bc4j.xcfg file. I can see in my jar file that this bc4j.xcfg exists and in the specified package directory. still the problem persists. My BC4JApp.jar is perfectly working when i use JDeveloper. but not when i use tomcat4.0 and call a JSP using BC4JApp.jar from browser (My environment is Jdeveloper3.2, Tomcat4.0+IIS in middle tier and oracle 8i as DB, everything on windows2k)
    I have gone through almost all the threads possible that relates to this error in this form. None of them have a answer except to say "put the file in classpath". and last reply is "will fix in jDeveloper 9i. So what happens to us who are working in Jdeveloper 3.2?
    1. I have this file in my jar file.
    2. I also tried creating a seperate directory manually, with the same name as my package under web-inf/classes, web-inf/lib , just under web-inf directory and atlast under approot directory also. I tried having my package directory containing bc4j.xcfg in these folders one at a time and also tried having this directory in all these folders at the same time.
    Still no solution.
    Itz frustrating that neither proper documentation nor a right url page nor i am aware of available addressing this. page links given in above threads only gives me the wonderful page of ie's "Page cannot be displayed".
    Is there a answer to this error and my problem. If this doesn't work, then i have to all the way develop from scratch creating my jsp using JDBC calls and Stored packages etc.
    I don't want to give up on this Jdeveloper at this final moment because if this bc4j.xcfg file is found, my application will work perfectly. on these final moments, if this doesn't work, i am frightened to imagine to develop my application in standard way. Atlast, if thatz the option left,we have to do that bcos our production date is close by.
    Please can some one in this forum or Jdeveloper help me to solve this problem. I am desperate and very urgent.
    Waiting for a reply from Jdev team very much...
    ( I just posted in the other thread which is pretty old, dated backto May 2001, which was relevant to this error. Just to make sure it is noticed, I am posting it seperately too)
    Thanks
    Hari(2/3/02)

    Hi All,
    For those who are following this thread, I got a solution for this error with the help of Jdev Team.
    This solution may work, if you have deployed your application in Tomcat4.0.1. This is the environment in which I work and tested.
    As you may be aware, Tomcat ignores value in CLASSPATH variable.
    To see any files that are existing or newly deployed, it has it own way of detecting it.
    Addition information on Tomcat working, you can follow this link,
    http://jakarta.apache.org/tomcat/tomcat-4.0-doc/index.html
    Coming to point, Tomcat has got five classloaders and each classloader invoked, looks in their related directories for files in following order.
    1. /WEB-INF/classes of your web-application
    2. /WEB-INF/lib/*.jar of your web application
    3. BootStrap classes of your JVM (Tomcat's $JAVA_HOME/jre/lib/ext)
    4. System class loader classes($CATALINA_HOME/bin/bootstrap.jar,CATALINA_HOME/lib/tools.jar)
    5. $CATALINA_HOME/common/classes
    6. $CATALINA_HOME/common/lib/*.jar
    7. $CATALINA_HOME//classes
    8. $CATALINA_HOME/lib/*.jar
    So All your individual application related files should be deployed in your application's WEB-INF/classes or WEB-INF/lib directory accordingly.
    If your application files are unpacked, they should be deployed or copied under WEB-INF/classes directory
    if the files are within a jar, they should be under WEB-INF/lib directory.
    If your Jar-files contains bc4j components, then those jar files should be deployed under WEB-INF/lib directory. Also,do the next step to copy all relavant BC4J runtime libraries under lib directory.
    IMPORTANT: Please remember to copy and paste all the required BC4j runtime libraries in the Same WEB-INF/lib directory along with your application jar files. This is the real reason which can solve this JBO:33001 to disappear. It worked for me.
    To configure your directory for tag-lib uri's, use web.xml to set the taglib-uri attribute.
    Put your web.xml and DataTags.tld in the WEB-INF directory.
    Your simple web.xml may look like as follows.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
         <taglib>
              <taglib-uri>
                   /webapp/DataTags.tld
              </taglib-uri>
              <taglib-location>
                   /WEB-INF/DataTags.tld
              </taglib-location>
         </taglib>
    </web-app>
    You may then modify this web.xml to suit further requirements of your application.
    Remember to stop and restart the Tomcat Server (service) by using shutdown and startup scripts after updating any jar files/class files/ JSP or source files deployed in Tomcat.
    Sometimes, only this helps even though your context's reloadable attribute is set to true in Tomcat Server's server.xml file.
    Hope this above information helps you to solve this error in Tomcat environment. My Sincere thanks once again to Juan and Jdev team for their help and efforts to solve this problem.
    Thanks
    Hari

  • Help Counting Vowels and Consonants using a class

    I'm currently working on a class project where I need take a user inputed string and count how many vowels and/or consonants are in the String at the user discretion. I have the main logic program working fine. However, the trouble I'm running into is how to take the string the user inputed and pass that data into the class method for counting.
    Here is the code for the program:
    package vowelsandconsonants;
    import java.util.Scanner;
    public class VowelConsCounter {
        public static void main(String[] args) {
            String input; //User input
            char selection; //Menu selection
            //Create a Scanner object for keyboard input.
            Scanner keyboard = new Scanner(System.in);
            //Get the string to start out with.
            System.out.print("Enter a string: ");
            input = keyboard.nextLine();
            //Create a VowelCons object.
            VowelCons vc = new VowelCons(input);
            do {
                // Display the menu and get the user's selection.
                selection = getMenuSelection();
                // Act on the selection
                switch (Character.toLowerCase(selection)) {
                    case 'a':
                        System.out.println("\nNumber of Vowels: " +
                                vc.getNumVowels());
                        break;
                    case 'b':
                        System.out.println("\nNumber of consonats: " +
                                vc.getNumConsonants());
                        break;
                    case 'c':
                        System.out.println("\nNumber of Vowels: " +
                                vc.getNumVowels());
                        System.out.println("Number of consonants: " +
                                vc.getNumConsonants());
                        break;
                    case 'd':
                        System.out.print("Enter a string: ");
                        input = keyboard.nextLine();
                        vc = new VowelCons(input);
            } while (Character.toLowerCase(selection) != 'e');
         * The getMenuSelection method displays the menu and gets the user's choice.
        public static char getMenuSelection() {
            String input;  //To hold keyboard input
            char selection;  // The user's selection
            //Create a Scanner object for keyboard input.
            Scanner keyboard = new Scanner(System.in);
            //Display the menu.
            System.out.println("a) Count the number of vowels in the string.");
            System.out.println("b) Count the number of consonants in the string.");
            System.out.println("c) Count both the vowels and consonants in the string.");
            System.out.println("d) Enter another string.");
            System.out.println("e) Exit the program.");
            //Get the user's selection
            input = keyboard.nextLine();
            selection = input.charAt(0);
            //Validate the input
            while (Character.toLowerCase(selection) < 'a' ||
                    Character.toLowerCase(selection) > 'e') {
                System.out.print("Only enter a,b,c,d or e:");
                input = keyboard.nextLine();
                selection = input.charAt(0);
            return selection;
    class VowelCons {
        private char[] vowels;
        private char[] consonants;
        private int numVowels = 0;
        private int numCons = 0;
        public VowelCons(String str) {
        public int getNumVowels() {
            return numVowels;
        public int getNumConsonants() {
            return numCons;
        private void countVowelsAndCons() {
            for (int i = 0; i < total; i++) {
                char ch = inputString.charAt(i);
                if ((ch == 'a') || (ch == 'A') || (ch == 'e') || (ch == 'E') || (ch == 'i') || (ch == 'I') || (ch == 'o') || (ch == 'O') || (ch == 'u') || (ch == 'U')) {
                    numVowels++;
                } else if (Character.isLetter(ch)) {
                    numCons++;
    }The UML given to me by my instructor calls for the counting method to be private. Being that I'm not too familiar with Java syntax I did not know if that may cause a problem with passing the user's input into that method.

    Well the only compilers i get are due to the code:
    private void countVowelsAndCons() {
            for (int i = 0; i < total; i++) {
                char ch = inputString.charAt(i);
                if ((ch == 'a') || (ch == 'A') || (ch == 'e') || (ch == 'E') || (ch == 'i') || (ch == 'I') || (ch == 'o') || (ch == 'O') || (ch == 'u') || (ch == 'U')) {
                    numVowels++;
                } else if (Character.isLetter(ch)) {
                    numCons++;
        }However, that is due to the fact that i have no data for those variables to use. I'm pretty much stuck on how to get the string the user inputs into that method shown above so the code can perform the task of counting the vowels and consonants.
    If i comment out the code within that function the program compiles and will allow me to enter the string and use the options but since i can't figure out how to pass the input to the counting method the program returns 0 for everything.

Maybe you are looking for

  • How do I use iCloud for non-iCloud apps

    I have a password manager app on both my iPhone 4S and iPad2. According to the description in the App Store and the About/Settings/Help section of the app, I can use iCloud to sync between the two, meaning that what I put on one will show up on the o

  • IOS 8 Photostream and Pages

    Ok, ever since upgrading to iOS 8 I've noticed some issues with how Pages and Photostream works with mine and my wife's iPhone. We both have iPhone 5s w/ iOS 8 and now the pictures she takes on her phone do not automatically download into my Photostr

  • Network Attached Storage (NAS) and Aperture (Drobo, ReadyNAS, etc)

    My photos are growing past a single hard drive worth of space - I'd like to attach a Droboshare to my iMac, and keep my photos on it. I was wondering - will this still have usable speed, if I store my library locally (I believe this is called referen

  • Provider hosted app installed on SharePoint 2013 on premises is returning internal 500 error !

    Hello, I have deployed the basic provider hosted app on sharepoint 2013 on premises. However when I try to run the app, its throwing an error on following as mentioned in screen: It seems an authentication issue, would you please tell me how can I re

  • Please help me get started with Databases...

    I've spent all day moving from one tutorial to the other trying to figure out how to use a Database with Java. I haven't found anything that explained things basic enough for me to understand, however, I did download and install MDAC 2.8 which was su