| | |
Error while compiling but not in the code itself????
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Feb 2006
Posts: 3
Reputation:
Solved Threads: 0
I dont understand what jbuilder is trying to tell me .. by all right my code seims fine I spent 4 days working it up (yes I am a beginer) I know there are most likly better ways to do what I am doing. The point is compiled the code tells me that it cant find bootstrap loader and several others. This is the 5th program I have done on jbuilder (most extensive and I think I followed the information in book and Online correctly) I have gone over it twice. please any assistance would help me at this point.
Java Syntax (Toggle Plain Text)
import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; public class Hangman extends JFrame { JLabel wordLabel; JButton letterButtons[] = new JButton[26]; boolean guessed[] = new boolean[26]; GallowsPanel gallows; JButton newGameButton; JButton quitButton; String theWord; boolean won; // true if the user won boolean lost; // true if the user lost final static int BAD_GUESS_LIMIT = 7; int badGuessCount; Font largeFont = new Font("Monospaced", Font.BOLD, 30); Font smallFont = new Font("Serif", Font.PLAIN, 18); Color backColor = Color.lightGray; Words dictionary; Color plainColor = backColor; Color correctColor = Color.green; Color wrongColor = Color.red; public Hangman() { Container contents = getContentPane(); gallows = new GallowsPanel(); gallows.setBackground(backColor); contents.add(gallows, BorderLayout.CENTER); JPanel rightPanel = new JPanel(new BorderLayout()); wordLabel = new JLabel("", JLabel.CENTER); wordLabel.setFont(largeFont); wordLabel.setBackground(backColor); wordLabel.setForeground(Color.black); rightPanel.add(wordLabel, BorderLayout.NORTH); JPanel buttonPanel = new JPanel(new GridLayout(9, 4)); for (int i = 0; i < 26; i++) { letterButtons[i] = new LetterButton(i); letterButtons[i].setFont(new Font("SansSerif", Font.PLAIN, 14)); buttonPanel.add(letterButtons[i]); } for (int i = 0; i < 6; i++) buttonPanel.add(new JLabel("")); quitButton = new JButton("quit"); quitButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(1); } } ); buttonPanel.add(quitButton); newGameButton = new JButton("new game"); newGameButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { initialize(); } } ); buttonPanel.add(newGameButton); JPanel wrapper = new JPanel(); wrapper.add(buttonPanel); rightPanel.add(wrapper, BorderLayout.SOUTH); contents.add(rightPanel, BorderLayout.EAST); dictionary = new Words(); initialize(); setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("Hangman Demo Game 2"); pack(); setVisible(true); } void setWordLabelText() { String theText = new String(); for (int i = 0; i < theWord.length(); i++) { char ch = theWord.charAt(i); if (guessed[ch - 'A']) theText = theText + ch + " "; else theText = theText + "_ "; } // end for loop wordLabel.setText(theText); } void initialize() { theWord = dictionary.getWord(); won = false; lost = false; for (int i = 0; i < 26; i++) { guessed[i] = false; letterButtons[i].setEnabled(true); letterButtons[i].setBackground(plainColor); } badGuessCount = 0; setWordLabelText(); repaint(); } boolean allGuessed() { for (int i = 0; i < theWord.length(); i++) { char ch = theWord.charAt(i); if (!guessed[ch - 'A']) return false; } return true; } public static void main(String args[]) { Hangman window = new Hangman(); } class GallowsPanel extends JPanel { public GallowsPanel() { super(); setPreferredSize(new Dimension(400, 410)); } public void paintComponent(Graphics g) { super.paintComponent(g); // No matter what, draw the gallows (blue) g.setColor(Color.blue); g.drawLine(10,10, 10,350); g.drawLine(10,350, 100,350); g.drawLine(100,350, 100,375); g.drawLine(100,375, 125,375); g.drawLine(125,375, 125,400); g.drawLine(125,400, 150,400); g.drawLine(10,10, 150, 10); g.drawLine(150,10, 150, 30); g.setColor(Color.black); // back to black for person if (badGuessCount > 0) g.drawOval(110,30, 80,80); if (badGuessCount > 1) g.drawLine(150,110, 150,150); if (badGuessCount > 2) g.drawLine(150,150, 100,200); if (badGuessCount > 3) g.drawLine(150,150, 200,200); if (badGuessCount > 4) g.drawLine(150,150, 150,250); if (badGuessCount > 5) g.drawLine(150,250, 80,320); if (badGuessCount > 6) g.drawLine(150,250, 220,320); String msg = "YOU WON!"; if (won) { g.setColor(Color.red); g.drawArc(120,40, 60,60, 0,-180); } if (lost) { msg = "YOU LOST!"; g.setColor(Color.red); g.setFont(smallFont); g.drawString("(the word was " + theWord + ")", 40,230); g.setColor(Color.red); g.drawArc(120,80,60,60, 30,120); } if (won || lost) { g.setColor(Color.black); g.drawOval(110,30, 80,80); g.setColor(Color.red); g.setFont(largeFont); g.drawString(msg,20,200); g.setColor(Color.blue); g.fillOval(130,50,10,10); g.fillOval(160,50,10,10); g.setColor(Color.black); g.fillOval(147,65,8,8); } } } private class LetterButton extends JButton implements ActionListener { private char theLetter; private int letterIndex; public LetterButton(int letterIndex) { theLetter = (char) (letterIndex + 'A'); this.letterIndex = letterIndex; String buttonLabel = theLetter + ""; setText(buttonLabel); addActionListener(this); } public void actionPerformed(ActionEvent event) { guessed[letterIndex] = true; boolean found = false; for (int i = 0; i < theWord.length(); i++) { if (theWord.charAt(i) == theLetter) { found = true; }// end if statment } if (found) { setWordLabelText(); letterButtons[letterIndex].setBackground(correctColor); } else { badGuessCount++; letterButtons[letterIndex].setBackground(wrongColor); } // end if statment letterButtons[letterIndex].setEnabled(false); if (allGuessed()) { won = true; } else if (badGuessCount >= BAD_GUESS_LIMIT) { lost = true; } // end if statment if (won || lost) { for (int i = 0; i < 26; i++) letterButtons[i].setEnabled(false); } // end if statment gallows.repaint(); } } public class Words { private ArrayList wordList; public Words() { wordList = new ArrayList(); wordList.add("COMPUTER"); wordList.add("COMPILER"); wordList.add("INSTRUCTOR"); wordList.add("JAVA"); wordList.add("INTERACTIVE"); wordList.add("PROGRAMING"); wordList.add("POPULATION"); wordList.add("DELIGATION"); wordList.add("BACKDRAFT"); wordList.add("GRAPHICS"); wordList.add("CHILDREN"); wordList.add("CHURCH"); wordList.add("HOLYSPIRIT"); wordList.add("PRINTER"); wordList.add("AFRICA"); wordList.add("CHINA"); wordList.add("FUNGI"); wordList.add("DOCTOR"); wordList.add("NETWORKCARD"); wordList.add("TCIP"); } public String getWord() { int size = wordList.size(); int randomIndex = (int) (Math.random() * size); return (String) wordList.get(randomIndex); } } }
•
•
Join Date: Feb 2006
Posts: 3
Reputation:
Solved Threads: 0
My I ask if I did not give enogh information or if I need to give other information? I am new to trying to get help in this manner. I want to be come a good java programer and would like to know were I am going wrong.
Can someone tell me some other books that I could use something with more information, what is the best series were do i get it? I am not looking for any one to do this for me I want to know were to get the information so I can do it my self. Please. Thanks.
Can someone tell me some other books that I could use something with more information, what is the best series were do i get it? I am not looking for any one to do this for me I want to know were to get the information so I can do it my self. Please. Thanks.
•
•
Join Date: Feb 2006
Posts: 3
Reputation:
Solved Threads: 0
the information that jbuilder is giving me is ..
ClassLoader.findBootstrapClass(String) line: not available [native method]
Launcher$ExtClassLoader(ClassLoader).findBootstrapClass0(String) line: not available
Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available
ResourceBundle.loadBundle(ClassLoader, String, Locale) line: not available
ResourceBundle.getBundleImpl(String, Locale, ClassLoader) line: not available
AccessController.doPrivileged(PrivilegedAction) line: not available [native method]
I do not understand why I am getting these messages while trying to comple ..... could anyone tell me were I can find the problem at
ClassLoader.findBootstrapClass(String) line: not available [native method]
Launcher$ExtClassLoader(ClassLoader).findBootstrapClass0(String) line: not available
Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available
ResourceBundle.loadBundle(ClassLoader, String, Locale) line: not available
ResourceBundle.getBundleImpl(String, Locale, ClassLoader) line: not available
AccessController.doPrivileged(PrivilegedAction) line: not available [native method]
I do not understand why I am getting these messages while trying to comple ..... could anyone tell me were I can find the problem at
![]() |
Similar Threads
- Compiling (Java)
- need help with error message (Java)
- Compiling Programs (C++)
- Error message when compiling in MS Vis (C++)
- Error measage in compiling c++ program (C++)
- error message when compiling program (C++)
- How do you write a code which compiles in c but not in c++? (C++)
Other Threads in the Java Forum
- Previous Thread: Array issue
- Next Thread: Please Help
| Thread Tools | Search this Thread |
Tag cloud for Java
actionlistener android api apple applet application apps arguments array arrays automation balls binary bluetooth card chat class classes clear client code component consumer database draw eclipse ee error event exception fractal free game gameprogramming gis givemetehcodez graphics gui html ide image input integer j2me j2seprojects java javaprojects jni jpanel julia jvm key linux list loop machine map method methods migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie nextline nls notdisplaying number oracle output print problem program programming project recursion recursive scanner screen security server set size sms socket sort spamblocker sql sqlite string sun swing terminal test threads time tree trolltech windows





