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 is Java Swing?

578


Is java swing still used?

510


How to render an html page using only swing.

576


Which swing methods are thread-safe?

620


What is java swing used for?

512






What is difference between applet and swing?

514


Can a class be it?s own event handler? Explain how to implement this?

518


What are the swing components?

478


Is swing thread-safe?

546


What are the components of swing in java?

525


What is swing and its features in java?

474


Why swing is used in java?

513


What is swing control?

490


How does accessibility works in swings?

533


How to align components in java swing?

564