How can you draw using Swing components?



How can you draw using Swing components?..

Answer / chandra rekha

use the getGraphics method to get an object of the graphics
class and with that object we can perform draw methods.
for example
public class myclass extends...implements ActionListener
{
...
...
....
public void actionPerformed(ActionEvent ae)
{
if(ae==....)
{
Graphics g=getGraphics();
g.drawLine(100,200,150,250);
}
}
.....

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More Swing Interview Questions

Why should any swing call back implementation execute quickly?

0 Answers  


Explain the differences between an applet and a Japplet?

2 Answers   College School Exams Tests, Satyam,


What is jfc swing in java?

0 Answers  


How to render an html page using only swing.

0 Answers  


What is import javax swing?

0 Answers  






Which containers use a border Layout as their default layout in swing?

0 Answers  


what do u mean by GUI framework

1 Answers  


How to reload a jframe in java swing?

0 Answers  


How is parsing html used in swing?

0 Answers  


What are the advantages of the event-delegation model over the event-inheritance model?

0 Answers  


What are the various components of swing?

0 Answers  


What is difference between applet and swing?

0 Answers  


Categories