Current location: Hot Scripts Forums » Programming Languages » Everything Java » simple gui


simple gui

Reply
  #1 (permalink)  
Old 04-24-06, 08:48 AM
hammie hammie is offline
New Member
 
Join Date: Apr 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
simple gui

I have written a simple java program

I run it using
>javac abc.java //compile

>java abc //run
from the command prompt

I have no experience in creating gui in any Prog Lang
i need to design a simple gui,just having a single button,that
when clicked does the job of "javac & java"
my program is very simple .it has 3 modes of running,which I have to
specify by passing parameters at command line.


please guide me in designing the gui for normal mode.
(in normal mode i don't have to pass any parameters at command line)
just: >javac abc.java
>java abc
then,I will manage for other modes.

One of my friends was saying that,u have to create an html file
having a 'link' that is connected to javac command,but unfortunately,he is out of touch with 'gui's and does'nt remember exactly

please help and send the code(universal one working for all progs)



Thank you
Reply With Quote
  #2 (permalink)  
Old 04-25-06, 01:08 AM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Here is a sample GUI Application. It is basically a single button in a single frame. When you click on the button, the action listener returns a click event, notifying you that the button has been pressed:

Code:
// SampleGUI.java: demo for GUI Elements

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
 
public class SampleGUI extends JFrame
  implements ActionListener {
  private JButton jbt1;
 
  public static void main(String[] args) {
	SampleGUI frame = new SampleGUI();
	frame.pack();
	frame.setTitle("Sample GUI");
	frame.setVisible(true);
  }
 
  public SampleGUI() {
	// Create panel p1 add three buttons
	JPanel p1 = new JPanel();
	p1.setLayout(new FlowLayout());
	p1.add(jbt1 = new JButton("Button 1"));
 
	// Place p1 in the frame
	getContentPane().setLayout(new BorderLayout());
	getContentPane().add(p1, BorderLayout.SOUTH);
 
	// Register listeners
	jbt1.addActionListener(this);
  }
 
  public void actionPerformed(ActionEvent e) {
	System.out.println(e.getActionCommand() + " was clicked");
  }
}
I have attached a screenshot of how it is suppose to look when you run it. Make sure to compile the java file first and create the .class before running it.

I use JDK 1.4.2 and JCreator LE Freeware to run the project. You can download and install JCreator here if you are interested (I highly recommend it. Makes life a lot easier):

http://www.jcreator.com/download.htm

Best of Luck,

Pete
Attached Images
File Type: gif SampleGUI.gif (6.7 KB, 420 views)
__________________
Reply With Quote
  #3 (permalink)  
Old 04-29-06, 10:57 AM
King Coder King Coder is offline
Community VIP
 
Join Date: Jan 2006
Posts: 703
Thanks: 0
Thanked 0 Times in 0 Posts
You may be able to create a Process() and execute that. I'm not sure how you would send the details to it though.
__________________
my site
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Script Required For Simple Man thebigman PHP 6 01-06-07 12:04 AM
need help simple question, but need it right. 0o0o0 PHP 3 01-31-06 04:21 PM
Need Simple Forum & Knowledgebase Norm1 Script Requests 1 01-31-06 01:08 AM
Simple Online Multiplayer Game (need coder and site designer) Midriv68 Job Offers & Assistance 0 01-27-06 04:31 PM
Very Simple Small Project - I got $$$ Fabolous Job Offers & Assistance 5 07-23-05 02:09 PM


All times are GMT -5. The time now is 05:37 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.