Solved

button to a frame?

Posted on 2001-06-22
3
240 Views
Last Modified: 2010-03-31
how can i add a textfield and buuton to aframe?
0
Comment
Question by:mca1
3 Comments
 

Accepted Solution

by:
anmadhu earned 75 total points
ID: 6217324
create objects for the field, button and frame.
for eg

Frame a =new Frame("asdf");
TextField b=new TextField("qwer",30);
Button c=new Button("button");
a.setSize(200,200);
a.add("North",c);
a.add("Center",b);
a.setVisible(true);
0
 
LVL 3

Expert Comment

by:rjackman
ID: 6217327
simple
add following in ur code
java.awt.Frame f = new java.awt.Frame();
java.awt.Button but = new java.awt.Button("myButton");
f.add(but);
java.awt.TextField tf = new java.awt.TextField(10);
f.add(tf);
f.pack();
f.setVisible(true);

cheers
RJ
0
 

Expert Comment

by:RajeshTandel
ID: 6218172
make an instance of textfield or button, get the content type of the frame and add the component to it.
code as follows.

Frame fm = new Frame();
Button btn = new Button("Hello");
fm.getContentPane().add(btn);
fm.setSize(400,400);
fm.show();
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ejb example issues 3 47
add projects t working set in maven 2 37
spring maven example issues 3 38
Java class and jar 3 41
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question