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 the class in swing to change the appearance of the frame in runtime?

0 Answers  


What is jfc swing in java?

0 Answers  


what do u mean by GUI framework

1 Answers  


What are the differences between Swing and AWT?

0 Answers  


What is meant by Swing?

8 Answers  






How do you swing an applet?

0 Answers  


What is difference between applet and swing?

0 Answers  


Which window contains the swing controls?

0 Answers  


I want to change the appearance of Frame in Runtime, what class can be used to do this?

2 Answers   TCS, Wipro,


how to give transparency for JComboBox,JListBox and JTable

2 Answers   TCS,


Does Swing contains any heavy weight component?

5 Answers  


What is an event handler in swing?

0 Answers  


Categories