Java Help Please **New Question**

Live forum: http://forum.freeipodguide.com/viewtopic.php?t=49281

superintendent

03-12-2006 00:43:49

Big Edit Ok so I edited out my own question entirely because I managed to figure it out on my own. I am looking into the book more and more and have seen alot of GUI interface stuff. Basically now I want to convery my entire program to GUI Based.

I am just trying to mess around with it a bit now and figure out how BreezySwing Works.

Basically I am trying to just make a simple program to test with that displays buttons, and when I click on a button it opens up a new window with one of my programs. So far I have figured out how to make buttons, labels, etc. The trouble I am having is getting the program to open up a brand new window where I can enter new labels, doublefields, buttons, etc.

[code12e07201ec9]
import javax.swing.li;
import BreezySwing.li;

public class ConvertWithGUI extends GBFrame{


private JLabel titleLabel;

private JButton triangleButton;
private JButton numberButton;
private JButton helloButton;


private ConvertWithGUI(){

titleLabel = addLabel ("Math Helper Version 1.0" ,1,1,1,1);

numberButton = addButton ("The Perfect/Prime Number Program" ,3,1,1,1);
triangleButton = addButton ("The Triangle Program" ,0,1,2,1);



}

public void Hi(){



ConvertWithGUI theGUI = new ConvertWithGUI();

theGUI.setSize (400, 200);

theGUI.setVisible(true);

theGUI.setTitle("The Perfect/Prime Number Program");
triangleButton = addButton ("Tfsdafsdaf" ,0,1,2,1);

helloButton = addButton ("HELLO" ,1,1,1,1);
}

public void buttonClicked (JButton buttonObj){
if (buttonObj == numberButton){

Hi();


}


}

public static void main (String [] args){
ConvertWithGUI theGUI = new ConvertWithGUI();

theGUI.setSize (300, 200);

theGUI.setVisible(true);
}
}
[/code12e07201ec9]

That is what I am testing out with. Basically when you run it, it opens up a window with two buttons. I want to make it so that when I click one of the buttons, they open Hi(); which opens/creates a completely new window with new buttons, labels, etc. that I instantiate. Right now, when you click on one of the buttons it opens a new window and resizes it, but I cant figure out how to clear/change the previous buttons from the previous window. Any help would be great.

Thank you.

TFOAF

03-12-2006 06:57:35

Yup. You gotta make classes and then call them.

public class blah{
doStuff();
}

Then you gotta have a keyboard class that recognizes characters. Which then you tell it what to do, and have the characters set to a variable, such as [if5a9b6894e]num[/if5a9b6894e].

System.out.println("Which do you want?");
System.out.println("1");
System.out.println("2");
System.out.println("3");

if (num == 1){
blah();
}

etc. etc. ;)