View Single Post
  #7 (permalink)  
Old 07-07-2009, 04:24 PM
RamyaSivakanth's Avatar
RamyaSivakanth RamyaSivakanth is offline
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 589
Rep Power: 1
RamyaSivakanth is on a distinguished road
Default
Hi,
How many times u type wrongly and ask for suiggestion.Gothru this...


Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class JDemoCreateGraphicsObject3 extends JApplet implements ActionListener
{
String companyName = new String("Event Handlers Incorperated ");
JButton moveButton = new JButton("Move it ");
Font helv12Font = new Font("Helvetica ", Font.ITALIC, 12);
int x = 10, y = 50;

public void init ()
{
setBackground(Color.YELLOW);
Container con = getContentPane();
con.setLayout(new FlowLayout() );
con.add(moveButton);
moveButton.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
Object source = ae.getSource();
if (source == moveButton)
{
Graphics pen = getGraphics();
pen.setFont(helv12Font);
pen.setColor(Color.MAGENTA);
if(x < 250)
{
pen.drawString(companyName, x+=20, y+= 20);
}
else
{
moveButton.setEnabled(false);
pen.setColor(Color.BLACK);
pen.drawOval(50, 170, 70, 70);
pen.drawLine(85, 240, 110, 300);
pen.drawOval(100, 170, 70, 70);

}

}

}
}
__________________
Ramya
Reply With Quote