Community
Participate
Working Groups
When copying a class, and pasting to a new class, internal references should be renamed to the new name. For instance, if I copy the following class and paste it in the same package, it will create a new class called CopyOfTestSwt.java. However, I will have a compiler error since the main() method references the TestSwt() constructor, which is private. I believe the constructor call in the main() method should be changed on the copy/paste to match the new class name (especially if the constructor is in the main() method, but arguably anywhere in the class). Here's the example: import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.events.*; //------------------------------------------------------------------- // //------------------------------------------------------------------- public class TestSwt { private Display display; private Shell shell; //------------------------------------------------------------------- // //------------------------------------------------------------------- static public void main(String[] args) { new TestSwt().runMain(args); } //------------------------------------------------------------------- // //------------------------------------------------------------------- private void runMain(String[] args) { display = new Display(); shell = new Shell(display); shell.setText(getClass().getName()); shell.setLayout(new FillLayout()); Button button = new Button(shell, 0); button.setText("H&ello World"); shell.setSize(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } }
*** This bug has been marked as a duplicate of 5219 ***