Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 20th, 2005, 8:39 PM   #1
OUfanAP12
Newbie
 
Join Date: Mar 2005
Posts: 1
Rep Power: 0 OUfanAP12 is on a distinguished road
Problem Compiling this program

Im in a Java Programming class and im having a problem with my code. Im assuming its all related to one problem, but i still cant figure it out

Code is attached

Errors:

C:\Documents and Settings\Owner\My Documents\DVD.java:42: cannot resolve symbol
symbol : method setDisplayedMnemonicIndex (int)
location: class javax.swing.JMenu
mnuFile.setDisplayedMnemonicIndex(0);
^
C:\Documents and Settings\Owner\My Documents\DVD.java:47: cannot resolve symbol
symbol : method setDisplayedMnemonicIndex (int)
location: class javax.swing.JMenuItem
mnuFileExit.setDisplayedMnemonicIndex(1);
^
C:\Documents and Settings\Owner\My Documents\DVD.java:55: cannot resolve symbol
symbol : method setDisplayedMnemonicIndex (int)
location: class javax.swing.JMenu
mnuEdit.setDisplayedMnemonicIndex(0);
^
C:\Documents and Settings\Owner\My Documents\DVD.java:60: cannot resolve symbol
symbol : method setDisplayedMnemonicIndex (int)
location: class javax.swing.JMenuItem
mnuEditInsert.setDisplayedMnemonicIndex(0);
^
C:\Documents and Settings\Owner\My Documents\DVD.java:67: cannot resolve symbol
symbol : method setDisplayedMnemonicIndex (int)
location: class javax.swing.JMenu
mnuEditSearch.setDisplayedMnemonicIndex(3);
^
C:\Documents and Settings\Owner\My Documents\DVD.java:72: cannot resolve symbol
symbol : method setDisplayedMnemonicIndex (int)
location: class javax.swing.JMenuItem
mnuEditSearchByTitle.setDisplayedMnemonicIndex(3);
^
C:\Documents and Settings\Owner\My Documents\DVD.java:79: cannot resolve symbol
symbol : method setDisplayedMnemonicIndex (int)
location: class javax.swing.JMenuItem
mnuEditSearchByStudio.setDisplayedMnemonicIndex(3);
^
C:\Documents and Settings\Owner\My Documents\DVD.java:86: cannot resolve symbol
symbol : method setDisplayedMnemonicIndex (int)
location: class javax.swing.JMenuItem
mnuEditSearchByYear.setDisplayedMnemonicIndex(3);
^
C:\Documents and Settings\Owner\My Documents\DVD.java:325: cannot resolve symbol
symbol : method setDefaultLookAndFeelDecorated (boolean)
location: class javax.swing.JFrame
JFrame.setDefaultLookAndFeelDecorated(true);
^
9 errors

Tool completed with exit code 1
Attached Files
File Type: txt DVD1.txt (9.8 KB, 36 views)
OUfanAP12 is offline   Reply With Quote
Old Mar 20th, 2005, 9:02 PM   #2
You Like Java?
Newbie
 
You Like Java?'s Avatar
 
Join Date: Mar 2005
Location: aboho.com (sn:eyvind)
Posts: 20
Rep Power: 0 You Like Java? is on a distinguished road
Send a message via AIM to You Like Java? Send a message via MSN to You Like Java? Send a message via Yahoo to You Like Java?
Those "cannot resolve symbol," with the symbol being a method method, mean
      • You misspelled the method name
      • You gave invalid parameters, for example:
        • Too many or too few parameters
        • Wrong type of parameters
      • You did not import the package containing the class cntaining the method
      • The object you are calling the method from does not have the method at all
Hope that helps you, I haven't gone over your code, but I glanced at it, it would be better if you found the erros and fixed them yourself, so you learn. If you have more trouble, post.
__________________
If you need help with Java, you can go to javaforum.tk and get answers quickly.

Programmer YouLikeJava = new JavaProgrammer("Eyvind");
YouLikeJava.printInfo();
YouLikeJava.setWeb("You Like Java?");
You Like Java? is offline   Reply With Quote
Old Nov 7th, 2005, 5:52 PM   #3
jamesdman
Newbie
 
