onyxgem
Jun 26 2007, 03:42 AM
Java GUI Making a Little Java Program Sec. 1: Imports and starting it off Sec. 2: Variables Sec. 3: Frame and Stuff Sec. 4: Declaring buttons Sec. 5: Adding buttons Sec. 6: Action Listening Sec. 7: Using this for a learning experience Section 1 Now, let's think. What imports do we need? We obviously need GUI imports. We also need the action Listener. So, let's declare this at the very top: Code: CODE import java.awt.*; import java.awt.event.*; import javax.swing.*; That's all we need to get all our supplies. Now to start us off. Skip a couple lines and add: Code: CODE public class Tutorial extends JFrame implements ActionListener { Section 2 Let's declare our variables. Right below the class, add Code: CODE private static Tutorial frame; private static JTextField text; I will tell you about this later. Section 3 This is in all java programs. To start it and load everything, you must add: Code: CODE public static main(String[] args) { We must now add the frame, so skip a 2 lines and add: Code: CODE frame = new Tutorial(); frame.setTitle("Tutorial of GUI"); frame.setSize(400, 100); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setVisible(true); Ending the statement, add one last "}" Section 4 Now add: Code: CODE public Tutorial() {Next add: Code: CODE setLayout(new BorderLayout());
JTextField text = new JTextField(10); JButton button = new JButton("JButton1"); JButton button1 = new JButton("JButton2"); JButton button2 = new JButton("JButton3"); JButton button3 = new JButton("JButton4");
JPanel panel = new JPanel(); That adds the button vars. Section 5 Let's add the buttons now. Add right below that, add: Code: CODE panel.setLayout(new FlowLayout());
panel.add(button); panel.add(button1); panel.add(button2); panel.add(button3);
add(panel, BorderLayout.NORTH); button.addActionListener(this); button1.addActionListener(this); button2.addActionListener(this); button3.addActionListener(this); } That adds the buttons on. Section 6 Let's make the outcome of clicking the button. Add: Code: CODE public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(frame, " was selected." );
} }That tells you what button was selected. Now save and compile. Now run the program and see what the outcome is. Section 7 You can view other things like this at: http://java.sun.com/developer/online.....;/contents.htmlThis will help you understand all the functions of java GUI. -Bill for Unkn note:i copied this from my word and pasted it here hope this helps ya out im sorry if i misspelled anything i type fast 
Comment/Reply (w/o sign-up)
alex7h3pr0gr4m3r
Jun 27 2007, 04:55 PM
Great tutorial! I still hate java though. I remember learning gui in java about four years ago, and it was hell for me. This probably would have made it a bit easier but I much prefer c++ to java when making gui applications. Anyway great tut! Keep up the good work!
Comment/Reply (w/o sign-up)
zak92
Jun 29 2007, 06:47 AM
These languages confuse me but at the same time fascinate me as some gibberish can turn into such good creation such as a great and a profitable web site. Thanks man love you as I wanted to just learn this.
Comment/Reply (w/o sign-up)
master_bacarra
Jun 29 2007, 11:32 AM
the reason why i like java more is because i could just use the exception handling for the errors. but i have to admit i'm not a great programmer at all. i never really appreciated c/c++ because of the complicated pointers. programming with pointers was hell for me. anyways, great tutorial for starters.
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : making, java, based, program
- Reclaim Control Over Your Windows-based Pc
Part 1 (2)
How To Install Opengeu In Ubuntu
OpenGEU is a distro based on Enlightenment and derived from Ubuntu (2) First of all please note well that E17 is in beta phase, and can make your computer segfault
(which by contrary - WILL NOT ERASE YOUR DATA - your computer will be restored to the statein which
it was before it segfaulted), and if you don't want this to happen then don't install this!
I'll now tell you how to install OpenGEU when you already have Ubuntu (or Kubuntu and
Xubuntu ) installed already on your machine. First of all I need to introduce you to OpenGEU,
it's a relativelly new Linux distro which uses Enlightenment instead of ....
Making Calculators with PHP
Some basic calculator scripts I made. (4) Yes, I made some basic calculators to use for simple math problems, nothing big. I'm a newbie at
php, so if I made something that could be short, long, I am sorry. lol Here is one for adding two
numbers. CODE Adding 2 numbers Type in the two numbers you'd like to add together.
+ Save that and name it add.php or add.html, it don't matter. In that
page, it is simply asking for 2 numbers to add. Next, create a page called add2.php, can't make
it html. CODE $_POST ; $_POST ; ?> Answer to + Answer to + ....
How To Make An Ultimate Game List.
If you're making a site on video games or such. (0) Hello. I am BuBBaG. You can call me Bubba for short. I'm going to show you how to make an
Ultimate Game List. First off, we need to make a database, we are going to call this database
`my_db`, leave out the `'s. Inside that database we will need to create a table called
`ugl'(Ultimate Game List, duh). To make the table, simply enter this in the Syntax. CODE
CREATE TABLE ugl ( System char(50), Game char(50), ) In the above code, it is stating we are
creating a table called ugl, with two columns, System, and Game. Next, we will need to make a form,
t....
Make A Flat Based Shoutbox, With Auto Refresh.
(8) With this tutorial, you will learn how to create a simple shoutbox, but only uses a .txt file. Also
with auto refresh, and I am going to do a backgound. We will be making 5 files. 1. index.php The
main page 2. msg.php Reading msg.txt 3. msg.txt Note: You must give it 777 4. shout.php Where
it add to msg.txt 5. bg.gif Background. Index.php would be like this: CODE Shoutbox
Name: Message: Let's go over what the code do. -> are just the title.
gets msg.php which gets msg.txt. You will know why I do that later. -> ....
Ftp In Visual Basic 6.0
Start making your FTP client using VB6 (3) Recently, I had a need to make a FTP client, since our webhosting FTP server was kind of exotic, and
very restrictive, and most of uploads, even though they reach 100% would crash... File would be
uploaded to a server, but FTP clients just froze upon completion, waiting for the 226 (OK) from FTP
server... So, I had to make my own, one who would not wait for 226, but instead, watch the file
pload progress... This tutorial is not fuly complete, in the sense that it does not offer COMPLETE
FTP client functionality (for example, I ddn't write the code for FTP download, ....
Making A Song In Fruity Loops Part Three
part three precusion (1) ok part three now which covers the precusions setup of the small song i built for this tutorial.
the nesecery files can be downloaded here the image below is included in the precusions folder as
it mught not be entierly visable within this post so shold you need it its there also the images
purpose is to enable you to see what i am refering to within this tutorial lateron. now what i
have done above is blackd out every pattern that has nothing to do with the precusion. so the
patterns displayed in light grey are the only patterns i will be refering to. ok lets b....
Making A Song In Fruity Loops Part 2
part 2 the second melody (0) ok i am going to attach the midi file againe incase you didnt get it from the first part in this
part i will demonstright how to create and insert the second mellody ok so you have your first
mellody wich is ecetially the comein chord as i call it. now open the midi file you put in your left
panel during the first tutorial and drag the mellody 2 © onto the pallet but click on pattern two
in the right site playlist box. now like in the first tutorial replace with sytrus. for this type
of mellody use something in the leads section of the plugin.for this you need to ....
Background Image Swap Script
Change a Background Image based on clock time (15) Background Image Changer Script To swap the background image from your CSS file according to the
Server Clock Time. 1.) In your CSS file, add the following rule: CODE body { background:
url(time.png); } 2.) Create a "folder" named time.png. 3.) Into the folder, place three images
named morning.png, day.png, night.png. 4.) Also, in the same folder, create an index.php file and
copy/paste the following script. CODE $hour = date('H'); if ($hour $image =
"morning.png"; } elseif ($hour $image = "day.png"; } else { $image = "night.pn....
Creating A Resume
10 Tips For Making A Resume (1) I've been working on my Resume for months now. Here is a summary of what I've learned: 1.
Avoid referring to yourself via 1st person or 3rd person terms. Rather than saying "I started this
job in" just say "Began job in"... Employers expect Resumes to be professional and avoid reference
to oneself; and instead speaking in an impersonal tone that presents
achievements/skills/experience/education without personalization. Avoid words like "I", "my", "he",
"she", etc. Leave out personal pronouns and only use the action words/verbs. This also includes
your Ob....
Faux Ajax Loading - Css Only
Pretend your site is Ajax based (3) Link: http://www.jlhaslip.trap17.com/samples/misc/ajax/index.html Check that out. The first page
has information and the second and has the actual example of its use with sample CSS code. I find
that when you visit a site which has a slow server and attempt to view 'large' Image files,
it is pretty boring to sit and stare at a blank screen, so this little snippet of code can be used
to give the visitor something to see to indicate that the image is being downloaded. I built a
small animated gif that sits in the background of the space allocated for the image....
Making A One Page Does All Website In Phph
(2) Hello and Great Day or Night either one. Have you ever been to a site and seen a index page or any
page at all control everything such as index.php?do=home&action=logout something similar to the
above? Well I am going to show you how easy it is to make this all own your own, and only have to
use one web template or design to make it work. Before we get started you need to go ahead and find
the web design that you want to use. After you find the site you want to use go ahead and save
it... and save it like this so we can work together, ok! Note* We are going to be s....
Making The Popular Id Browsing For Your Site.
(17) Was just sitting and being bored but then I realized I could show how to create more or less popular
?id=page browsing. It's actually really easy. I know two ways how to do it. First one I learned
was checking the variable and if it's true including the text/file/anything needed and so on. It
was ok, but sometimes I just couldn't make it work so I switched to switch() function and
that's what I'm going to show you guys right now. So, I made a test page which contains the
code needed and here is its source. CODE Untitled Home - P....
Css-based "i-frames" (sort Of)
A couple of ways to do it... (1) I got thinking that it might be nice to have a method to load a bunch of pictures up to a site, but
not have them taking up a lot of space. And without using a bunch of php, while still presenting the
entire picture. And using full-on CSS coding, not tables or frames. So here you go... a "picture in
a picture" method. A CSS framed picture And a "hidden" "picture in a picture" method. A
"hidden" CSS framed picture Sort of a way to 'hide the picture and let the user decide if they
want to actually see the image. All it does is use positioning for placing the....
How To Make A Simple File Based Shoutbox Using Php And Html
(8) A simple tut to make a simple shoutbox. Let me jump right in. First of all you need the standard
equipment for PHP, an IDE like XAMPP and an editor like PHP EDITOR 2OO7. Were going to make a
simple guestbook using three files, webpage.php, shout.php and shout.txt. Webpage.php can be
changed to whatver you want, it will be the page on which the guestbok is shown, you could even use
this code and add it to another php page n your site. Shout.php is the proccessing page and
shout.txt is where the shouts are stored. Firstly we need to make the visual design of the box.....
Making A Dynamic Page On Blogspot
Using an external server to make your pages hosted on blogspot dynamic (5) Good morning everyone. Have you ever wondered how to allow your visitors to edit content on your
blog? Like adding a post straight off the page, adding a link, editing your profile etc. This will
be extremely useful if you want your visitors to contribute to your blog besides writing comments or
tagging. 1. Adding a post straight off the page. Go to blogger.com, login, select your blog. Go to
settings -> email. By enabling blog email, you can now add a post by simply sending an email to the
address you specified. The address should look something like: yourusername....
Beginner's Guide To Skiing
Based on my own experience. (4) I really like skiing. It is so much fun that you won't know how you could have survived until
your first time. So here are some things you should know before you head over to your lcoal ski
area: Dressing: You should get a few basic things: -Base layer: long underwear, especially
thermals, keep you warm, wick moisture from the skin, keep your legs from getting irritated by your
ski pants -Middle layer: A fleece jacket; or anything aside from wool, which is very itchy. This
will keep you warm in cold weather. If your outer jacket or parka (see below) is insulate....
Building An Address Book With Java
(1) Dear Friends I am sharing a java program with all of u which I built a few years back. I guess it
will help beginners. It uses java utill package to store data in a flat file. The File
Name-----phone.java import java .io .*; import java .util .*; import java.awt.event.*; public
class phone { public void new_record() { String id,name,city,add,number,total,list;
boolean bln=false; try { Properties pr=new Properties(); FileInputStream
fin=new FileInputStream("phone.dat"); if(fin!=null) { pr.load(fin); } ....
Making Interactive Cds With Flash
My second flash tutorial for Beginners (2) Im back again with what i think it would be an interesting tutorial for all of you guys who wants to
take flash out of the web and make really cool interactive CDS. First of all if all of you are
thinking right now: "this dude is wrong for making interactive cds you have to use macromedia
Director", well you are right macromedia director it's used to build interactive cds and dvds
among other things, but you can also make interactive cds with Flash, the thing is: if you want to
make a simple interactive CD you can totally do it with flash, of course Director brings ....
Creating A Timer Program
Using Visual Basic 2005 (8) This tutorial will explain how to create a basic timer using Visual Basic Express 2005. If you
don't have it, it's free and you can dowload it from Microsoft's website. All you need
is a few minutes to sit down and read this and a version of Visual Basic. OK, so what will this
timer actually do? Well, you are able to enter a number of minutes and a message, and then click a
button. Once the timer is up, your message pops up and you are reminded! So, basically it's a
little reminder system. I use it to remind me when TV programmes start, when I have to go ....
How To: Make A Simple Php Site
Making one file show up on all pages using php (21) I have looked all over the site and could not find anything that was like this simple, or just like
this at all.. For some people i know that you are using a basic HTML site...and having a big menu
if you want to add somthing you have to go into every one of the pages and add or remove or edit
what you want to do, but with somthing verry simple all you would have to do is edit one file, and
all of the pages that have the PHP script on them would suddenly change to what that one file is.
So to start off if you are planning on using this little tirck, the page that you a....
Css Based Photo Gallery Code
Fluid design for layout (3) Fluid Design Photo Gallery There are quite a few Topics here on the Trap17 Forum about how to
set-up and use Photo Galleries and about the link code for getting from a Thumbnail Image to a full
size Image and all that stuff, so I would like to take this "Photo Gallery" concept one step further
without covering what others have already supplied instruction for. Usually, when there is a
solution posted here for the code on "how-to-do-this", there are tables involved and the Links are
placed inside Table cells. Tables are not neccesarilly a bad thing, but they were n....
Php Navigation
How to make your navigation based on php (7) I have re-constructed my last PHP Navigation system and it works great. So I have it here for you
guys. Here are the instructions. INSTRUCTIONS: Open your main page for your site in your text
editor and paste in the following code where the main content goes. CODE error_reporting
(E_ALL ^ E_NOTICE); if(!$page){ $page = $HTTP_GET_VARS ; } //You can change 'page' to
whatever you want. //Default Page if($page == "" or $page == "index"){ include("main.php"); //You
can change 'main.php' to whatever you want. } //Secondary Pages if($page == "something"....
Making Winrar Archives
and adding password to winrar archives (15) **** This tutorial will show you how to put files into .rar Archive and pass worded (if wanted)
**** What You Will Need Before continuing you will need a couple of thing, first of all you
need WINRAR , which is a very powerful archive manager. It can reduce size for you email
attachments, decompress RAR, ZIP and other types of files downloaded from the internet. You can get
winrar at http://www.rarlabs.com The other thing is that make sure your using Windows XP because
this is what I used to make this tutorial. I think it works with any other windows not....
Tutorial: Installing D-shoutbox For Ipb V1.2
Making your installation even easier (12) Over the course of the summer I have tried hard to install a shoutbox into a new forum I was
developing. I went to the Invisionalize forums and found several mods for shoutboxes, but none of
them seemed to work. I first tried to install the D-Shoutbox, but upon this first try, I was
unsuccessful. Eventually, after much frustration, and trying other mods, which didn't seem to
stack up to Dean's features, I was determined to make it work. For some, editing your files (to
the newbie that is) can be difficult, with everything looking like a foreign language (basi....
An Introduction To Java And Graphics
(5) Table of Contents I. Introduction II. Before You Begin III. Necessities in a Java Program IV.
Creating a Canvas V. Shapes A. Line B. Rectangle C. Oval D. Polygon VI. Other Things A.
Changing the Color B. Strings 1. Changing the Font 2. Drawing a String C. Images VII.
Conclusion I. Introduction Welcome to my second tutorial here at Trap17. I'm going on
vacation for a week so I thought I'd leave you all with some of the things that I picked up in
the class I took ealier this summer. If anyone wants to see some things that I've done, t....
Making Shadows Without Images
(4) Im going to show you very simply how to create boxes with Shadows using div tags and css, no images
needed, meaning fat pageload times! /biggrin.gif' border='0' style='vertical-align:middle'
alt='biggrin.gif' /> You simple need to create two layers, one behind the other, the one behind
will have a top and left margin on 20px, the one infront 10px, set teh background colour of the one
behing darker than teh one infront, you should end up with something like this: Here is th html
to create this effect: CODE Its as simple as that, two divtags, a bit of cs....
Making A Webserver Directory Listing
Helps you organise your webserver (6) I recentely installed IIS with PHP and MySQL on my pc (previous I used UniServer, but that
doesn't matter here). But I had always to go to http://localhost/websiteiwanted or I had to
create a shortcut on my desktop for every site so I decided to create an "overviewpage". It shows
all the websites in your wwwroot with a link to them. If you have folders you don't want to be
included, you extense the && check (but I'll explain this lateron) Here's the total code:
CODE $dir=opendir('.'); $isdirtrue = false; while ($file = readdir($dir)){ ....
Making A Website
Also Some Dos and Don'ts (6) I had originally had this posted on my domain at nevernormal.com, and thought that you guys could
use it here as well. Granted, this is geared to the uber newbie, so don't razz me if I
don't suggest the most advanced in web design. lol So, you want to make a website? 1.
First, think about what you want your site to be about. There are fanfic sites, like Drastic
Measures and fanfiction.net ; cliques or clubs, like the BtVS Writers' Guild ; or, if you
want, you could have a general site, whether it be about a show/movie you like, or even just about y....
How To Setup A Php-nuke Based Site
very helpfull (5) Ok, so you want to have a php nuke site. First of all, what is this "PHP nuke", and why is it so
special? Php nuke is a web portal system. It is expandible, and can be very usefull. You can find
an example here. Yes, it is that good. So, lets take a closer look. It's pre-packaged basic
features are: *forums *a login system *weblinks *downloads *news *polls *faqs *content You can
allways de-actuvate some features, but it's near-imposible to remove them. Kinda annoying, but
you know. Some people may not need phpnuke, or cant have i period. You need: *some ....
Looking for making, java, based, program
|
Searching Video's for making, java, based, program
See Also,
|
advertisement
|
|