How can you draw using Swing components?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the swing components in java?

738


What is java swing components?

764


Why do we use swing in java?

706


Which method is used for setting security in applets?

802


What is the function of internal frame in swing?

799


What is swing and awt in java?

704


How to align components in java swing?

802


What is import javax swing?

706


What are the two key features of swing?

714


What is a swing day?

729


What is swing api?

713


Why are swings considered lightweight?

761


What are the advantages of swing?

706


What are the containers available in swing?

731


Is java swing a framework?

753