问题
I read source code of Java Graphics abstract class, I am curious how does this abstract void drawline method draws lines in JComponent's paint(Graphics g) and paintComponent(Graphics g). I know that abstract methods have no method body. I couldn't find any relevant examples with Google. If possible, can you provide me a link to source code of this method.
回答1:
Mad Programmer is right, all of java's graphics and graphics2d methods is directed with native codes. If you're curious about these native codes, open src zip of your JDK go to Java Desktop/sun/java2d/windows/GDIRenderer. You can see some native methods for graphics class.
来源:https://stackoverflow.com/questions/51974770/java-how-does-graphics-abstract-drawline-method-really-works