Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


Hemant Yadav
AWT
1 Answer(s)      3 years and 9 months ago
Posted in : Java Beginners


How to set size of button in awt?


Advertisement
View Answers

November 15, 2010 at 12:51 PM


Hi Friend,

You can use setPreferredSize(new Dimension(40,15)); to set the size of Button in awt.

Here is an example:

import java.awt.*;
import java.awt.event.*;
class ButtonSize extends Frame{
    ButtonSize(){
        Label lab=new Label("Enter Name: ");
        final TextField text=new TextField(20);
        Button b=new Button("Hello");
        Panel p=new Panel();
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                String name=text.getText();
        System.out.println(name);

            }
        });
        p.add(lab);
        p.add(text);
        p.add(b);
        b.setPreferredSize(new Dimension(40,15));     
        add(p);
        pack();
        setVisible(true);
    }
    public static void main(String[] args){
        new ButtonSize();
    }
}

Thanks



Related Tutorials/Questions & Answers:
AWT
AWT  How to set size of button in awt
awt
Java AWT Applet example  how to display data using JDBC in awt/applet
Advertisements
awt
JDBC and AWT to display data  how to display data using JDBC in awt/applet
awt
JDBC in awt applet  how to display data using JDBC in awt/applet
awt
JDBC in awt  how to display data using JDBC in awt/applet
AWT & SWING
AWT & SWING  What is diffennce between AWT & SWING
AWT programmes - Swing AWT
AWT programmes  I need few programs for menus in AWT. how to open a filed dialog window, and how to save a image in the save window when we press... has all AWT programms which must open,save and make changes to a particular
awt in java
awt in java  using awt in java gui programming how to false the maximization property of a frame
Java AWT
Java AWT  What interface is extended by AWT event listeners
awt jdbc
awt jdbc  programm in java to accept the details of doctor (dno,dname,salary)user & insert it into the database(use prerparedstatement class&awt
awt - Swing AWT
awt  dear sir my proble is , i have applet code which is stock market chart this code made using "AWT" . in this chart one textbox when user.../java/awt/ Thanks
Java AWT
Java AWT  What is meant by controls and what are different types of controls in AWT
awt swings - Swing AWT
awt swings  hello sir, My requirement is to insert captured image from cam onto a frame and from that place i hve to save it in the database(MySql).its urgent sir.it is a part of my project..if code is available
java awt calender
java awt calender  java awt code for calender to include beside a textfield
JAVA AWT BASE PROJECT
JAVA AWT BASE PROJECT  suggest meaningful java AWT-base project
AWT-swings tutorial - Swing AWT
AWT-swings tutorial  hello sir, i am learnings swings and applets.. i want some tutorials and some examples related to swings.. thank you sir..waiting for your answer.  Hi friend, I am sending you a link
AWT Tutorials
AWT Tutorials  How can i create multiple labels using AWT????   Java Applet Example multiple labels 1)AppletExample.java: import javax.swing.*; import java.applet.*; import java.awt.*; import
awt list item* - Swing AWT
awt list item*  how do i make an item inside my listitem not visible  Hi friend, import java.awt.*; import java.awt.event.... information. http://www.roseindia.net/java/example/java/awt/ Thanks
Java AWT event hierarchy
Java AWT event hierarchy  What class is the top of the AWT event hierarchy?  The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy
java - Swing AWT
What is Java Swing AWT  What is Java Swing AWT
AWT code for popUpmenu - Swing AWT
AWT code for popUpmenu  Respected Sir/Madam, I am writing a program in JAVA/AWT.My requirement is, a Form consists of a "TextBox" and a "Button... for more information. http://www.roseindia.net/java/example/java/awt/pop
AWT
Basic Diffence between Swing-AWT - Swing AWT
Basic Diffence between Swing-AWT  What is Basic Diffence between Swing-AWT
AWT Image
AWT Image  I have loaded two images using toolkit in java.one is concentric rectangle and other is concentric circle.kindly someone send me the source code of interchanging the inner most rectangle with the inner most circle
awt - Java Interview Questions
awt  what is the difference between awt and swings  Hi friend, These are basically the main differences between awt and swing. 1.swing components sits on the top of AWT components and do the wiork. 2.AWT
Swing and AWT Problem - Swing AWT
Swing and AWT Problem  hi sir i have a problem i know from one Jframe we can send values to another Jframe. so in my project i have one fame containing three textfields CODE: String a=TNa.getText().toString(); String b
AWT basics
AWT basics Are you looking for the AWT Basics to help you learn AWT quickly? Here we have provided you the links to our AWT tutorials. AWT stands.... Now a day?s developers are using Swing components instead of AWT to develop
query - Swing AWT
java swing awt thread query  Hi, I am just looking for a simple example of Java Swing
another frame by using awt or swings
another frame by using awt or swings  how to connect one frame to another frame by using awt or swings
SWINGS - Swing AWT
more information,Examples and Tutorials on Swing,AWT visit to : http://www.roseindia.net/java/example/java/awt/ http://www.roseindia.net/java/example/java
java awt package tutorial
Java AWT Package In Java, Abstract Window Toolkit(AWT) is a platform... programming language, the AWT is also platform-independent. A common set.... The implementation of the user interface elements provided by the AWT is done using
Awt programming with java
Awt programming with java  Write a java program, which provides a text area with horizontal and vertical scrollbar.Type some lines in the text area and use scrollbars to move the text within the text area.Read a word in a text
date and time in awt(java)
date and time in awt(java)  sir, do you have an example of date in awt java which can be view over a textfield.   Display time in JTextField import java.util.*; import javax.swing.*; import java.awt.event.*; public
JavaThread "AWT-EventQueue-176 - Applet
JavaThread "AWT-EventQueue-176  Hello, I am getting some dump files... --------------- Current thread (0x02cd1ef0): JavaThread "AWT-EventQueue-176" [_thread... java.awt.event.InvocationEvent.dispatch()V+47 J java.awt.EventQueue.dispatchEvent(Ljava/awt
Window State - Swing AWT
Window State  Thanks for you reply. I have already tried the setSize() method of AWT Window and also with JFrame. But I want to Maximize the Window when it is opened by the user and instead of the Maximize
Calling awt Frame methods from subclass
Calling awt Frame methods from subclass  Calling awt Frame methods from subclass
AWT Components
AWT Components       The class component is extended by all the AWT components. More of the codes can be put to this class to design lot of AWT components. Most of the AWT
java - Swing AWT
java  i want a program that accepts string from user in textfield1 and prints same string in textfield2 in awt   hi, import java.awt.... information, http://www.roseindia.net/java/example/java/awt/ Thanks
java awt components - Java Beginners
java awt components  how to make the the button being active at a time..? ie two or more buttons gets activated by click at a time
Java Dialogs - Swing AWT
/springlayout.html http://www.roseindia.net/java/example/java/awt/borderlayout-example
tooltip problem - Swing AWT
tooltip problem  Hi All, I am using SWT_AWT bridge in my code to embed swing components into SWT Composite. I am using a Swing JButton in SWT Composite. My problem is that I am unable to see the tooltip for this button even
GUI - Swing vs. AWT
Java: GUI - Swing vs. AWT The original graphical user interface (GUI) for Java was called the Abstract Windowing Toolkit (AWT). Performance and extendability problems with AWT were resolved by introducing a new GUI interface, known
provide code - Swing AWT
provide code  Dear frnds please provide code for two player CHESS GAME.....using swings,awt concepts   Hi friend, import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; public
What is AWT in java
What is AWT in java In this Example we will describe awt in java. The awt in java stands for Abstract Windowing Toolkit and is a package available with JDK. awt contains all classes and develops user interface objects like
SWT_AWT bridge ,jtextfield edit problem - Swing AWT
SWT_AWT bridge ,jtextfield edit problem  Hi All, I am using SWT_AWT..._AWT bridge frame and adding JTextfield to it, My problem is that the JTextfield...*; public class SWT_AWT { public static void main(String[] args
Java AWT Package Example
Java AWT Package Example       In this section you will learn about the AWT package of the Java. Many running examples are provided that will help you master AWT package. Example
how to print all colors using awt
how to print all colors using awt  how to print all colors using awt
Design a Toll bar - Swing AWT
Design a Toll bar  Hi,i am very new to Swings-awt..... Please any one send me the Logic to Create a Toolbar which is similar to --- winword(Standard/Formating Tool bar). it's very urgent. Thanks in Advance. Thanks
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException   when i click on the SUBMIT button ON,OFF window is visiable first OFF button is clicking I getting the error : Exception in thread "AWT-EventQueue-0
What is AWT in java
What is AWT in java      ... available with JDK. AWT stands for Abstract Windowing Toolkit. It contains all classes... toolkits. You can use the AWT package to develop user interface objects like
 

 

 

DMCA.com