Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions? | Software Development
 

How to Create Button on Frame

In this section, you will learn how to create Button on frame the topic of Java AWT package.

How to Create Button on Frame

                         

In this section, you will learn how to create Button on  frame the topic of Java AWT package. In the section, from the generated output of the following program, complete window or frame is created in the ButtonText class that is the main class where the main() method lies. This part of the topic will show a simple command button labeled with the text "Submit" when the program will be executed.

Here, you will learn simply the procedure of creation a command button on the Java Awt Frame. There is a program for the best illustration the topic has been given ahead.

Description of Program

The following program has used simply the Button class for creating a command button on the frame object.

FlowLayout(): This is the constructor of FlowLayout class. This class is used for arranging the component from left to right. Here this is used for creating the object of the class to set the layout by passing the created object from the setLayout() method of the Frame class.

Here is the code of  this program:

import java.awt.*; 
import java.awt.event.*;
 

public class ButtonText 
  public static void main(String[] args) {
    Frame frame=new Frame("Button Frame");
    Button button = new Button("Submit")
    frame.add(button)
    frame.setLayout(new FlowLayout());
    frame.setSize(200,100);
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent e){
        System.exit(0);
      }
    });
  }
}

Output this program:

  

Download this Example:

                         

» View all related tutorials
Related Tags: c list interface event methods multiple interfaces method ip int ai listener to listeners e multi li ul im ce

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

3 comments so far (
post your own) View All Comments Latest 10 Comments:

how to insert button for a frame

Posted by pr on Monday, 04.6.09 @ 14:19pm | #86544

Inserting button to a frame

Posted by sushe on Monday, 04.6.09 @ 14:16pm | #86543

java swings material

Posted by Arjun on Monday, 12.1.08 @ 06:13am | #82235

 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.