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 
Reply
galexcd
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!
Reply
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.
Reply
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.
Reply
Recent Queries:--
planning a java-based web site - 366.10 hr back. (1)
-
auto refresh jbutton - 590.09 hr back. (1)
Similar Topics
Keywords : making, java, based, program
- Fun In Sun (java)
(2)
Awesome Mmorpg Game
Pirate based strategy game (1) I just thought the by passing quest should be able to have a look at this to. /smile.gif"
style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> This game is something that
every1 should try out, it's a pirate game, the only one in it's kind. You can do lots of
stuff really, try this link and find out; http://www.ruletheseas.com/index.php?r=149039 If you
need any in game help try contacting me, punx08, and I might send you cash or something else
smile.gif Quote from the homepage: "Yarg, a pirate game. Do what ye want. Mug, steal, kill, and ....
Best Text-based (mmo)rpg's
(6) What are your favorite text-based mmorpg games?? If you done know what it is try google it. This is
something that every1 should try out, it's a pirate game, the only one in it's kind. You can
do lots of stuff really, try this link and find out;
http://www.ruletheseas.com/index.php?r=149039 If you need any in game help try contacting me,
punx08, and I might send you cash or something else /smile.gif" style="vertical-align:middle"
emoid=":)" border="0" alt="smile.gif" /> Quote from the homepage: "Yarg, a pirate game. Do what ye
want. Mug, steal, kill, and m....
Reclaim Control Over Your Windows-based Pc
Part 1 (2) QUOTE Important This tutorial contains steps that tell you how to modify the registry.
However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure
that you follow these steps carefully. For added protection, back up the registry before you modify
it. Then, you can restore the registry if a problem occurs. For more information about how to back
up and restore the registry, click the following article number to view the article in the Microsoft
Knowledge Base: 322756 How to back up and restore the registry in Windows ....
Java Script To Hide The Url In Address Bar
Does any one know about this ? (6) Hello friends , just now i came accross a particular type of script which is capable of masking the
URL which is seen in the Address bar of the webpage , that is by implementing the particular Java
Script when the user visits a page eg. www.mysite.com , then it is possible for the admin of
www.mysite.com to mask this site and display some other website in the viewers address bar. I came
to know that such a script can be written using Java Scripts , Can any one get me the Script ??....
My Modern History Speech- Is It Good? Am I Making Any Historical Inaccuracies?
(2) Can you guys please read through my modern history speech and tell me what you think? It is meant to
go for between 5 - 8 mins but mine goes for 9 mins, the teacher said he doesnt mind if we go over
just dont blabble so I haven't blabbled /biggrin.gif" style="vertical-align:middle" emoid=":D"
border="0" alt="biggrin.gif" /> ------------------------ HYPOTHESIS: FDR and Stalin were effective
in the introduction of their economic policies, however each attained major disadvantages that
counteracted the positives. QUOTE Good Morning Mr Howley and class. Today I wil....
Which Is Good Java Or Dot Net
which is good (3) Hi, I want to know which is going to be a success in future. I've asked this question to
many but all are giving my vague answers. I'm asking this question because i'm going to join
a company where i can choose either dot net or java. Which one should i choose. Wax....
Making My Own Browser
Uhm...need a name (10) I am currently developing my own Web Browser and I need a name for it /biggrin.gif"
style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> So if you got any good
ideas please do post them /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0"
alt="biggrin.gif" />....
Learn Java Programming Language Online Step By Step
(1) I had found this site >> http://learnjava.awardspace.com This website is for people who want
to learn Java Programming Language step by step. This website also includes JAVA lessons from the
beginning to advanced level. So this site appropriates for the beginner of Java programmer language
or non-basic Java Programming Language. The lessons are easy to follow and understand starting
from how to get your PC JAVA ready, the fundamental programming concept and creating the real
application. Moreover, the working examples are also included. Please enjoy the les....
Text Based Game
(6) Is it possible to make a Text Based game with only HTML and some PHP for chat? I dunno any
languages besides HTML. =.= yeah Im a newbie.....
Java Or C++
(10) Many having tell me to make my MMORPG in java leads me to agree, But I'm not sure truly is it
not yet easier, but yet the outcome of programming an MMORPG in java will make it fail or succeed
more then one in C+= I've learned a lot of variables in javascript, and I don't think that
java would be too bad either. My true question is, is those who use these languages, which seems
to give better outcome, and which seems to be more in ease. Regards -PCessna....
Budding Java Game Developers?
Ever wanted to make your own java web-based game, but not had the time (10) Right, this is the first post of hopefully many in this thread. Basically the idea is to get many
developers together to share ideas and knowledge to create our very own game. First we'll be
asking for is any ideas of what kind of game everybody would like to make, and then we'll set
about assigning tasks depending on everybodies skills. We will need programmers, artists,
web-designers, even admin and marketing. This will be freeware, but the experience will be great.
So, ideas anyone?....
Have You Ever Tried Soulseek?
P2P program for music sharing (1) Hi all, I was searching for a P2P good and fast P2P for downloading and sharing music files, and I
found SoulSeek, and it fit my needs, easy, fast, groupable sharing (e.g. when you are searching for
a song, you can download the whole folder that contain it). you can visit SOUL SEEK OFFICIAL
WEBSITE for downloading freeware version of soul seek, and download your favorite songs Wish that
help people who interests in downloading songs, music and soundtracks....
Helpful Registry Edit For Java Programmers
Command Prompt on right click menu (3) With this registry edit you can easily open the current folder in prompt without going through any
Change Directory commands (cd). This is useful for people like me who are programming in JAVA, and
every time to create class files and test them I have a diificult time just entering the commands in
Prompt. But if you don't want to use this registry edit you can create the directory in
C:\ drive like C:\files so you have to navigate very little in prompt. If you are
experienced in regedit you can do it yourself shown below OR download the attachment and app....
What Program Do You Use To Design Your Web?
Frontpage, Dreamweaver, a good text editor? (95) I personaly choose frontpage because its easy to use but.....I use dreamweaver for PHP.....
Jsp Or Java Chat Script Like Mig33
(5) so most of you guys know mig33. its a wap application,probaly java.most kindly to be java. does
anyone have java knowlege or knows where i can get a chat script like mig33? i also know this server
supports jsp so im planing to use it for my application. i was hosted here last year but moved
because i found a better host. now im back just to use the jsp on this server. Im planing to run
chat applictions so if any one wants to help me in my project let me know.....
Best Online Money Making Programmes
(9) check out this website to make a fortune online ....
Carpentry Information
Based on my experiences as a Carpenter (10) This is my "Day Job". If anyone has any questions about Carpentry, Cabinetmaking, Finish
Carpentry, Timber Framing or Woodworking (in general), I would be pleased to assist them with find
answers. I am not "ticketed", which means I haven't learned any bad habits from schools, but
with more than a few years in Construction, and having worked from Concrete to Countertops, I am
very experienced. And that is a fair to middling Teacher... /smile.gif"
style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Residential, Commercial,
Industrial, Interior....
Best Java Framework For J2ee?
Your Opinion About The Best Java Framework (6) What is the best framework to make enterprise application using Java (J2EE)? Currently I am
learning Spring and it is quite good eventhough it is very complicated in my opinion. Maybe someone
can share which framework that you use What are its advantages and disadvantages? I seek a J2EE
framework that supports JMS and offer quick development process.....
Tips For Making New Friends
What do you do when you have no friends (17) maybe im to young or omsehinthing, but everyone else in my school hangs around with their friends.
Im always the one left out:( like when my p.e. teacher tells us to partner up, i can't get any
partners and im always the one that has to join a group of 3's and have to take turns or osme
crap like that. Im the one the no one likes, some of the kids at my school have a girlfriend but I
can't even get ANY friends!This is really making me angry because I want a friend and I hate
the fact that no one likes me and wants to kill me. I even have some kids that ar....
What Free Advertising Program Do You Like?
Which one works best? (8) Please tell people what your favorite FREE traffic exchange, banner exchange, affiliate program and
such is. I know this is pretty broad topic, but it is a good way for people to see what programs
you use and why. No referal links are allowed as usual and these programs should be FREE. I would
like to use some of the ones you suggest to get more traffic. So list them here. Also, tell why
you like it and explain the service a bit so people can know a little about it. Like how successful
it was, how long you used it, ect. Thanks.....
.::gunz Online Clan::.
making a gunz clan lvl 10+ (17) hey im making a gunz online clan you have to be over lvl 10 to get in fill in this form gunz
name: country: plays a week: time(in GBA) play: level:....
Making And Editing A New Ipb V1.2 Skin [SPAM]
IPB newbie tutorial #2. (2) And I welcome you all, back for IPB tutorial session #2. For this tutorial I once again target you,
the newbie, and will assist you in the process of customizing your forum. When I first started
playing around with Invision Power Board, I was unaware of all of its features. In fact, when I did
learn of these features I had no clue what do to with them. So now, listen up, as I teach you the
basics of creating and editing a new skin. Let us begin. 1. Log into your AdminCP, on the left
side expand the Skins and Templates section, and click on Board Wrappers. Then ....
Making Winrar Archives
and adding password to winrar archives (13) **** 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....
Program To Rotate Images 45 Degrees
(9) I didn't know where to post it, so I just posted it here. Well, what I want is a program to
rotate an image I have. However, when I do it in Photoshop, the some of the lines are getting really
pixelated and the quality of the image and details are gone. So, I wonder if there are any programs
that can rotate the image 45 degrees without losing the picture quality. Also, I've made a
picture showing what I mean. Before rotating 45 degrees: After rotating: As you may see, the
lines on the second image are completely messed up. But is there a program, or just....
Are You In Search Of Free Google Cash Program ?
FREE GOOGLE CASH / GOOGLE PROFIT E BOOK (11) ARE YOU IN SEARCH OF FREE GOOGLE CASH PROGRAM ? FREE GOOGLE CASH / GOOGLE PROFIT E BOOK
QUOTE This is a free google cash program starter guide (in form of E book) brings you the
step to step process. Discussing about google ad words concepts, choosing the right platform to
reduce your work burden and makes it fully automatic of all. It takes only 20 to 30 minutes to set
an account. Getting the right advertiser based on some important points (EPC rates) so that you can
earn just place ads on google ad words. Ok rest all in guide. About the program Th....
Inbox Dollars
Best Money making Site-I Got Paid (31) Inbox Dollars is a great site that i found when i was browsing around the net. This Site Offers you
3 different reward chioces and they are: - 10000 Banner Imprressions- $10 - Gold Membership
-$17 - Check- $30 I have already gotten the 10000 banner impressoins from them. The ways
you can earn money are: -$5 when you join the site... -$0.01-0.10 for every paid email
-$4 for every survey site you join -Up to $50 for for every offer -Unlimited cash for
games -Umlimited cash for shoppings The offers are very easy to fill out and you ge....
[help] Java Script: Window.open
Works with Firefox, not IE (10) CODE <HEAD> var popUpWin=0; function popUpWindow(URLStr) {
if(popUpWin) { if(!popUpWin.closed) popUpWin.close(); }
popUpWin = open(URLStr, 'GunBound Tactics: Screenshots',
'width=820,height=550,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,top=90,left=90')
;; } </HEAD> <BODY> <a
href="javascript:popUpWindow('/f11/clipped.php');"><b>Clips&
#60;/b></a> This is a script for opening a new window. It works ....
Im Making A Mmorpg >>
Have a read... (14) can you give your ideas for my new game. if you want to help me even more then send me a private
message Thanks Tyjotr __________________________________________________ HybridHero - the new 3d
MMORPG (coming soon)....
Blender 3d
A nice FREE 3d program (18) Hi. I just wanna make you know that program : Blender. It's a free 3D program, but it's a
very good one, there's a lot of functions, and even a game engine that allows toy to create your
own games... The program is downloadable at : http://www.blender3d.org . I recommend that you try
it, even if it's not as good as 3DSM or Maya, it has pretty cool functions. Oh plz give your
opinion 'bout that program in this topic. See ya !....
Looking for making, java, based, program
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for making, java, based, program
*MORE FROM TRAP17.COM*
|
advertisement
|
|