Solved

button to a frame?

Posted on 2001-06-22
3
244 Views
Last Modified: 2010-03-31
how can i add a textfield and buuton to aframe?
0
Comment
Question by:mca1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

752 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