I have a problem having my source code run on my console window. I was
working on GUI(Gooey) and when I try to position objects or buttons or
labels or textFields on either south, north, east or west, it doesn't
work. I use Textpad . Could there be a problem with my code? Please
check it out below and help where you can.
************************************************************************************************************
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
class gui2
{
public void init()
{
JButton bt = new JButton("Hi");
add(new bt , NORTH);
addActionlisteners();
}
}
What could be preventing a button labelled "Hi" from showing up on the
console window to the North of it?
Hope to hear from you. Thanks
************************************************************************************************************
Here is another example that failed to compile as well.
****************************************************************************************************************
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
public class guistuff
{
public void init()
{
JButton butt = new JButton()
add(new JButton("Hello"), SOUTH);
add(new JButton("There"), NORTH);
add(new JButton("Guest"), EAST);
add(new JButton("Thanks"), WEST);
add Actionlisteners();
}
public void actionPerformed(ActionEvent e)
{
String cmd = e.getActionCommand();
if(cmd.equals("Hello"))
{
System.out.println("Hello there!");
}
else if(cmd.equals("There"))
{
System.out.println("Where on earth?");
}
else if(cmd.equals("Guest"))
{
System.out.println("So you are new huh!");
}
else if(cmd.equals("Thanks"))
{
System.out.println("I will say thanks again!");
}
}
}
********************************************************************************************************************
Thanks in advance.
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en