How do I access the variable within another class's method?

Important bits of the Main class:

Genster mechz =new Genster();

//...

privateclass ClickListenerimplements ActionListener{

publicvoid actionPerformed(ActionEvent e){

if (e.getSource() == b_generate){

if (basic.isSelected() ==true);{

Genster.BasicG();// to execute what would be in that method

t_generate.setText(/*what to put here?*/);

}

Genster class:

publicclass Genster{

publicstaticvoid BasicG(){

String numbercool ="1337, it worked!";

//return numbercool;

// Without the void, NetBeans complains that I don't have a

// return type, although I have it here, currently commented. Returning numbercool

// would seem logical. :/

}

}

So, I'm a bit stumped here. I want to set the text of a text box to what my BasicG method in Genster processes. Right now, it just assigns numbercool to something I specify. I've tried all sorts of things like mechz.numbercool and mechz.BasicG(numbercool) Help please! :D

[1989 byte] By [kavon89a] at [2007-11-27 10:44:12]
# 1

private class ClickListener implements ActionListener {

public void actionPerformed(ActionEvent e) {

if (e.getSource() == b_generate) {

if (basic.isSelected()) {

String text = Genster.BasicG();

t_generate.setText(text);

}

//...

public class Genster {

public static String BasicG() {

return "1337, it worked!";

}

}

Note that you had a semicolon following the test "basic.isSelected()==true",

which is a common mistake:

if (x==y); {

//this code block is *always* entered because of ";"

}

BigDaddyLoveHandlesa at 2007-7-28 20:05:27 > top of Java-index,Java Essentials,New To Java...
# 2

Odd how that was the only one with a semi-colon, the rest of the Ifs under it didn't.

I don't think that solves my problem though. :/

kavon89a at 2007-7-28 20:05:27 > top of Java-index,Java Essentials,New To Java...
# 3

My code looks OK to me. If it doesn't work for you, post a small (<1 page) sample program that forum members can run that demonstrates your problem.

BigDaddyLoveHandlesa at 2007-7-28 20:05:27 > top of Java-index,Java Essentials,New To Java...
# 4

t_generate.setText(/*what to put here?*/);

That is my main problem. How do I call the string ' numbercool ' from the method BasicG inside the Genster class.

kavon89a at 2007-7-28 20:05:27 > top of Java-index,Java Essentials,New To Java...
# 5

> t_generate.setText(/*what to put here?*/);

>

> That is my main problem. How do I call the string '

> numbercool ' from the method BasicG inside the

> Genster class.

What was wrong with:

String text = Genster.BasicG();

t_generate.setText(text);

BigDaddyLoveHandlesa at 2007-7-28 20:05:27 > top of Java-index,Java Essentials,New To Java...