473,320 Members | 2,000 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

had a probelm in button program

11
in this pgm, 1 textbox and 1 button displays in the frame. if i enter 3 in the text box means, three buttons will display on right hand side. Then if click every single button means it should display two butons on lefthand side. plz help me.
The code is as follows.


import java.awt.*;
import java.awt.event.*;
public class buttons1 extends Frame implements ActionListener
{
TextField t1;
Button b1,b2,b3;
Button[] bu;
Button[] bt;
Button BB;
int x1=700;
int y1=0;
int x2=100;
int y2=10;
int x3=180;
int y3=10;
int s1;
int s3;
String s;


public buttons1()
{
setLayout(null);
t1=new TextField(20);
b1=new Button("Enter");
add(b1);
add(t1);
b1.addActionListener(this);
b1.setBackground(Color.blue);
t1.setBounds(400,100,70,30);
b1.setBounds(400,300,70,30);
}

public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
s=t1.getText();
s1=Integer.parseInt(s);
System.out.println("Value of I is"+s1);
String s2[]={"Rone","Rtwo","Rthree","Rfour","Rfive","Rsix","R seven","Reight","Rnine","Rten","Releven","Rtwelve" ,"Rthirteen","Rfourteen","Rfifteen"};
for(int i=0;i<s1;i++)
{
Graphics g=getGraphics();
int y;
y=600/s1;
bu=new Button[s1];
bu[i]=new Button(s2[i]);
bu[i].addActionListener(this);
add(bu[i]);
y1=y1+y;
bu[i].setBounds(x1,y1,70,30);
g.drawLine(470,310,x1,y1+20);
bu[i].setBackground(Color.red);
}
}
s=t1.getText();
s1=Integer.parseInt(s);
for(int i=0;i<s1;s1++)
{
System.out.println(i);
//bu[i].addActionListener(this);
if(ae.getSource()==bu[i])
{
System.out.println("Value of J is");
Button a1=new Button("AAA");
Button a2=new Button("BBB");
a1.setBounds(x2,y2,70,30);
y2=y2+40;
a2.setBounds(x3,y3,70,30);
}
}
}
May 21 '07 #1
0 875

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Sebastian Faust | last post by:
Hi, I have a design problem about which I am thinking now for a while and still couldnt find any help in deja. What I need is something like a virtual function template. I know that this is not...
3
by: QQ | last post by:
Hi here is my short program void main() { while(1) { int command; scanf("%d", &command); switch(command) {
1
by: cfyam | last post by:
How can I to disable some tabpages in TabControl, then user cann't select these pages?
0
by: Pengyu Hong | last post by:
Hi, I host an AxWebBrowser control in my application. Some web sites have Javascript that will open a new window and show results in the new window. I used the following codes to create a new...
0
by: Yoshitha | last post by:
HI I am calling exe (vb.net application) from web application for this i wrote code like this system.diagnosis.process.start("e:\...") i wrote above code in button click event.
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
24
by: 73blazer | last post by:
So a friend an I inadvertanly came across this problem while diagnosing another: I have a table: create table test.test (g_id int not null, g_width int, g_height int); create index testtest on...
0
by: preeti13 | last post by:
i have a two tables employeenominations and reason if someone storing a data first time it will store into the employeenominations table if name is already exist it will store into the reason table...
7
by: jimgym1989 | last post by:
import java.util.*; import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Scanner; public class solano extends JFrame{ private JLabel letterL...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.