Join Date: Apr 2005
Location: NC,USA
Posts: 17
Rep Power: 0 jamesdman is on a distinguished road
/*
Chapter 7: Classics on DVD
Programmer: J.Starks
Date: November 12,2004
Filename: DVD.java
Purpose: This program creates a swing device for sorting a DVD collection
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;

public class DVD extends JFrame implements ActionListener
{
//Construct components
JLabel sortPrompt = new JLabel("Sort By");
JComboBox fieldCombo = new JComboBox();
JTextPane textPane = new JTextPane();

//initialize data in arrays
String title[] = {"Casablanca" , "Citizen Kane", "Singin' in the Rain","The Wizard of Oz"};
String studio[] = {"Warner Brothers", "RKO Pictures","MGM","MGM"};
String year[] = {"1942", "1941", "1952", "1939"};

//construct instance of DVD
public DVD()
{
super("Classics on DVD");
}

//create the menu system
public JMenuBar createMenuBar()
{
//create an instance of the menu
JMenuBar mnuBar = new JMenuBar();
setJMenuBar(mnuBar);

//construct and populate the File menu
JMenu mnuFile = new JMenu("File", true);
mnuFile.setMnemonic(KeyEvent.VK_F);
mnuFile.setDisplayedMnemonicIndex(0);
mnuBar.add(mnuFile);

JMenuItem mnuFileExit = new JMenuItem("Exit");
mnuFileExit.setMnemonic(KeyEvent.VK_F);
mnuFileExit.setDisplayedMnemonicIndex(1);
mnuFile.add(mnuFileExit);
mnuFileExit.setActionCommand("Exit");
mnuFileExit.addActionListener(this);

//construct and populate the Edit menu
JMenu mnuEdit = new JMenu("Edit",true);
mnuEdit.setMnemonic(KeyEvent.VK_E);
mnuEdit.setDisplayedMnemonicIndex(0);
mnuBar.add(mnuEdit);

JMenuItem mnuEditInsert = new JMenuItem("Insert New DVD");
mnuEditInsert.setMnemonic(KeyEvent.VK_I);
mnuEditInsert.setDisplayedMnemonicIndex(0);
mnuEdit.add(mnuEditInsert);
mnuEditInsert.setActionCommand("Insert");
mnuEditInsert.addActionListener(this);

JMenu mnuEditSearch = new JMenu("Search");
mnuEditSearch.setMnemonic(KeyEvent.VK_R);
mnuEditSearch.setDisplayedMnemonicIndex(3);
mnuEdit.add(mnuEditSearch);

JMenuItem mnuEditSearchByTitle = new JMenuItem("by Title");
mnuEditSearchByTitle.setMnemonic(KeyEvent.VK_T);
mnuEditSearchByTitle.setDisplayedMnemonicIndex(3);
mnuEditSearch.add(mnuEditSearchByTitle);
mnuEditSearchByTitle.setActionCommand("title");
mnuEditSearchByTitle.addActionListener(this);

JMenuItem mnuEditSearchByStudio = new JMenuItem("by Title");
mnuEditSearchByStudio.setMnemonic(KeyEvent.VK_T);
mnuEditSearchByStudio.setDisplayedMnemonicIndex(3);
mnuEditSearch.add(mnuEditSearchByStudio);
mnuEditSearchByStudio.setActionCommand("Studio");
mnuEditSearchByStudio.addActionListener(this);

JMenuItem mnuEditSearchByYear = new JMenuItem("by Title");
mnuEditSearchByYear.setMnemonic(KeyEvent.VK_T);
mnuEditSearchByYear.setDisplayedMnemonicIndex(3);
mnuEditSearch.add(mnuEditSearchByYear);
mnuEditSearchByYear.setActionCommand("Year");
mnuEditSearchByYear.addActionListener(this);

return mnuBar;
}

//Create the content pane
public Container createContentPane()
{
//populate the JComboBox
fieldCombo.addItem("Title");
fieldCombo.addItem("Studio");
fieldCombo.addItem("Year");
fieldCombo.addActionListener(this);
fieldCombo.setToolTipText("Click the drop=down arrow to display sort fields.");

//construct and populate the north panel
JPanel northPanel = new JPanel();
northPanel.setLayout(new FlowLayout());
northPanel.add(sortPrompt);
northPanel.add(fieldCombo);

//create the JTextPane and center panel
JPanel centerPanel = new JPanel();
setTabsAndStyles(textPane);
textPane = addTextToTextPane();
JScrollPane scrollPane = new JScrollPane(textPane);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setPreferredSize(new Dimension(500,200));
centerPanel.add(scrollPane);

//create Container and set attributes
Container c = getContentPane();
c.setLayout(new BorderLayout(10,10));
c.add(northPanel, BorderLayout.NORTH);
c.add(centerPanel,BorderLayout.CENTER);

return c;
}

//method to create tab stops and set font styles
protected void setTabsAndStyles(JTextPane textPane)
{
//create tab stops
TabStop[] tabs = new TabStop[2];
tabs[0] = new TabStop(200, TabStop.ALIGN_LEFT,TabStop.LEAD_NONE);
tabs[1] = new TabStop(350, TabStop.ALIGN_LEFT,TabStop.LEAD_NONE);
TabSet tabset = new TabSet(tabs);

//set Tab Style
StyleContext tabStyle = StyleContext.getDefaultStyleContext();
AttributeSet aset =
tabStyle.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.TabSet, tabset);
textPane.setParagraphAttributes(aset, false);

//set Font STyle
Style fontStyle=
StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

Style regular = textPane.addStyle("regular",fontStyle);
StyleConstants.setFontFamily(fontStyle,"SansSerif");

Style s = textPane.addStyle("italic", regular);
StyleConstants.setItalic(s, true);

s = textPane.addStyle("bold",regular);
StyleConstants.setBold(s,true);

s = textPane.addStyle("large",regular);
StyleConstants.setFontSize(s,16);
}

//method to add new text to the JTextPane
public JTextPane addTextToTextPane()
{
Document doc = textPane.getDocument();
try
{
//clear previous text
doc.remove(0, doc.getLength());

//insert title
doc.insertString(0,"TITLE\tSTUDIO\tYEAR\n",textPane.getStyle("large"));

//insert detail
for(int j = 0; j<title.length; j++)
{
doc.insertString(doc.getLength(), title[j]+"\t",
textPane.getStyle("bold"));
doc.insertString(doc.getLength(), studio[j]+"\t",textPane.getStyle("italic"));
doc.insertString(doc.getLength(), year[j]+"\n",textPane.getStyle("regular"));
}
}
catch (BadLocationException ble)
{
System.err.println("Couldn't insert text.");
}
return textPane;
}

//event to process user clicks
public void actionPerformed(ActionEvent e)
{
String arg = e.getActionCommand();

//user clicks the sort by combo box
if(e.getSource()==fieldCombo)
{
switch(fieldCombo.getSelectedIndex())
{
case 0:
sort(title);
break;
case 1:
sort(studio);
break;
case 2:
sort(year);
break;
}
}

//user clicks exit on the file menu
if(arg=="Exit")
System.exit(0);

//user clicks Insert New DVD on the Edit menu
if(arg=="Insert")
{

//enlarge arrays
title = enlargeArray(title);
studio = enlargeArray(studio);
year = enlargeArray(year);


//call sort method
sort(title);
fieldCombo.setSelectedIndex(0);
}

//user clicks Title on the Search submenu
if(arg =="title")
search(arg,title);

//user clicks Studio on Search submenu
if(arg =="search")
search(arg,studio);

//user clicks Year on Search submenu
if(arg =="year")
search(arg,year);
}
//method to enlarge an array by 1
public String[] enlargeArray(String[] currentArray)
{
String[] newArray = new String[currentArray.length + 1];
for(int i = 0; i<currentArray.length; i++)
newArray[i] = currentArray[i];
return newArray;
}

//method to sort arrays
public void sort(String tempArray[])
{
//loop to control number of passes
for(int pass =1;pass < tempArray.length; pass++)
{
for (int element = 0; element < tempArray.length - 1; element++)
if (tempArray[element].compareTo(tempArray[element + 1])>0)
{
swap(title, element, element + 1);
swap(studio, element, element + 1);
swap(year, element, element + 1);
}
}
addTextToTextPane();
}

//method to swap two elements of an array
public void swap(String swapArray[], int first, int second)
{
String hold; //temporary holding area for swap
hold = swapArray[first];
swapArray[first] = swapArray[second];
swapArray[second] = hold;
}

public void search(String searchField, String searchArray[])
{
try
{
Document doc= textPane.getDocument();
doc.remove(0,doc.getLength());

//display column titles
doc.insertString(0, "TITLE\tSTUIOD\tYEAR\n", textPane.getStyle("large"));

//prompt user for search data
String search = JOptionPane.showInputDialog(null, "Please enter the "+ searchField);
boolean found = false;

//search arrays
for (int i = 0; i<title.length; i++)
{
if (search.compareTo(searchArray[i])==0)
{
doc.insertString(doc.getLength(), title[i] + "\t",textPane.getStyle("bold"));
doc.insertString(doc.getLength(), studio[i] + "\t",textPane.getStyle("italic"));
doc.insertString(doc.getLength(), year[i] + "\n",textPane.getStyle("regular"));
found = true;
}
}
if (found == false)
{
JOptionPane.showMessageDialog(null, "Your search produced no results.","No results found",JOptionPane.INFORMATION_MESSAGE);
sort(title);
}
}
catch (BadLocationException ble)
{
System.err.println("Couldn't insert text.");
}
}

//main method executes at run time
public static void main(String args[])
{
JFrame.setDefaultLookAndFeelDecorated(true);
DVD f = new DVD();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setJMenuBar(f.createMenuBar());
f.setContentPane(f.createContentPane());
f.setSize(600,375);
f.setVisible(true);
}
}
Sorry I just took out the errors I got from it and this works.
Perhaps you will find how to add back the features.I never wrote any programs so this is fun for me to play with.I will try harder to get the rest of it back.
jamesdman is offline   Reply With Quote
Old Nov 7th, 2005, 7:06 PM   #4
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
[ CODE ] tags or you may as well not even post.
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Nov 7th, 2005, 8:27 PM   #5
jamesdman
Newbie
 
Join Date: Apr 2005
Location: NC,USA
Posts: 17
Rep Power: 0 jamesdman is on a distinguished road
Sorry.Try setting a variable for line 218-220.Also you might want to correct the typo on line 293,just for looks.
jamesdman is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:57 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC