aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes really basic GUI question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "really basic GUI question" Watch "really basic GUI question" New topic
Author

really basic GUI question

Larry Reynolds
Greenhorn

Joined: Oct 22, 2005
Posts: 24
I am trying to start writing a program and for now would be happy to get a window to display. I know that I can't create the window in a static method, not sure what to do to call the createGUI method, here's part of the code: Thanks again.

mport javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.*;

public class TestGrid {
public static void main(String[] args)
{
GridSquare[][] squares = new GridSquare[10][8];
setUpGrids(squares);

}
public void createGUI(){
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label);

frame.setSize(300,300);
frame.setVisible(true);
}
rob armstrong
Ranch Hand

Joined: Jul 25, 2005
Posts: 77
import javax.swing.*;

public class ClassNameHere extends JFrame
{
public static void main(String[] args)
{
new ClassNameHere();
}
public ClassNameHere()
{
this.setSize(200,100); //Sizing
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Title of Window); //Top of the Box
this.setVisible(true); //make visible or you can't see it
}
}



Give that a try!
roba
Larry Reynolds
Greenhorn

Joined: Oct 22, 2005
Posts: 24
It worked great! Thanks for your help.
[ January 08, 2006: Message edited by: Larry Reynolds ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: really basic GUI question