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 awt and swing?

0 Answers  


Is swing an adjective?

0 Answers  


Why would you use swingutilities.invokeandwait or swingutilities.invokelater?

0 Answers  


What are the containers available in swing?

0 Answers  


how to give transparency for JComboBox,JListBox and JTable

2 Answers   TCS,






how can u handle runtime exceptions in java plz explain with examples briefly?

3 Answers   Fujitsu, IBM,


What's java swing?

0 Answers  


How to link two forms in java swing?

0 Answers  


How do you swing an applet?

0 Answers  


what is difference between checked and unchecked exception plz explain examples ?

5 Answers   Fujitsu,


What are all the components used in Swing?

1 Answers  


what are the root classes of all classes?

4 Answers  


Categories