Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

button to a frame?

Posted on 2001-06-22
3
Medium Priority
?
259 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 300 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

722 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