PDA

View Full Version : java frame name maker (Help!


jdfskitz
09-01-2009, 11:51 PM
Here is my code .. where the font is red is where is sais errors

package namer;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.Math.*;
import java.lang.String.*;
import java.lang.*;
import javax.swing.JFrame.*;

/* FrameDemo.java requires no other files. */
public class Main {
private static String order;
private static String consanents;
private static String vowels;
private static String a;
private static String b;
private static String c;
private static String d;
private static String e;
private static String f;
private static String g;
private static String h;
private static String i;
private static String j;
private static String k;
private static String l;
private static String m;
private static String n;
private static String o;
private static String p;
private static String q;
private static String r;
private static String s;
private static String t;
private static String u;
private static String v;
private static String w;
private static String x;
private static String y;
private static String z;
private static String one;
private static String two;
private static String three;
private static String four;




private static void createAndShowGUI() {
//Create and set up the window.
a = vowels;vowels = a;
e = vowels;vowels = e;
i = vowels;vowels = i;
o = vowels;vowels = o;
u = vowels;vowels = u;
b = consanents;consanents = b;
c = consanents;consanents = c;
d = consanents;consanents = d;
f = consanents;consanents = f;
g = consanents;consanents = g;
h = consanents;consanents = h;
j = consanents;consanents = j;
k = consanents;consanents = k;
l = consanents;consanents = l;
m = consanents;consanents = m;
n = consanents;consanents = n;
p = consanents;consanents = p;
q = consanents;consanents = q;
r = consanents;consanents = r;
s = consanents;consanents = s;
t = consanents;consanents = t;
v = consanents;consanents = v;
w = consanents;consanents = w;
x = consanents;consanents = x;
y = consanents;consanents = y;
z = consanents;consanents = z;

one = (consanents - 20,vowels - 3);
two = (consanents - 20,vowels - 4);
three = (vowels - 4,consanents - 19);
four = (vowels - 4, consanents -20);

one = order;
order = (one,two,three,four);

JFrame frame = new JFrame("Namer");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel emptyLabel = new JLabel("namer");
emptyLabel.setPreferredSize(new Dimension(400, 200));
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
frame.getContentPane(frame.add(frame.list(consanents)));

//Display the window.
frame.pack();
frame.setVisible(true);
}

public static void main(String[] args) {


//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}


What i am trying to make a name generator..

Can someone show me what to do to fix it>?

im new to java. just started learning a few weeks ago


i just wrote that from scratch.. and i cant find the problem .

can someone help me?

i need it so my bro can get names for characters on his warcraft 3 map

jdfskitz
09-01-2009, 11:57 PM
package namer;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.Math.*;
import java.lang.String.*;
import java.lang.*;
import javax.swing.JFrame.*;

/* FrameDemo.java requires no other files. */
public class Main {
private static String order;
private static String consanents;
private static String vowels;
private static String a;
private static String b;
private static String c;
private static String d;
private static String e;
private static String f;
private static String g;
private static String h;
private static String i;
private static String j;
private static String k;
private static String l;
private static String m;
private static String n;
private static String o;
private static String p;
private static String q;
private static String r;
private static String s;
private static String t;
private static String u;
private static String v;
private static String w;
private static String x;
private static String y;
private static String z;
private static String one;
private static String two;
private static String three;
private static String four;




private static void createAndShowGUI() {
//Create and set up the window.
a = vowels;vowels = a;
e = vowels;vowels = e;
i = vowels;vowels = i;
o = vowels;vowels = o;
u = vowels;vowels = u;
b = consanents;consanents = b;
c = consanents;consanents = c;
d = consanents;consanents = d;
f = consanents;consanents = f;
g = consanents;consanents = g;
h = consanents;consanents = h;
j = consanents;consanents = j;
k = consanents;consanents = k;
l = consanents;consanents = l;
m = consanents;consanents = m;
n = consanents;consanents = n;
p = consanents;consanents = p;
q = consanents;consanents = q;
r = consanents;consanents = r;
s = consanents;consanents = s;
t = consanents;consanents = t;
v = consanents;consanents = v;
w = consanents;consanents = w;
x = consanents;consanents = x;
y = consanents;consanents = y;
z = consanents;consanents = z;

one = math.random(consanents - math.random(20));
one = math.random(vowels - math.random(3));
two = math.random(consanents - math.random(20));
two = math.random(vowels - math.random(4));
three = math.random(vowels - math.random(4));
three = math.random(consanents - math.random(19));
four = math.random(vowels - math.random(4));
four = math.random(consanents - math.random(20));
one = order;
two = order;
three = order;
four = order;
order = (one);
order = (two);
order = (three);
order = (four);

JFrame frame = new JFrame("Namer");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel emptyLabel = new JLabel("namer");
emptyLabel.setPreferredSize(new Dimension(400, 200));
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
frame.getContentPane(frame.add(frame.list(order))); //fixed and changed consanents to order

//Display the window.
frame.pack();
frame.setVisible(true);
}

public static void main(String[] args) {


//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}


I just changed it to that but it still doesnt work

Gox
09-02-2009, 09:36 PM
Posting the error messages associated with your (red) lines of code would be helpful.

On a quick look I notice the following. Your variables one, two, three, and four are declared as type String. If you look at the API for Math.random (http://java.sun.com/javase/6/docs/api/java/lang/Math.html) you'll notice that its return type is "double". You cannot assign a double to a String.

You should also notice that the method random() does not take any parameters, but you are trying to pass the random method a parameter.

As well, the JFrame class does not appear to have a method called "list". Hence, your "frame.list" line of code should be an error. What is it that you're trying to do here?

My guess is these are the sources of some of your errors.

jdfskitz
09-02-2009, 10:31 PM
Im Trying to make a program that randomizes names.. my brother is making a wc3 rpg map.. and it gave me a task to get better at coding.. cause he cant think of names to give the people that give quests..

I would like it if you could post some fixes

jdfskitz
09-02-2009, 10:32 PM
and srry i forgot to change consanents to order