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.
This code has forced NetBeans IDE 200512072015, Java 1.6 rc-b62 throw an unexpected exception. package net.phpvietnam.java.swing; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.ArrayList; import javax.swing.BorderFactory; import javax.swing.border.Border; /** * * @author Admin */ // This class represents a "canvas" that can display colored shapes public class ShapeCanvas extends JPanel implements ActionListener { public enum shape { Rectangle, Circle, Eclipse, Polygon } Color currentLineColor = Color.red; // default color; when a shape is created, this is its color Color currentFillColor = Color.blue; // default color; when a shape is created, this is its color /** Creates a new instance of ShapeCanvas */ // Constructor: set background color of the drawing area to white /* ShapeCanvas() { setBackground(Color.red); } */ public void paintComponent(Graphics g) { super.paintComponent(g); // Call the paintComponent method from // the superclass, JPanel. This simply // fills the entire component with the // component's background color. int width = getSize().width; // Get this component's width. int height = getSize().height; // Get this component's height. } public void actionPerformed(ActionEvent event) { // Called to respond to action events. The 4 shape-adding // buttons have been set up to send action events to this canvas. // Respond by adding the appropriate shape to the canvas. // This method is divided into 2 parts // 1: Determine which shape should be drawn: get the order from button event // 2: Get the order from JComboBox. If they exist, get the color and paint them with the shape. // Check the color first because if I check the button first, I will want to draw the Shapes // before I have any info on the colors ordered. // I will use a eventSource object to store information on the source that generates the events // Please be advised that I have set the ActionCommand first. He he.pcdinh Object eventSource = event.getSource(); System.out.println("Source: "+eventSource); if (eventSource instanceof JButton) { System.out.println("Source: JButton"); } String command = event.getActionCommand(); System.out.println("Command: "+command); if (command.equals("Rectangle")) { System.out.println("Command: "+command); } else if (command.equals("Circle")) { } else if (command.equals("Eclipse")) { } else if (command.equals("PolygonShape")) { } } private void drawShapes(enum shape) { // Originally, I use private void drawShapes(String shape) but // after that I decided to try out enum feature. An exception has been thrown. switch (shape) { case "Rectangle": break; case "Eclipse": break; default: break; } } } Log file is attached below
Created attachment 27678 [details] Netbeans error log
It should be a warning: modifier enum not allowed here instead of a exception
Tomasi, can you take a look at it?
Hi, I tried to reproduce this bug in Netbeans 5.5 and it is still there. java.lang.RuntimeException: Unexpected type of ASTree: 272 at org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.getElementProxy(MetadataElement.java:688) at org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.createElement(MetadataElement.java:554) at org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.initOrCreate(MetadataElement.java:1312) at org.netbeans.modules.javacore.jmiimpl.javamodel.ParameterImpl.initChildren(ParameterImpl.java:347) at org.netbeans.modules.javacore.jmiimpl.javamodel.ParameterImpl.getTypeName(ParameterImpl.java:154) at org.netbeans.jmi.javamodel.Parameter$Impl.getTypeName(Unknown Source) at org.netbeans.modules.java.navigation.jmi.JUtils.getParameterType(JUtils.java:406) at org.netbeans.modules.java.navigation.jmi.JUtils.extractParameterName(JUtils.java:390) at org.netbeans.modules.java.navigation.jmi.JUtils.extractMethodName(JUtils.java:305) at org.netbeans.modules.java.navigation.jmi.JUtils.extractName(JUtils.java:247) at org.netbeans.modules.java.navigation.ClassMemberModel.buildWString(ClassMemberModel.java:397) at org.netbeans.modules.java.navigation.ClassMemberModel.buildMembersForPainting(ClassMemberModel.java:358) at org.netbeans.modules.java.navigation.ClassMemberModel.loadContents(ClassMemberModel.java:331) at org.netbeans.modules.java.navigation.spi.ListModelSupport$Loader.run(ListModelSupport.java:960) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:493) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:926) This exception has been thrown on and on when the code line private void drawShapes(enum shape) { } was not fixed.
Is this going to be fixed in 5.5? If not please change milestone to proper value.
Javacore module was replaced by Retouche infrastructure. This bug is not valid in trunk any more.
Reorganization of java component