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

What is Java Swing?

0 Answers  


What is swing?

0 Answers  


please any one explain this project: Minimizing recovery state in geographic ad hoc routing

1 Answers   IBM,


What are all the components used in Swing?

1 Answers  


What does x mean in javax.swing?

7 Answers  






What are the components of swing?

0 Answers  


Why are swing components called lightweight components?

0 Answers  


Default layout for a ContentPane in JFC?

8 Answers   HCL,


What is the use of jcomponent class in swing?

0 Answers  


Why are swings considered lightweight?

0 Answers  


What is the default look and feel of a Swing Component?

3 Answers  


What are the swing components?

0 Answers  


Categories