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: how to add pause and play buttons at java applet, dead space cant use mouse buttons, coding for buttons for pharmacy in java, buttons on a food processor, buttons operated electro magnetic gear shifting system references wikipedia, dual elevator call buttons, java pgm to display biodata using buttons textfield,

Forum Jump:


Users browsing this thread: 1 Guest(s)