The Name Game program - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

The Name Game program

raziel713raziel713 Posts: 1Member
I am having issues generating the results I need when I enter a name to be converted into the Name Game; when a user click the Generate Button it is to display the results. I commented out the section that is giving me the issue. Any suggestions?

* To change this template, choose Tools | Templates
* and open the template in the editor.
package thegame;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

* @author SecretofGod
public class TheGame extends JFrame{

private JLabel label;
private JTextField usertext;
private JButton button;
private JButton clear;
String name, name2;

public TheGame () {
setLayout(new FlowLayout());

label = new JLabel("Enter Your Name For Shirley");

usertext = new JTextField(12);

button = new JButton("Generate Lyric");

clear = new JButton("Clear Text");

buttonButtonHandler buttonListener = new buttonButtonHandler();

clearButtonHandler clearListener = new clearButtonHandler();

private class buttonButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e){

/*for (int x = 0; x < list.size(); x++)
name = list.get(x);
name2 = "";
for (int y = 1; y < name.length(); y++)
name2 += name.charAt(y);
if (!name2.equals("uck") && !name2.equals("hit") && !name2.equals("itch"))
JOptionPane.showMessageDialog(null, name+"!
"+name+", "+name+" bo
B"+name2+" Banana fanna fo F"+name2+"
Fee fy mo M"+name2+",
JOptionPane.showMessageDialog(null, "Error!
The name "+name+" cannot be used"+" for some vague reason.");


private class clearButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e){

* @param args the command line arguments
public static void main(String[] args) {
// TODO code application logic here
TheGame gui = new TheGame();
gui.setTitle("I wanna play a Name Game");

Sign In or Register to comment.