Application & JApplet - Inner Classes

Hi,
I am having problems understanding the purpose of Inner Classes.
1. Is purpose of inner class in an Application to take care of what init method
takes care of in a JApplet. I believe init method in JApplet brings up the browser and
xecutes statements in init()?
2. Is it possible to write the enclosed Application without using an Inner Class?
If so, can someone please show me how?
3. Is it possible to write the enclosed JApplet using an inner Class?
If so, can someone please show me how?
Maybe if I see how an Application and JApplet are written with and without inner classes, this may help me understand.
Thank you.
//APPLICATION USING AN INNER CLASS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//outerclass
public class InnerTest extends JFrame
private JTextField numField, sumField;
private int sum = 0;
public InnerTest()
super("Inner Test");
Container c = getContentPane();
c.setLayout(new FlowLayout());
ActionEventHandler handler = new ActionEventHandler();
numField = new JTextField(10);
sumField = new JTextField(10);
numField.addActionListener(handler);
c.add(numField);
c.add(sumField);
public static void main(String args[])
InnerTest win = new InnerTest();
win.setSize(400, 140);
win.show();
//Innerclass
private class ActionEventHandler implements ActionListener
public void actionPerformed(ActionEvent e)
sum += Integer.parseInt(numField.getText()); // access to sum and numField
numField.setText("");
sumField.setText(Integer.toString(sum));
JAPPLET
Below is modification of above code to a JApplet
without using inner class. I have CAPITALIZED MODIFICATIONS.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class InnerTest extends JAPPLET
private JTextField numField, sumField;
private int sum = 0;
public VOID INIT()
super("Inner Test");
Container c = getContentPane();
c.setLayout(new FlowLayout());
ActionEventHandler handler = new ActionEventHandler();
numField = new JTextField(10);
sumField = new JTextField(10);
numField.addActionListener(THIS);
c.add(numField);
c.add(sumField);
public void actionPerformed(ActionEvent e)
sum += Integer.parseInt(numField.getText()); // access to sum and numField
numField.setText("");
sumField.setText(Integer.toString(sum));

