This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
looking at the java swing tutorial application -- IconDemo in the latest tutorial dnloads. IconDemoApp.java has a field -- no indication that the anonymous class or methods inside exist -- how are we to discover them ??? just read code??? neither process or doInBackground methods show up in navigator. ------ /** * SwingWorker class that loads the images a background thread and calls publish * when a new one is ready to be displayed. * * We use Void as the first SwingWroker param as we do not need to return * anything from doInBackground(). */ private SwingWorker<Void, ThumbnailAction> loadimages = new SwingWorker<Void, ThumbnailAction>() { /** * Creates full size and thumbnail versions of the target image files. */ @Override protected Void doInBackground() throws Exception { for (int i = 0; i < imageCaptions.length; i++) { ImageIcon icon; icon = createImageIcon(imagedir + imageFileNames[i], imageCaptions[i]); ThumbnailAction thumbAction; if(icon != null){ ImageIcon thumbnailIcon = new ImageIcon(getScaledImage(icon.getImage(), 32, 32)); thumbAction = new ThumbnailAction(icon, thumbnailIcon, imageCaptions[i]); }else{ // the image failed to load for some reason // so load a placeholder instead thumbAction = new ThumbnailAction(placeholderIcon, placeholderIcon, imageCaptions[i]); } publish(thumbAction); } // unfortunately we must return something, and only null is valid to // return when the return type is void. return null; } /** * Process all loaded images. */ @Override protected void process(List<ThumbnailAction> chunks) { for (ThumbnailAction thumbAction : chunks) { JButton thumbButton = new JButton(thumbAction); // add the new button BEFORE the last glue // this centers the buttons in the toolbar buttonBar.add(thumbButton, buttonBar.getComponentCount() - 1); } } };
Its' quite obvious that the anonymous class is not shown as a member of class, as it's enclosing element is not the class but the method. In your case it's initializer as it's a field initialization. The only reasonable way how to solve it is to add nesting level under methods and probably under fields (not to use initializers) where these local and anonymous classes will be shown.