Hi Guys,
Working on a class at the moment in NetBeans however I have a problem with a section of code;
When built it brings up the following error;Code:public void init() { itemList = new ArrayList(); GUI gui1 = new GUI(); getContentPane().add(gui1, "Center"); }
I've included the full code below;Code:NetBeansProjects\ToDoList\src\ToDoList.java:26: cannot find symbol symbol : method add(ToDoList.GUI,java.lang.String) location: class java.awt.Container getContentPane().add(gui1, "Center"); Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
Suggestions would be appreciated!Code:/* Small application implementing a To-Do List. * Uses a mobile phone-like interface. */ import java.awt.Container; import java.util.ArrayList; import java.util.Collections; import javax.swing.JApplet; public class ToDoList extends JApplet { // first we create an instance of this class class GUI{} public ToDoList() { // create a graphical user interface, // passing it a reference to this tdl program object // initialisation goes here: } public void init() { itemList = new ArrayList(); GUI gui1 = new GUI(); getContentPane().add(gui1, "Center"); } public ArrayList getList() { // dummy return value of an empty list, // just to get the program to compile initially return itemList; } public ArrayList addToList(String s) { itemList.add(s); return itemList; } public ArrayList getSortedList() { // dummy return value of an empty list, // just to get the program to compile initially Collections.sort(itemList); return itemList; } public ArrayList performReverse() { // dummy return value of an empty list, // just to get the program to compile initially Collections.reverse(itemList); return itemList; } public ArrayList performDeletion(int i) { // dummy return value of an empty list, // just to get the program to compile initially if(i < itemList.size()) itemList.remove(i); return itemList; } public ArrayList performSwap(int i) { // dummy return value of an empty list, // just to get the program to compile initially if(i < itemList.size() && itemList.size() >=2) { String s = (String)itemList.remove(i); if(i < itemList.size()) itemList.add(i + 1, s); else itemList.add(itemList.size() - 1, s); } return itemList; } private GUI gui; private ArrayList itemList; }


Reply With Quote


Bookmarks