Welcome to Dream.In.Code
Become a Java Expert!

Join 149,481 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,434 people online right now. Registration is fast and FREE... Join Now!




java gui

 
Reply to this topicStart new topic

java gui

matome
17 May, 2007 - 07:30 AM
Post #1

New D.I.C Head
*

Joined: 22 Apr, 2007
Posts: 10


My Contributions
i 'm trying to write a java program to capture ann animal,its habitat,species it belongs,its life span,but i have got this error
'{' expected line 4


This is my code,please help me guys!!!


import java.swing.*;
import java.awt.*;

public class Gui extent JFrame

{
private jlabel label1,label2,label3;
private jTextField text1,text2,text3;
private jButton button,button;

public Gui()
{
SetTitle("Animal Capturing");
SetSize(400,300);
Container pane = getContainerPane();
pane.Setlayout(new FlowLayout());

label1 =new jlabel("ANIMAL HABITAT");
label2 =new jlabel("SPECIES");
label3 =new jlabel("life's span");
text1 =new jTextField(10);
text2 =new jTextField();
text3 =new jTextField();
button =new jBuutton("ok");
button =new jBuutton("ok");

pane.add(label1);
pane.add(text1);

pane.add(label2);
pane.add(text2);

pane.add(label3);
pane.add(text3);

pane.add(button);
pane.add(button);

SetVisible(true);
SetDefaultCloseOperation(Exit_On_Close);

}
public static void main(string args[])
{
Gui gui = new Gui();
}

}

User is offlineProfile CardPM
+Quote Post

Ellie
RE: Java Gui
17 May, 2007 - 08:21 AM
Post #2

D.I.C Regular
Group Icon

Joined: 17 Jan, 2007
Posts: 427



Thanked: 4 times
Dream Kudos: 150
My Contributions

You have a mass of syntax and spelling errors which are preventing this from working.

I've fixed them mostly, but I'm not sure about the SetDefaultCloseOperation method, so I've just commented it out for now. This compiles and runs though, so should get you going again.


CODE
import javax.swing.*;
import java.awt.*;

public class Gui extends JFrame
{
private JLabel label1,label2,label3;
private JTextField text1,text2,text3;
private JButton button1,button2;

public Gui(String title)
{
//SetTitle("Animal Capturing");
super(title);

Container pane = this.getContentPane();
pane.setLayout(new FlowLayout());
this.setSize(400, 300);


label1 =new JLabel("ANIMAL HABITAT");
label2 =new JLabel("SPECIES");
label3 =new JLabel("life's span");
text1 =new JTextField(10);
text2 =new JTextField();
text3 =new JTextField();
button1 =new JButton("ok");
button2 =new JButton("ok");

pane.add(label1);
pane.add(text1);

pane.add(label2);
pane.add(text2);

pane.add(label3);
pane.add(text3);

pane.add(button1);
pane.add(button2);


//SetDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

}
public static void main(String args[])
{
Gui gui = new Gui("Animal Capturing");
gui.setVisible(true);

}

}

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 04:22PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month