Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Java Buttons Java source code
#1

Code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class JavaButtons extends Applet implements ActionListener
{
  String msg = " ";
  Button bList[] = new Button[3];
  public void init()
  {
  Button Yes = new Button("Yes");
  Button No = new Button("No");
  Button MayBe = new Button("May Be");

  bList[0] = (Button) add(Yes);
  bList[1] = (Button) add(No);
  bList[2] = (Button) add(MayBe);
  for(int i = 0;i < 3 ;i++)
  {
  add(bList[ i ]);
  bList[ i ].addActionListener( this );
  }
  }
  public void actionPerformed(ActionEvent ae)
  {
  for(int i = 0;i < 3 ;i++)
  {
  if(ae.getSource() == bList[ i ])
  {
  msg ="You Pressed " + bList[i].getLabel();
  }
  }
  repaint();
  }
  public void paint(Graphics g)
  {
  g.drawString(msg,1,100);
  }
}
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: dual elevator call buttons, dead space cant use mouse buttons, abstract of buttons, buttons on a food processor, how to add pause and play buttons at java applet, simple student registration form with update delete insert and exit buttons using java swing and mysql, abstract on aacess control using i buttons,

Forum Jump:


Users browsing this thread: 1 Guest(s)