:?: :?: 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.

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);
    }
  }
}

:?:

Recommended Answers

All 3 Replies

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.