Making a java based program

free web hosting
Open Discussion > CONTRIBUTE > Tutorials

Making a java based program

onyxgem
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.html
This 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 cool.gif

 

 

 


Reply

galexcd
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
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
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



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. planning a java-based web site - 366.10 hr back. (1)
  2. auto refresh jbutton - 590.09 hr back. (1)
Similar Topics

Keywords : making, java, based, program

  1. Fun In Sun (java)
    (2)
  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 ....
  3. 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....
  4. 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 ....
  5. 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 ??....
  6. 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....
  7. 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....
  8. 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" />....
  9. 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....
  10. 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.....
  11. 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....
  12. 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?....
  13. 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....
  14. 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....
  15. 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.....
  16. 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.....
  17. Best Online Money Making Programmes
    (9)
    check out this website to make a fortune online ....
  18. 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....
  19. 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.....
  20. 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....
  21. 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.....
  22. .::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:....
  23. 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 ....
  24. 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....
  25. 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....
  26. 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....
  27. 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....
  28. [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 ....
  29. 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)....
  30. 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 !....

    1. Looking for making, java, based, program

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for making, java, based, program

*MORE FROM TRAP17.COM*
Similar
Fun In Sun (java)
Awesome Mmorpg Game - Pirate based strategy game
Best Text-based (mmo)rpg's
Reclaim Control Over Your Windows-based Pc - Part 1
Java Script To Hide The Url In Address Bar - Does any one know about this ?
My Modern History Speech- Is It Good? Am I Making Any Historical Inaccuracies?
Which Is Good Java Or Dot Net - which is good
Making My Own Browser - Uhm...need a name
Learn Java Programming Language Online Step By Step
Text Based Game
Java Or C++
Budding Java Game Developers? - Ever wanted to make your own java web-based game, but not had the time
Have You Ever Tried Soulseek? - P2P program for music sharing
Helpful Registry Edit For Java Programmers - Command Prompt on right click menu
What Program Do You Use To Design Your Web? - Frontpage, Dreamweaver, a good text editor?
Jsp Or Java Chat Script Like Mig33
Best Online Money Making Programmes
Carpentry Information - Based on my experiences as a Carpenter
Best Java Framework For J2ee? - Your Opinion About The Best Java Framework
Tips For Making New Friends - What do you do when you have no friends
What Free Advertising Program Do You Like? - Which one works best?
.::gunz Online Clan::. - making a gunz clan lvl 10+
Making And Editing A New Ipb V1.2 Skin [SPAM] - IPB newbie tutorial #2.
Making Winrar Archives - and adding password to winrar archives
Program To Rotate Images 45 Degrees
Are You In Search Of Free Google Cash Program ? - FREE GOOGLE CASH / GOOGLE PROFIT E BOOK
Inbox Dollars - Best Money making Site-I Got Paid
[help] Java Script: Window.open - Works with Firefox, not IE
Im Making A Mmorpg >> - Have a read...
Blender 3d - A nice FREE 3d program
advertisement



Making a java based program



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE