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

How to add and delete nodes in Jtree?

1 Answers   MindMill,


What is the function of abstractaction class?

0 Answers  


What is swing package in java?

0 Answers  


Explain how to render an html page using only swing.

0 Answers  


Why are swing components called lightweight components?

0 Answers  






Why should any swing call back implementation execute quickly?

0 Answers  


What is pane in swing?

0 Answers  


What is the difference between a scrollbar and a jscrollpane ?

0 Answers  


What is sling swing?

0 Answers  


What is container in java swing?

0 Answers  


What is the relationship between clipping and repainting?

0 Answers  


What class is at the top of the AWT event hierarchy?

0 Answers  


Categories