1. Is purpose of inner class in an Application to
take care of what init method
takes care of in a JApplet. I believe init method in
JApplet brings up the browser and
xecutes statements in init()?No. The init() method of an applet is similar to the constructor for an application. It is used to initialize data for the applet, the same data you will initialize in the constructor of the application.
>
2. Is it possible to write the enclosed Application
without using an Inner Class?Yes it is possible. The power of an inner class is that is has access even to private member variables of the enclosing class. In your case the event handler has access to the private variables: numField and sumField. If you do not use an inner class you have to pass a reference to your frame in the event handler's constructor and access the variables through that reference. But in this case you do not have access to private variables. So you must provide methods to access those variables or you must change theri visibility.
ActionEventHandler handler = new ActionEventHandler(this);Provide accessor methods in InnerTest class:
public String getTextString(){
     return numField.getText();
public void setTextString(String text){
     numField.setText(text);
}As for the applet it works just as your application in this case, you can use inner classes or not but with the same restrictions.
I hope you can understand what I tried to explain.

Similar Messages

  • Problem creating inner class for JTable panel in a class for an application

    i want to create an inner class for a database application development.
    but there is occuring exceptions & errors.i want to retrieve data & enter data also from many tables in a database.i want an urgent help for this plz.

    http://forum.java.sun.com/thread.jsp?forum=57&thread=271752
    See this thread, please.

  • Exception handling for eventlistener inner classes in swing application

    Hi,
    This is probably sooo easy I will kick myself when I find out, but anyway here goes...
    I have an inner class thus...
              cmbOffence.addFocusListener(new FocusAdapter() {
                        public void focusGained(FocusEvent e) {
                             cmbOffence_focusGained(e);
                        public void focusLost(FocusEvent e) {
                        try {
                             cmbOffence_focusLost(e);
                        } catch (XMLConfigurationException xce) {
                   });where cmbOffence.focusLost(e) is looking up to a class that throws an exception which should be fatal i.e. the swing app should close. I want to handle this exception gracefully so therefore want to throw the XMLConfiguratinException to the main application class. How do I do this?? I guess this is more of an inner classes question than a swing one per se, but any help would be appreciated.
    Thanks
    Conrad

    I think you're maybe confusing classes and threads. In the typical Swing application the "main" thread finishes after openning the initial window and there really is no main thread to report back to. In fact the dispatcher thread is about as "main" as they come.
    To exit such a program gracefully is usually a matter of cleaning up resources and calling dispose on the main window, which you can perfectly well do from the dispatcher thread.
    I usually wind up with some centralised method to deal with unexpected exceptions, for example as part of my desk top window in an MDI, but it's called from the dispatcher thread as often as from anywhere.

  • Null pointer exception with inner class

    Hi everyone,
    I've written an applet that is an animation of a wheel turning. The animation is drawn on a customised JPanel which is an inner class called animateArea. The main class is called Rotary. It runs fine when I run it from JBuilder in the Applet Viewer. However when I try to open the html in internet explorer it gives me null pointer exceptions like the following:
    java.lang.NullPointerException      
    at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2761)      
    at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2722)      
    at Rotary$animateArea.paintComponent(Rotary.java:251)      
    at javax.swing.JComponent.paint(JComponent.java:808)      
    at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4771)      
    at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4724)      
    at javax.swing.JComponent._paintImmediately(JComponent.java:4668)      
    at javax.swing.JComponent.paintImmediately(JComponent.java:4477)      
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)      
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)      
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)      
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:448)      
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)      
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)      
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)      
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)      
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    Do inner classes have to be compiled seperately or anything?
    Thanks a million for you time,
    CurtinR

    I think that I am using the Java plugin ( Its a computer in college so I'm not certain but I just tried running an applet from the Swing tutorial and it worked)
    Its an image of a rotating wheel and in each sector of the wheel is the name of a person - when you click on the sector it goes red and the email window should come up (that doesn't work yet though). The stop and play buttons stop or start the animation. It is started by default.
    This is the code for the applet:
    import java.applet.*;
    import javax.swing.JApplet;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import java.awt.image.*;
    import java.util.StringTokenizer;
    import java.net.*;
    public class Rotary extends JApplet implements ActionListener, MouseListener
    public boolean rotating;
    private Timer timer;
    private int delay = 1000;
    private AffineTransform transform;
    private JTextArea txtTest; //temp
    private Container c;
    private animateArea wheelPanel;
    private JButton btPlay, btStop;
    private BoxLayout layout;
    private JPanel btPanel;
    public Image wheel;
    public int currentSector;
    public String members[];
    public int [][]coordsX, coordsY; //stores sector no. and x or y coordinates for that point
    final int TOTAL_SECTORS= 48;
    //creates polygon array - each polygon represents a sector on wheel
    public Polygon polySector1,polySector2,polySector3, polySector4, polySector5,polySector6,polySector7,polySector8,polySector9,polySector10,
    polySector11,polySector12,polySector13,polySector14,polySector15,polySector16,polySector17,polySector18,polySector19,polySector20,
    polySector21,polySector22,polySector23,polySector24,polySector25,polySector26,polySector27,polySector28,polySector29,polySector30,
    polySector31,polySector32,polySector33,polySector34,polySector35,polySector36,polySector37,polySector38,polySector39,polySector40,
    polySector41,polySector42,polySector43,polySector44,polySector45,polySector46,polySector47,polySector48;
    public Polygon polySectors[]={polySector1,polySector2,polySector3, polySector4, polySector5,polySector6,polySector7,polySector8,polySector9,polySector10,
                      polySector11,polySector12,polySector13,polySector14,polySector15,polySector16,polySector17,polySector18,polySector19,polySector20,
                      polySector21,polySector22,polySector23,polySector24,polySector25,polySector26,polySector27,polySector28,polySector29,polySector30,
                      polySector31,polySector32,polySector33,polySector34,polySector35,polySector36,polySector37,polySector38,polySector39,polySector40,
                      polySector41,polySector42,polySector43,polySector44,polySector45,polySector46,polySector47,polySector48};
    public void init()
    members = new String[TOTAL_SECTORS];
    coordsX= new int[TOTAL_SECTORS][4];
    coordsY= new int[TOTAL_SECTORS][4];
    currentSector = -1;
    rotating = true;
    transform = new AffineTransform();
    //***********************************Create GUI**************************
    wheelPanel = new animateArea(); //create a canvas where the animation will be displayed
    wheelPanel.setSize(600,580);
    wheelPanel.setBackground(Color.yellow);
    btPanel = new JPanel(); //create a panel for the buttons
    btPanel.setLayout(new BoxLayout(btPanel,BoxLayout.Y_AXIS));
    btPanel.setBackground(Color.blue);
    btPanel.setMaximumSize(new Dimension(30,580));
    btPanel.setMinimumSize(new Dimension(30,580));
    btPlay = new JButton("Play");
    btStop = new JButton("Stop");
    //txtTest = new JTextArea(5,5); //temp
    btPanel.add(btPlay);
    btPanel.add(btStop);
    // btPanel.add(txtTest); //temp
    c = getContentPane();
    layout = new BoxLayout(c,layout.X_AXIS);
    c.setLayout(layout);
    c.add(wheelPanel); //add panel and animate canvas to the applet
    c.add(btPanel);
    wheel = getImage(getDocumentBase(),"rotary2.gif");
    getParameters();
    for(int k = 0; k <TOTAL_SECTORS; k++)
    polySectors[k] = new Polygon();
    for(int n= 0; n<4; n++)
    polySectors[k].addPoint(coordsX[k][n],coordsY[k][n]);
    btPlay.addActionListener(this);
    btStop.addActionListener(this);
    wheelPanel.addMouseListener(this);
    startAnimation();
    public void mouseClicked(MouseEvent e)
    if (rotating == false) //user can only hightlight a sector when wheel is not rotating
    for(int h= 0; h<TOTAL_SECTORS; h++)
    if(polySectors[h].contains(e.getX(),e.getY()))
    currentSector = h;
    wheelPanel.repaint();
    email();
    public void mouseExited(MouseEvent e){}
    public void mouseEntered(MouseEvent e){}
    public void mouseReleased(MouseEvent e){}
    public void mousePressed(MouseEvent e){}
    public void email()
    try
    URL rotaryMail = new URL("mailto:[email protected]");
    getAppletContext().showDocument(rotaryMail);
    catch(MalformedURLException mue)
    System.out.println("bad url!");
    public void getParameters()
    StringTokenizer stSector;
    String parCoords;
    for(int i = 0; i <TOTAL_SECTORS; i++)
    {               //put member names in applet parameter list into an array
    members[i] = getParameter("member"+i);
    //separate coordinate string and store coordinates in 2 arrays
    parCoords=getParameter("sector"+i);
    stSector = new StringTokenizer(parCoords, ",");
    for(int j = 0; j<4; j++)
    coordsX[i][j] = Integer.parseInt(stSector.nextToken());
    coordsY[i][j] = Integer.parseInt(stSector.nextToken());
    public void actionPerformed(ActionEvent e)
    wheelPanel.repaint(); //repaint when timer event occurs
    if (e.getActionCommand()=="Stop")
    stopAnimation();
    else if(e.getActionCommand()=="Play")
    startAnimation();
    public void startAnimation()
    if(timer == null)
    timer = new Timer(delay,this);
    timer.start();
    else if(!timer.isRunning())
    timer.restart();
    Thanks so much for your help!

  • Calling functions of the inner class in .java code file

    Hello,
    I created a .java code file in Visual J#.Net and converted it into
    the application by adding the "public static void main(String args[])"
    function.
    I have created the two classes one extends from Applet, and the other
    extends from Frame. The class which I inherited from the Frame class becomes
    the inner class of the class extended from the Applet. Now How do I
    call the functions of the class extended from Frame class - MenuBarFrame
    class. the outline code is
    public class menu_show extends Applet
    ------init , paint action function---------
    public class MenuBarFrame extends Frame
    paint,action function for Menu
    public static void main(String args[])
    applet class instance is created
    instance of frame is created
    Menu , MenuBar, MenuItem instance is created
    and all these objects added
    I have Created MenuBarFrame class instance as
    Object x= new menu_show().new MenuBarFrame
    ????? How to call the functions such as action of MenuBarFrame class - what
    should be its parameters??????
    }

    Here's how I would do it:
    interface Operation {
        public int op(int y);
    class X {
        private int x;
        public X(int x) {
            this.x = x;
        private class Y implements Operation {
            public int op(int y) {
                return x+y;
        public Operation createOperation() {
            return new Y();
        public static void main(String[] args) {
            X app = new X(17);
            Operation f = app.createOperation();
            System.out.println(f.op(-11));
    }Your code, however, has some serious "issues". You typically don't
    instantiate an applet class -- that's the job of the applet viewer or Java plugin
    your browser is using. If you instantiate the applet directly, you're going
    to have to supply it an AppletStub. Do you really want to go that way?
    Again, use an applet viewer or browser, or better yet, why write applets at all?

  • General class and setting properties vs specific inner class

    This is a general question for discussion. I am curious to know how people differentiate between instantiating a standard class and making property adjustments within a method versus defining a new inner class with the property adjustments defined within.
    For example, when laying out a screen do you:
    - instantiate all the objects, set properties, and define the layout all within a method
    - create an inner class that defines the details of the layout (may reference other inner classes if complex) that is then just instantiated within a method
    - use some combination of the two depending on size and complexity.
    - use some other strategy
    Obviously, by breaking the work up into smaller classes you are simplifying the structure since each class is taking on less responsibility, as well as hiding the details of the implementaion from higher level classes. On the other hand, if you are just instantiating an object and making some SET calls is creating an inner class overkill.
    Is there a general consensus for an approach? I am curious to hear the approach of others.

    it's depends on your design..
    usually, if the application is simple and is not expected to be maintain (update..etc..) than I just have all the building of the gui within the same class (usually..the main class that extends JFrame).
    if the application follows the MVC pattern, than I would have a seperate class that build the GUI for a particular View. I would create another class to handle the ActionEvent, and other event (Controller)
    I rarely use inner class...and only use them to implements the Listerner interface (but only for simple application)..

  • Inner classes should appear in jar?

    At first thanks for answering my question: I did resolve the problem of excluding files, so the .java and .html are not present anymore�.. but the problem stays: I do see the applet in the applet viewer but not on the safari (mac Version 3.0.4) browser. The tag, I think is ok:
    <applet code="Slides.class" width="500" height="500" archive="slides.jar"></applet>
    A second question related to this problem might be, that the two inner class files that show up in the build/class file are not present in the jar. The application consists of just one single class (I already moved some initialization stuff from the constructor to the init). The class is called Slides.class and the compiler generates the Slides$1, Slides$xxx and Slides$yyyy. Should they all be included in the jar I only so the main class.
    Thanks a lot
    willemjav
    The (still dirty) code is here (you need a folder with images files called xxxx#img01 etc.) and a first image called firstpic.jpg
    * Slides
    * Created on February 3, 2008, 10:25 PM
    * The application does an applet slide show
    * of a list of images files set in the folder
    * Imagestore each 7 seconds changes the picture
    * see DURATION
    * still to do an image list check on file extentions
    * and a fade in/ out
    * @author wdragstra
    import java.awt.*;
    import java.awt.Image;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.net.URL;
    import java.io.*;
    import java.awt.image.BufferedImage;
    public class Slides2 extends JPanel implements ActionListener {
    private int count, maxcount, x, y, duration,
    textposx, textposy, imgwidth, imgheight;
    static int framew, frameh;
    private boolean intro;
    private static final int LOAD = 7000, PAUSE=4000; // animation duration
    private static final String FILE_NAME="Imagestore"; // the image file name in work directory
    private File directory; // File object referring to the directory.
    private String[] picfilenames; // Array of file names in the directory.
    private JOptionPane infoPane;
    private JPanel picttextPanel;
    private JLabel textLabel;
    private Timer load, timer, pause;
    private Image firstpic;
    private BufferedImage OSC;
    public Slides2() { // construtor
    framew = 350; // frame size to be set
    frameh = 390;
    textposx = 130; // text position to be set
    textposy = 20;
    duration = 9000; // image duration to be set
    count=0; // image and textstring counters
    maxcount = 0;
    load = new Timer(LOAD, this); // the three animation timers
    readImageFilelist(FILE_NAME); // get the content of the image folder
    firstpic = downloadImage("firstpic.jpg");
    orderImages();
    timer = new Timer(duration, this);
    infoPane = new JOptionPane(); // containing the 1) firstpic.jpg the
    picttextPanel = new JPanel(); // first picture or only picture
    textLabel = new JLabel(" INFO ", JLabel.CENTER); // 2) the parameter file called
    this.setLayout(null); // imageanimater.txt 3) the imgefiles
    textLabel.setBounds(textposy,textposx, 300 , 50); // with name xxxxx#img01 - 99
    add(textLabel);
    intro = true;
    load.start();
    public void actionPerformed(ActionEvent evt) { // timer listner
    if (evt.getSource() == load) { // first timer only ones for first picture
    // second timer for image duration
    load.stop();
    timer.start();
    intro=false;
    repaint();
    if (evt.getSource() == timer) {
    if (count == maxcount)
    count = 0;
    repaint();
    count++;
    void readImageFilelist(String dirname) { // gets the list of images
    directory = new File(dirname); // of folder imagestore
    if (directory.isDirectory() == false) { // in work directory
    if (directory.exists() == false)
    JOptionPane.showMessageDialog(infoPane,
    " there is no directory called " + directory);
    else
    JOptionPane.showMessageDialog(infoPane, directory +
    " is not a directory. ");
    else {
    picfilenames = directory.list(); // stores the list of file names
    for (int i = 0; i < picfilenames.length; i++) {
    if (imageNamecheck(picfilenames)) { // check correct file extension #img
    picfilenamesmaxcount = picfilenames; // eliminate the incorrect ones
    maxcount++;
    if (maxcount == 0)
    JOptionPane.showMessageDialog(infoPane,
    "no valid files present ");
    private boolean imageNamecheck(String st) {
    int pos = st.indexOf("#img");
    if (pos == -1)
    return false;
    else return true;
    private int imagePos(String st) {
    int posnmb=0; // convert string-number into int
    int pos = st.indexOf("#img"); // when no image present returns -1
    if (pos==-1) {
    JOptionPane.showMessageDialog(infoPane,
    "The file has�t the correct format #img01-#img99 ");
    return 0;
    else
    return pos+4;
    private void orderImages() { // sort de file list of images 00-99
    int lastarray = maxcount-1;
    int trynmb=0, maxnmb=0, index=0, pos=0;
    String tempfl="";
    while(lastarray != 0) {
    index = 0;
    pos = imagePos(picfilenames[0]);
    try { maxnmb = Integer.parseInt(picfilenames[0].substring(pos, pos+2));
    catch ( NumberFormatException e ) {
    JOptionPane.showMessageDialog(infoPane,
    "File format: #img01-#img99 " + e);
    for (int i = 1; i <= lastarray; i++) {
    pos = imagePos(picfilenames);
    try { trynmb = Integer.parseInt(picfilenames.substring(pos, pos+2));
    catch ( NumberFormatException e ) {
    JOptionPane.showMessageDialog(infoPane,
    "File format: #img01-#img99 " + e);
    if (trynmb>maxnmb) {
    maxnmb = trynmb;
    index=i;
    tempfl = picfilenameslastarray;
    picfilenameslastarray = picfilenamesindex;
    picfilenamesindex = tempfl;
    lastarray--;
    // for (int i = 0; i < maxcount; i++) {
    //JOptionPane.showMessageDialog(infoPane,
    // "last array " + i + " filename " + picfilenames);
    private Image scaleImage(BufferedImage bimg) { // scale buffered image into image fill
    try {
    imgwidth = bimg.getWidth(this);
    catch (Exception e) {
    JOptionPane.showMessageDialog(infoPane, "can not get image width " + e);
    try {
    imgheight = bimg.getHeight(this);
    catch (Exception e) {
    JOptionPane.showMessageDialog(infoPane, "can not get image height " + e);
    double scalerate = calcScale(imgwidth, imgheight); // calls the actual scaling method
    imgwidth = (int)(imgwidth * scalerate);
    imgheight = (int)(imgheight * scalerate);
    x = (int)(framew - imgwidth)/2;
    y = (int)(frameh - imgheight)/2;
    DecimalFormat myFormatter = new DecimalFormat("######.##");
    String xx = myFormatter.format(scalerate);
    String yy = myFormatter.format(scalerate);
    //JOptionPane.showMessageDialog(infoPane,
    // "image size " + imgwidth + " / " + imgheight + " new size " + newidth + " / " + newheight + " scalerate " + xx
    // + " insets " + insetw + " / " + inseth );
    try {
    Image img = bimg.getScaledInstance(imgwidth, imgheight, bimg.SCALE_FAST); // the actual scaling
    return img;
    catch (IllegalArgumentException e) {
    JOptionPane.showMessageDialog(infoPane, " can not scale the image " + bimg + " " + e);
    return null;
    private double calcScale(int imgwidth, int imgheight) {
    double sc=0, x=0;
    if ((double)framew-imgwidth < frameh-imgheight) { // gets the smallest side of the picture
    sc = (double)framew/imgwidth; // to scale to frame size (sc)
    else {
    sc = (double)frameh/imgheight;
    return sc;
    private Image downloadImage(String filename) { //downloads image and call the scaling
    BufferedImage bufimg=null;
    Image img=null;
    ClassLoader cl = Slides2.class.getClassLoader();
    URL imageURL = cl.getResource(filename);
    try {
    bufimg = ImageIO.read(imageURL);
    img=scaleImage(bufimg);
    catch (Exception e){
    JOptionPane.showMessageDialog(infoPane, " can not download " + filename + " " + e);
    return img;
    private void displayText(int cnt) {
    textLabel.setFont(new Font("Serif", Font.BOLD, 18));
    textLabel.setForeground(Color.RED);
    textLabel.setText("xcount maxcount " + count + " / " + maxcount);
    public void paintComponent(Graphics g) { // the timer calls the component
    // to draw the pictures
    if (intro) { // the first pic and its display time
    g.drawImage(firstpic,0, 0, imgwidth, imgheight, this);
    else {
    //g.drawImage(img, dest_x1, dest_y1, dest_x2, dest_y2,
    // source_x1, source_y1, source_x2, source_y2, imageObserver); x=width y=height
    g.setColor(Color.WHITE);
    g.fillRect(0, 0, framew+10, frameh+10);
    g.drawImage(downloadImage(picfilenamescount),x, y, imgwidth, imgheight,this);
    //g.drawImage(firstpic,0, 0, imgwidth, imgheight, this);
    displayText(7);
    }

    If the application is expecting to find an inner class in the jar - then yes, it must be there.
    Put it in there and see what happens - it is probably needed there.

  • Problems with inner classes

    I ran into the following problems when I tried to read into an inner class:
    This is my .jdo file
    <?xml version="1.0"?>
    <jdo>
    <package name="com.globalrefund.jdo.mna">
    <class name="Parameter$Syspar" objectid-class="SysparId">
    <extension vendor-name="kodo" key="table" value="syspar"/>
    <extension vendor-name="kodo" key="lock-column" value="none"/>
    <extension vendor-name="kodo" key="class-column" value="none"/>
    <field name="landescode" primary-key="true">
    <extension vendor-name="kodo" key="data-column"
    value="landescode"/>
    </field>
    <field name="waehrungscode">
    <extension vendor-name="kodo" key="data-column"
    value="waehrungscode"/>
    </field>
    </class>
    </package>
    </jdo>
    1.) appidtool does not work for this inner class, I get this stack trace
    C:\users\Bernhard\jbProject\refundManual>appidtool
    src\com\globalrefund\jdo\mna\Parameter$Syspar.jdo
    Generating an application id for type "class
    com.globalrefund.jdo.mna.Parameter$Syspar"...
    Exception in thread "main" java.lang.NullPointerException
    at com.solarmetric.kodo.enhance.ApplicationIdTool.getFile(Unknown
    Source)
    at
    com.solarmetric.kodo.enhance.ApplicationIdTool.writeApplicationId(Unknown
    Source)
    at
    com.solarmetric.kodo.enhance.ApplicationIdTool.writeApplicationId(Unknown
    Source)
    at com.solarmetric.kodo.enhance.ApplicationIdTool.main(Unknown
    Source)
    2.) I tried to use a hand coded inner class as ID class, but id did not work
    (is this not possible ?)
    Exception in thread "main" java.lang.NoSuchMethodError:
    com.globalrefund.jdo.mna.Parameter$SysparId: method <init>()V not found
    at
    com.globalrefund.jdo.mna.Parameter$Syspar.jdoNewObjectIdInstance(Parameter.j
    ava)
    at
    javax.jdo.spi.JDOImplHelper.newObjectIdInstance(JDOImplHelper.java:166)
    at com.solarmetric.kodo.util.ObjectIds.fromPKValues(Unknown Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.createFromResultSet(
    Unknown Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager$2.getResultObject(Un
    known Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.instantiateRow(Unknown
    Source)
    at com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.get(Unknown
    Source)
    at java.util.AbstractList$Itr.next(AbstractList.java:416)
    at com.solarmetric.kodo.runtime.ResultListIterator.next(Unknown
    Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.ResultListFactory.createResultList(Un
    known Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(Unknown
    Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.executeQuery(Unknown
    Source)
    at com.solarmetric.kodo.query.QueryImpl.executeWithMap(Unknown
    Source)
    at com.solarmetric.kodo.query.QueryImpl.execute(Unknown Source)
    at
    com.solarmetric.kodo.query.QueryImpl$SynchronizedQuery.execute(Unknown
    Source)
    at com.globalrefund.jdo.mna.Parameter.<init>(Parameter.java:71)
    3.) It worked after I moved the ID class into a separate class
    Regards,
    Bernhard

    1.) appidtool does not work for this inner class, I get this stack traceThis is a bug. It will be corrected in the final release of 2.3, due out
    Real Soon Now. Thanks for catching this!
    2.) I tried to use a hand coded inner class as ID class, but id did not work
    (is this not possible ?)
    Exception in thread "main" java.lang.NoSuchMethodError:
    com.globalrefund.jdo.mna.Parameter$SysparId: method <init>()V not foundThis exception is saying that your application ID class does not have a
    no-args constructor. Make sure the id class is a static inner class;
    otherwise Java transparently adds a parent object parameter to each
    constructor, and so the application id class will violoate the JDO constraint
    of having a no-args constructor.

  • Strange behaviour of JBuilder Plug-In with Inner class

    Hi, I'm using the Kodo 2.5.2 Plug-In with JBuilder 8. I have an inner
    persistent class. It seems that it is necessary to have a zero length file
    named EnclosingClass$InnerClass.java for the build process to work, since
    if I delete this file and run the application it throws an exception
    saying that the Inner class has not an specified field which it really
    has. I don't know if this is a bug of the Kodo implementation or of the
    JBuilder Plug-In.
    Thanks for any help.
    Jaime.

    This is one of the limitations of the JBuilder plugin. Hopefully it
    will be resolved in the next iteration of our plugins for 3.x.
    Jaime De La Jara F. wrote:
    Hi, I'm using the Kodo 2.5.2 Plug-In with JBuilder 8. I have an inner
    persistent class. It seems that it is necessary to have a zero length file
    named EnclosingClass$InnerClass.java for the build process to work, since
    if I delete this file and run the application it throws an exception
    saying that the Inner class has not an specified field which it really
    has. I don't know if this is a bug of the Kodo implementation or of the
    JBuilder Plug-In.
    Thanks for any help.
    Jaime.
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • How to make an object of inner class and use it ?

    Hi tecs,
    In my JSF application i have a need to make an inner member class in one of my bean class.
    How can i make the object of this class?(what should be the entry in faces-config)
    And there are text box and check box (in the JSP) associated with the elements of this inner class. What should be the coding in JSP so that elements in the JSP can be linked with the corresponding members of the inner class ?
    Plz help.
    Thnx in advance.

    Hi
    I am havin 10 text boxes in my application.
    But out of 10 , 3 will be always together(existence of one is not possible without the other two.)
    Now i want to create a vector of objects ( here object will consist of the value corresponding to these three boxes),there can be many elements in this vector.
    So i m thinking to make an inner class which have three String variables corresponding to these text boxes that exists together.
    What can b done ?

  • Adding inner class object

    Hello to all
    I have one doubt regarding eventhandling. Consider i am having one class named outer which extends applet and with in outer class i am having one class inner which extends panel.
    Now when i try to add the inner class object in action performed of outer
    class it doesnt get added. How to overcome this.
    Eventhough sometimes it gets added it shouldnot appear for the first time. After resizing the window only it gets displayed.
    How to over come this.
    This is my coding
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Test extends JApplet implements ActionListener{
         JButton b1;
         Container c;
         public void init()
              c=getContentPane();
              b1=new JButton("First");
              c.add(b1,BorderLayout.NORTH);
              b1.addActionListener(this);
         public void actionPerformed(ActionEvent ae)
              System.out.println("Working");
              c.add(new panel());
         class panel extends JPanel
              int a=5;
              JLabel l=new JLabel("ADSF");
              public panel()
                   add(new JButton("ASDFASDFs"));
                   add(l);
              /*public void paint(Graphics g)
                   g.drawString("ASDFASDF123123123123",20,20);
    }

    You could try being more specific when you add ie
    c.add(new panel(), BorderLayout.CENTER);

  • JDeveloper 10.1.2.0.0 - Inner class cannot be found

    Hi!<br>
    <br>
    I use Apache MyFaces 1.1.1 (Nightly Build 20051130) to create a Web app and imported all necessary libraries. I want to write a custom ViewHandler at the moment and experience a strange problem. I want to use a public inner class of javax.faces.application.StateManager, named SerializedView, but this class cannot be found when I try to import it with the following statement:<br>
    import javax.faces.application.StateManager.SerializedView;<br>
    JDeveloper just says: <br>
    Imported class 'javax.faces.application.StateManager.SerializedView' not found<br>
    I already successfully use many other javax.faces classes, like StateManager...<br>
    Any help would highly be appreciated, since this is a real blocker for me.<br>
    <br>
    Regards,
    Matthias

    Hi again!<br>
    <br>
    The problem is solved for the most part now. Compilation works fine, although the Java editor says the class SerializedView cannot be found.<br>
    <br>
    So the Java editor's behavior is still strange...<br>
    <br>
    Regards,<br>
    Matthias

  • Event handling and inner classes

    Hi everyone,
    When assigning an actionlistener object to a swing component, is making the encapsulating component implement actionlistener better performance-wise than using inner classes? I ask this because my application is pretty slow to start-up, and I'm using lots of inner classes.
    I don't want to go ahead and change the event-handling unless I'm sure it will do any good, because the time restriction is too tight for wasting. Does using addActionListener(this) just pass a reference to itself or is an object generated for each call?
    Thanks in advance,
    Richard

    Passing this only passes a reference. But you won't get a big improvement over inner classes. (If you use one listener object instance and pass that instance to the event sources. Do you?)
    Kurta

  • Error with inner Classes

    I've a Swing app in wich I've the following code :
    final ComboBoxEditor editor = comboBox.getEditor();
    editor.getEditorComponent().addKeyListener(new java.awt.event.KeyAdapter() {
    public void keyReleased(KeyEvent e) {
    combo_keyReleased(e,editor);
    Runned in a normal way it works, runned via Webstart 1.4.2 it gives me :
    java.lang.ClassFormatError: it/axioma/basic/application/templates/ClWidgetCombo$2 (Illegal Variable name " val$editor")
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(Unknown Source)
         at java.security.SecureClassLoader.defineClass(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader.defineClass(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader.access$100(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader$1.run(Unknown Source)
    etc...
    Could someone explain me why ?
    Is there any workaround ?
    TIA
    Tullio

    There seems to be a problem using final variables with anonymous inner classes under a different classloader, see http://forum.java.sun.com/thread.jsp?forum=38&thread=372291

  • Why have inner classes

    Well I can understand the purpose of inner classes in multithreaded applications or where you need a continous monitoring, but I have always been wondering why use an inner application in a normal application. Any ideas?

    I guess you mean "inner class in a normal applications" in the last line of your question? If not, don't mention reading this reply since it doesn't answer your question in the latter case.
    Otherwise, the most common use for inner classes according to me is event handling and out of pure lazyness. Good programmers should be lazy you know.
    Let me give an example:
    public class Test() extends Applet{
    <some code here>
    private class Handler extends MouseAdapter(){
    public void mouseEntered(MouseEvent evt){
    <some event handling>
    In the example above we have an applet in which we want to do some MouseEvent handling.
    You could implement the mouselistener in your applet or you could create an inner class that extends MouseAdapter.
    When you implement the MouseListener interface, you have to define all methods from this interface in your applet to prevent it from being abstract.
    When you use an innerclass you only have to provide the method which you want to override, all the other are already implemented by extends the adapter.
    Another advantage of innerclasses is that you have access to all classvariables of the class in which you defined your inner class.
    I hope this can be a little help for you.

Maybe you are looking for