944,033 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1641
  • Java RSS
Feb 20th, 2006
0

Error while compiling but not in the code itself????

Expand Post »
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)
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. import java.util.ArrayList;
  5. public class Hangman extends JFrame {
  6.  
  7. JLabel wordLabel;
  8. JButton letterButtons[] = new JButton[26];
  9. boolean guessed[] = new boolean[26];
  10. GallowsPanel gallows;
  11. JButton newGameButton;
  12. JButton quitButton;
  13. String theWord;
  14.  
  15. boolean won; // true if the user won
  16. boolean lost; // true if the user lost
  17. final static int BAD_GUESS_LIMIT = 7;
  18. int badGuessCount;
  19. Font largeFont = new Font("Monospaced", Font.BOLD, 30);
  20. Font smallFont = new Font("Serif", Font.PLAIN, 18);
  21. Color backColor = Color.lightGray;
  22. Words dictionary;
  23. Color plainColor = backColor;
  24. Color correctColor = Color.green;
  25. Color wrongColor = Color.red;
  26.  
  27. public Hangman() {
  28.  
  29. Container contents = getContentPane();
  30.  
  31. gallows = new GallowsPanel();
  32. gallows.setBackground(backColor);
  33. contents.add(gallows, BorderLayout.CENTER);
  34. JPanel rightPanel = new JPanel(new BorderLayout());
  35.  
  36. wordLabel = new JLabel("", JLabel.CENTER);
  37. wordLabel.setFont(largeFont);
  38. wordLabel.setBackground(backColor);
  39. wordLabel.setForeground(Color.black);
  40. rightPanel.add(wordLabel, BorderLayout.NORTH);
  41.  
  42. JPanel buttonPanel = new JPanel(new GridLayout(9, 4));
  43. for (int i = 0; i < 26; i++) {
  44. letterButtons[i] = new LetterButton(i);
  45. letterButtons[i].setFont(new Font("SansSerif", Font.PLAIN, 14));
  46. buttonPanel.add(letterButtons[i]);
  47. }
  48. for (int i = 0; i < 6; i++)
  49. buttonPanel.add(new JLabel(""));
  50. quitButton = new JButton("quit");
  51. quitButton.addActionListener(
  52. new ActionListener() {
  53. public void actionPerformed(ActionEvent e) {
  54. System.exit(1);
  55. }
  56. }
  57. );
  58. buttonPanel.add(quitButton);
  59. newGameButton = new JButton("new game");
  60. newGameButton.addActionListener(
  61. new ActionListener() {
  62. public void actionPerformed(ActionEvent e) {
  63. initialize();
  64. }
  65. }
  66. );
  67. buttonPanel.add(newGameButton);
  68.  
  69. JPanel wrapper = new JPanel();
  70. wrapper.add(buttonPanel);
  71. rightPanel.add(wrapper, BorderLayout.SOUTH);
  72.  
  73. contents.add(rightPanel, BorderLayout.EAST);
  74.  
  75. dictionary = new Words();
  76. initialize();
  77. setDefaultCloseOperation(EXIT_ON_CLOSE);
  78. setTitle("Hangman Demo Game 2");
  79. pack();
  80. setVisible(true);
  81. }
  82.  
  83. void setWordLabelText() {
  84. String theText = new String();
  85. for (int i = 0; i < theWord.length(); i++) {
  86. char ch = theWord.charAt(i);
  87. if (guessed[ch - 'A'])
  88. theText = theText + ch + " ";
  89. else
  90. theText = theText + "_ ";
  91. } // end for loop
  92. wordLabel.setText(theText);
  93. }
  94.  
  95.  
  96. void initialize() {
  97. theWord = dictionary.getWord();
  98. won = false;
  99. lost = false;
  100.  
  101. for (int i = 0; i < 26; i++) {
  102. guessed[i] = false;
  103. letterButtons[i].setEnabled(true);
  104. letterButtons[i].setBackground(plainColor);
  105. }
  106. badGuessCount = 0;
  107. setWordLabelText();
  108.  
  109. repaint();
  110. }
  111.  
  112. boolean allGuessed() {
  113. for (int i = 0; i < theWord.length(); i++) {
  114. char ch = theWord.charAt(i);
  115. if (!guessed[ch - 'A'])
  116. return false;
  117. }
  118. return true;
  119. }
  120.  
  121. public static void main(String args[]) {
  122. Hangman window = new Hangman();
  123. }
  124.  
  125. class GallowsPanel extends JPanel {
  126.  
  127. public GallowsPanel() {
  128. super();
  129. setPreferredSize(new Dimension(400, 410));
  130. }
  131.  
  132. public void paintComponent(Graphics g) {
  133. super.paintComponent(g);
  134.  
  135. // No matter what, draw the gallows (blue)
  136. g.setColor(Color.blue);
  137. g.drawLine(10,10, 10,350);
  138. g.drawLine(10,350, 100,350);
  139. g.drawLine(100,350, 100,375);
  140. g.drawLine(100,375, 125,375);
  141. g.drawLine(125,375, 125,400);
  142. g.drawLine(125,400, 150,400);
  143. g.drawLine(10,10, 150, 10);
  144. g.drawLine(150,10, 150, 30);
  145. g.setColor(Color.black); // back to black for person
  146.  
  147. if (badGuessCount > 0)
  148. g.drawOval(110,30, 80,80);
  149.  
  150. if (badGuessCount > 1)
  151. g.drawLine(150,110, 150,150);
  152.  
  153. if (badGuessCount > 2)
  154. g.drawLine(150,150, 100,200);
  155.  
  156. if (badGuessCount > 3)
  157. g.drawLine(150,150, 200,200);
  158.  
  159. if (badGuessCount > 4)
  160. g.drawLine(150,150, 150,250);
  161.  
  162. if (badGuessCount > 5)
  163. g.drawLine(150,250, 80,320);
  164.  
  165. if (badGuessCount > 6)
  166. g.drawLine(150,250, 220,320);
  167.  
  168. String msg = "YOU WON!";
  169. if (won) {
  170. g.setColor(Color.red);
  171. g.drawArc(120,40, 60,60, 0,-180);
  172. }
  173. if (lost) {
  174. msg = "YOU LOST!";
  175.  
  176. g.setColor(Color.red);
  177. g.setFont(smallFont);
  178. g.drawString("(the word was " + theWord + ")", 40,230);
  179.  
  180. g.setColor(Color.red);
  181. g.drawArc(120,80,60,60, 30,120);
  182. }
  183. if (won || lost) {
  184.  
  185. g.setColor(Color.black);
  186. g.drawOval(110,30, 80,80);
  187.  
  188. g.setColor(Color.red);
  189. g.setFont(largeFont);
  190. g.drawString(msg,20,200);
  191.  
  192. g.setColor(Color.blue);
  193. g.fillOval(130,50,10,10);
  194. g.fillOval(160,50,10,10);
  195.  
  196. g.setColor(Color.black);
  197. g.fillOval(147,65,8,8);
  198. }
  199. }
  200. }
  201.  
  202. private class LetterButton extends JButton implements ActionListener {
  203. private char theLetter;
  204. private int letterIndex;
  205.  
  206. public LetterButton(int letterIndex) {
  207. theLetter = (char) (letterIndex + 'A');
  208. this.letterIndex = letterIndex;
  209. String buttonLabel = theLetter + "";
  210. setText(buttonLabel);
  211. addActionListener(this);
  212. }
  213.  
  214. public void actionPerformed(ActionEvent event) {
  215. guessed[letterIndex] = true;
  216.  
  217. boolean found = false;
  218. for (int i = 0; i < theWord.length(); i++) {
  219. if (theWord.charAt(i) == theLetter) {
  220. found = true;
  221. }// end if statment
  222. }
  223.  
  224. if (found) {
  225.  
  226. setWordLabelText();
  227. letterButtons[letterIndex].setBackground(correctColor);
  228. }
  229. else {
  230.  
  231. badGuessCount++;
  232. letterButtons[letterIndex].setBackground(wrongColor);
  233. } // end if statment
  234.  
  235. letterButtons[letterIndex].setEnabled(false);
  236.  
  237. if (allGuessed()) {
  238. won = true;
  239. }
  240. else if (badGuessCount >= BAD_GUESS_LIMIT) {
  241. lost = true;
  242. } // end if statment
  243.  
  244.  
  245. if (won || lost) {
  246. for (int i = 0; i < 26; i++)
  247. letterButtons[i].setEnabled(false);
  248. } // end if statment
  249.  
  250. gallows.repaint();
  251. }
  252.  
  253. }
  254.  
  255. public class Words {
  256.  
  257. private ArrayList wordList;
  258.  
  259. public Words() {
  260. wordList = new ArrayList();
  261. wordList.add("COMPUTER");
  262. wordList.add("COMPILER");
  263. wordList.add("INSTRUCTOR");
  264. wordList.add("JAVA");
  265. wordList.add("INTERACTIVE");
  266. wordList.add("PROGRAMING");
  267. wordList.add("POPULATION");
  268. wordList.add("DELIGATION");
  269. wordList.add("BACKDRAFT");
  270. wordList.add("GRAPHICS");
  271. wordList.add("CHILDREN");
  272. wordList.add("CHURCH");
  273. wordList.add("HOLYSPIRIT");
  274. wordList.add("PRINTER");
  275. wordList.add("AFRICA");
  276. wordList.add("CHINA");
  277. wordList.add("FUNGI");
  278. wordList.add("DOCTOR");
  279. wordList.add("NETWORKCARD");
  280. wordList.add("TCIP");
  281. }
  282.  
  283. public String getWord() {
  284. int size = wordList.size();
  285. int randomIndex = (int) (Math.random() * size);
  286. return (String) wordList.get(randomIndex);
  287. }
  288. }
  289. }

Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wejavalearn is offline Offline
3 posts
since Feb 2006
Feb 21st, 2006
0

Re: Error while compiling but not in the code itself????

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wejavalearn is offline Offline
3 posts
since Feb 2006
Feb 21st, 2006
0

Re: Error while compiling but not in the code itself????

This might be the answer you're looking for.

http://info.borland.com/techpubs/jbu.../bajb/bmj.html
Reputation Points: 11
Solved Threads: 8
Posting Whiz in Training
hooknc is offline Offline
216 posts
since Aug 2005
Feb 21st, 2006
0

Re: Error while compiling but not in the code itself????

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wejavalearn is offline Offline
3 posts
since Feb 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Array issue
Next Thread in Java Forum Timeline: Please Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC