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 the implementation of any swing callback (like a listener) execute quickly?

1 Answers  


What is container in java swing?

1 Answers  


What are the benefits if Swing over AWT?

1 Answers  


What are the advantages of swing over awt?

1 Answers  


What is the difference between swing and applet?

1 Answers  


What is the use of java swing?

1 Answers  


What is sling swing?

1 Answers  


can we create a object in static block class A { static { A a=new A(); } }

7 Answers   Cap Gemini,


What things to do to make a web browser compatibale for swing components?

1 Answers   Tesco, TracFone, Wipro,


What are the swing components?

1 Answers  


What is swing container?

1 Answers  


Is swing an api?

1 Answers  


Categories