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

Write a program to paint the off-screen buffer in swings

0 Answers  


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

0 Answers  


What are swing components in java?

0 Answers  


What is the base class for all swing components?

0 Answers  


What is an on stage swing?

0 Answers  


What is the difference between AWT & Swing?

21 Answers   BeBo Technologies, Deshaw, TCS,


What is the corresponding Layout for Card in Swing?

3 Answers   Patni,


Why swings are called lightweight components?

0 Answers  


What is java swing application?

0 Answers  


What is pane in swing?

0 Answers  


How to reload a jframe in java swing?

0 Answers  


What is the purpose of transferhandler class?

0 Answers  


Categories