473,394 Members | 1,765 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,394 software developers and data experts.

Button event problem

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 24 '07 #1
1 1231
r035198x
13,262 8TB
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);
}
}
}
Use code tags. I've already told you this before.
May 24 '07 #2

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

Similar topics

3
by: Jason Kyle Baginski | last post by:
Here's a little test app to demonstrate a problem I'm having. It creates four buttons, each one with the different FlatStyle types available. Three of them behave exactly the same way(and the...
6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
4
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code...
5
by: Tina | last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing validation elsewhere on the page. I want to specify that these buttons should not cause validation but they have no design...
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.