The Artima Developer Community
Sponsored Link

Design Forum
how 2 make GUI from application

3 replies on 1 page. Most recent reply: Sep 30, 2002 2:52 PM by bree vanoss

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Roob

Posts: 3
Nickname: booboo
Registered: Aug, 2002

how 2 make GUI from application Posted: Aug 18, 2002 12:57 PM
Reply to this message Reply
Advertisement
hi all, i need your help urgently as i have to finish my project by this week.
iv got all the classes and methods that take care of everything that my application will need.

however i dont know how to create the GUI and implement the listener etc.. to take care of menu selections, making them do what they're supposed to do. can anyone help me?

thank you


thomas

Posts: 42
Nickname: turbomanic
Registered: Jul, 2002

Re: how 2 make GUI from application Posted: Aug 19, 2002 5:27 AM
Reply to this message Reply
create a class like so
import java.awt.event.*;
import java.awt.*;
public class Gui extends frame implements ActionListener{
MenuBar mb;
Menu file;
MenuItem close;
public Gui{
mb=new MenuBar();
add(mb);//adds menubar to frame
file=new Menu("file");
mb.add(file);//adds file to menubar
close=new MenuItem("close");
file.add(close);//adds close to menu
show()//shows the frame (window)
}//end of constructor
public void actionPerformed(ActionEvent evt){
if(evt.getSource()==close){
dispose();//destroys frame ending programme
}//end of if
}//end of action performed

public static void main(String [] args){
Gui frame=new Gui();
}//end of main

}//end of class

thomas

Posts: 42
Nickname: turbomanic
Registered: Jul, 2002

Re: how 2 make GUI from application Posted: Aug 19, 2002 5:42 AM
Reply to this message Reply
sorry for the above post there is alot of errors in that programme, major errors.


THE BELOW PROGRAMME
WORKS PERFECTLY


import java.awt.event.*;
import java.awt.*;
public class FileCreator extends Frame implements ActionListener{
MenuBar mb;
Menu file;
MenuItem close;

public FileCreator(){
setLayout(null);
setSize(600,600);
mb=new MenuBar();
setMenuBar(mb);//adds menubar to frame
file=new Menu("file");
mb.add(file);//adds file to menubar
close=new MenuItem("close");
file.add(close);//adds close to menu
close.addActionListener(this);
show();//shows the frame (window)
}//end of constructor

public void actionPerformed(ActionEvent evt){
if(evt.getSource()==close){
dispose();//destroys frame ending programme
}//end of if
}//end of action performed

public static void main(String [] args){
FileCreator frame=new FileCreator();
}//end of main

}//end of class



SORRY FOR ANY
INCONFIENCE

bree vanoss

Posts: 9
Nickname: bree
Registered: Sep, 2002

Re: how 2 make GUI from application Posted: Sep 30, 2002 2:52 PM
Reply to this message Reply
you've got to be kidding? it's bad enough you are asking for a solution to some school assignment instead of actually "learning" how to do it yourself; but on top of that you don't provide ANY information as to what the gui would actually need to do.

your first stop should be the swing part of the java tutorial http://java.sun.com/docs/books/tutorial/uiswing/mini/index.html.

-=bree

Flat View: This topic has 3 replies on 1 page
Topic: please talk about workflow!! Previous Topic   Next Topic Topic: Applet-Servlet Vs RMI

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use